Comments (6)
I finally figured out how to get HTML in markdown, properly: https://github.com/wooorm/rehype-raw, which may be useful!
from mdast.
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.
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.
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.
Hope that answered the issue. If not, either use Gitter, or create a new issue!
from mdast.
@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)
- Incorrectly eaten value HOT 2
- Incorrectly eaten value HOT 2
- Incorrectly eaten value HOT 1
- Add a `target` on `Link` nodes HOT 1
- Add support for `DefinitionList` nodes HOT 2
- What content models are allowed? HOT 3
- Add support for `meta` field on `Code` blocks HOT 2
- Add support for shortcode blocks HOT 1
- Is the `uri` field RFC3986 compliant? HOT 2
- Support for Hard and Soft line breaks HOT 10
- Rename `depth` to `rank` HOT 4
- Rename `blockquote` -> `blockQuote` HOT 1
- Use separate constructs for flow, text html: `htmlFlow`, `htmlText` HOT 2
- Rename `code` -> `codeFlow`, `inlineCode` -> `codeText` HOT 4
- Slightly change the `label` field on associations
- Add concrete syntax details HOT 5
- mdast@latest (3.0.0) npm package contains no code HOT 7
- Whitespace in URL in link HOT 5
- Incorrectly eaten value HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mdast.