Coder Social home page Coder Social logo

md4w's People

Contributors

ije avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

md4w's Issues

feature: add render page mode

---
title: Hello World
desc: Hello world!
slug: hello-world
cover: /images/hello-world.png
---

![Cover]({cover})

# {title}

Hello world!

๐Ÿ‘‡

<html>
<head>
  <title>Hello World</title>
  <meta name="description" content="Hello world!">
</head>
<body>
  <p><image alt="Cover" src="/images/hello-world.png"></p>
  <h1>Hello World</h1>
  <p>Hello world!<p>
</body>
</html>

In browser loading

I'm a big fan of this lib and thanks for sharing it.

I wanted to ask about the preferred way to load md4w in the browser (client side).

I tried it using Vite (without a CDN). However the dynamic nature of loading prevents Vite from building the final bundle.

<script>
  import { init, mdToHtml } from "md4w";
  await init();
</script>

Error:

โœ˜ [ERROR] Top-level await is not available in the configured target environment ("chrome87", "edge88", "es2020", "firefox78", "safari14" + 2 overrides)

node_modules/.pnpm/[email protected]/node_modules/md4w/js/index.js:12:23:
  12 โ”‚   const { readFile } = await import(m);
     โ•ต                        ~~~~~

Shouldn't be there a dedicated Build for Browsers on npm.js?

Support WebAssembly ESM Integration / unwasm

Hi! Kinda excited to see this project since I was planning to work on some markdown utils pkg and was looking for a fast native parser, this is an amazing effort ๐Ÿ”ฅ

Some context:

There is an outstanding proposal from WebAssmbly working group to support .wasm imports as ESM imports, resolving the ever-lasting issues of inconsistent WASM support across platforms and tools.

Besides this, we have Cloudflare Workers that have their specific requirement that requires a wasm import to be predictable (and not compiled on demand) (and other worker runtimes that don't like top-level await for init)

To allow widely adopting wasm libraries within Nuxt and UnJS ecosystems, I have recently started working on unwasm which is an effort to allow adopting ESM WASM modules ahead of time in toolings and allow a universal way of wasm module consumption. unwasm is under development but also constantly tested to make sure has maximum compatibility at the same time.

What is required for it to work?

A small refactor to split the init functionality from the rest of logic (mem alloc, and util exports).

If you are interested, I can happily make a minimal environment for you to easily try this.

JSON parse error with `mdToJSON` on commonamrk

reproduction:

import { init, mdToJSON } from 'md4w'

const commonMark = await fetch('https://github.com/ije/md4w/raw/main/test/commonmark-spec.md').then(r => r.text())

await init()

try {
  console.log(mdToJSON(commonMark))
} catch (error) {
  console.error(error.stack.slice(0, 200))
}
\Error: Failed to parse JSON: Bad escaped character in JSON at position 4959
[{"type":5},{"type":9,"children":["title: CommonMark Spec","\n","author: John MacFarlane","\n","version: '0.31.2'","\n","data

Use global writer

currently we create a new writer for each renderer call, a global writer without memory alloc/free in each render should have better perfermance.

Exposing parse utils

Hi. I quickly made this tracker issue while writing unjs/automd#32 to see if you are interested to also expose a simple parse util? (could be either stream or returning whole AST). This can be used as parser core in unjs/omark โค๏ธ

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.