Giter VIP home page Giter VIP logo

Comments (6)

wooorm avatar wooorm commented on May 10, 2024 2

I finally figured out how to get HTML in markdown, properly: https://github.com/wooorm/rehype-raw, which may be useful!

from mdast.

wooorm avatar wooorm commented on May 10, 2024

That's very possible, you can extend mdast with any nodes you like.

Inside the remark ecosystem, however, you may not fare too well: unknown nodes are ignored or thrown about when found, depending on the plugin. You'll also run in the compiler (remark-stringify, used in remark), which will not know what to do with them.

If it looks like HTML, and quacks like HTML, why not use the 'html' type? Note that, if you use your own compiler (e.g., remark-react has their own), you can always do funky stuff in that when compiling to a virtual dom.

Finally, could you expand some more on how you're planning to handle the new nodes? It's an interesting problem and I'd like to help.

from mdast.

KyleAMathews avatar KyleAMathews commented on May 10, 2024

Oh cool! Perfect.

So for the next version of Gatsby I'm building a new data layer based on GraphQL. GraphQL is cool in lots of ways but one big reason is it let's the client (in this case React.js components) tell the server (Gatsby) what data it wants. So the server can offer data in all sorts of ways and the client can pick and choose from the offerings. So for markdown, I want Gatsby to expose markdown in every possible way that a client could want.

So the obvious way for a client to query for markdown data is for the compiled HTML string. But for maximum flexibility I want to give people the option to query the markdown AST directly and build React components directly from the raw markdown AST data. They could specify which components they want to handle lists, paragraphs, headers, etc. This is why it'd be ideal to parse JSX and add the parsed nodes alongside the markdown nodes so the user could just match the Quiz node they put in the markdown with their custom Quiz React component.

Make sense? Seem like a sensible plan?

from mdast.

wooorm avatar wooorm commented on May 10, 2024

Yes, it does makes sense. And I’m working on doing something quite similar, transforming to HAST, however it’s rather hard and I’m unsure how to do it properly 😬

from mdast.

wooorm avatar wooorm commented on May 10, 2024

Hope that answered the issue. If not, either use Gitter, or create a new issue!

from mdast.

naivefun avatar naivefun commented on May 10, 2024

@wooorm is there an example of extending node type? For example I'd like to support something like this block:

@startxxx
...
@end

Is it parsed as paragraph by default?

from mdast.

Related Issues (20)

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.