Suggested strategies for "skipping" incomplete/malformed markdown links? #1332
-
Hey remark community, I have a question on what strategies I could consider to skip incomplete/malformed markdown links. Given the following strings, markdown would render (using Github markdown preview to confirm):
I want to understand the general direction on strategies one can apply to essentially skip rendering the link if it is malformed e.g. scenarios 2 and 3 will only print I'm assuming one has to author some validator/transform e.g. const validateMarkdown = (text: string) => string;
validateMarkdown('Hello [world](https://www.world.com)'); // ''Hello [world](https://www.world.com)"
validateMarkdown('Hello [world]'); // ''Hello "
validateMarkdown('Hello [world](https://`'); // ''Hello "
// in a similar way, `validateMarkdown` to be extended to handle HTML comments
validateMarkdown('Hello <!-- this is a comment -->'); // 'Hello <!-- this is a comment -->'
validateMarkdown('Hello <!-- this is a broken comment '); // 'Hello " This question is mostly to understand the recommended approach from the community, and any help from relevant resources within remark/micromark ecosystem to solve this problem will be greatly appreciated.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hey!
The thing is, there is no malformed markdown. |
Beta Was this translation helpful? Give feedback.
There is no "streaming" markdown, it is always a full document.
Make the LLM produce valid markdown.
You can shape the output with libraries like: https://github.com/guidance-ai/guidance and https://github.com/outlines-dev/outlines to ensure the LLM will produce valid markdown.