-
Hello, great work, thank you for this project! I'm migrating some of our custom syntax into mdast/micromark extensions and I cannot quite reverse engineer the api of There are quite a lot of utils in source (not a bad thing!) but that make is a bit hard to understand at glance and I would be really thankful for a few brief pointers :) As far as I see those function have following interface. function enterSomeStatement(this: MdastContext, token: Token)
function exitSomeStatement(this: MdastContext, token: Token) where interface MdastContext {
// render node
enter: (node: Node, token: Token) => void;
// stop rendering node
exit: (token: Token) => void;
// convert micromark token to string
sliceSerialize: (token: Token) => string;
// ??? what it does, is the interface correct?
getData: (key: string) => any;
// ??? what it does, is the interface correct?
setData: (key: string, value: any) => void;
// ??? what it does?
resume: () => void;
// current ast stack
stack: Node[];
// current token stack
tokenStack: Token[];
}; Q1: Could you consider adding those interface to public types? Current typing of Q2: Is my interface correct? What's the Q3: What the state get/set data should be used for? Q4 (extra): is there a way to access other (child) micromark tokens inside those functions? There are no in token stack, and I cannot add them via another Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hi there! Jakub!
Working on it. I’m in the process of updating the whole collective (unifiedjs/unified#121), and yesterday pushed types to micromark. There are a couple of other issues going into that release. I first built CommonMark support only. Then came all the extensions. Those all affected the core too. Now I’m going through everything again, making it stable, and documenting it.
Not completely, for one the return types are different than the code: https://github.com/syntax-tree/mdast-util-from-markdown/blob/main/lib/index.js.
An example is how
Could you explain in a bit more detail why and what you are doing? |
Beta Was this translation helpful? Give feedback.
Hi there! Jakub!
Working on it. I’m in the process of updating the whole collective (unifiedjs/unified#121), and yesterday pushed types to micromark. There are a couple of other issues going into that release.
I first built CommonMark support only. Then came all the extensions. Those all affected the core too. Now I’m going through everything again, making it stable, and documenting it.
Not completely, for one the return types are different than the code: https://github.com/syntax-tree/mdast-util-from-markdo…