Question: Sanitize Markdown #646

Closed
opened 2026-01-29 14:41:58 +00:00 by claunia · 2 comments
Owner

Originally created by @molinch on GitHub (Dec 28, 2023).

First of all thanks for the awesome lib!

Are you aware of a possibility to parse a string that contains Markdown and sanitize it to ensure only the allowed Markdown functionalities remain?
In our case we want to guarantee we want to guarantee we can only use bold/italic/lists/links.

Originally created by @molinch on GitHub (Dec 28, 2023). First of all thanks for the awesome lib! Are you aware of a possibility to parse a string that contains Markdown and sanitize it to ensure only the allowed Markdown functionalities remain? In our case we want to guarantee we want to guarantee we can only use bold/italic/lists/links.
claunia added the question label 2026-01-29 14:41:58 +00:00
Author
Owner

@xoofx commented on GitHub (Dec 29, 2023):

Are you aware of a possibility to parse a string that contains Markdown and sanitize it to ensure only the allowed Markdown functionalities remain?
In our case we want to guarantee we want to guarantee we can only use bold/italic/lists/links.

Yes, it is possible. Markdig provides the full Abstract Syntax Tree (AST) of a parsed Markdown document. You can process this AST to remove any nodes that are not relevant for your case.

@xoofx commented on GitHub (Dec 29, 2023): > Are you aware of a possibility to parse a string that contains Markdown and sanitize it to ensure only the allowed Markdown functionalities remain? > In our case we want to guarantee we want to guarantee we can only use bold/italic/lists/links. Yes, it is possible. Markdig provides the full Abstract Syntax Tree (AST) of a parsed Markdown document. You can process this AST to remove any nodes that are not relevant for your case.
Author
Owner

@molinch commented on GitHub (Dec 29, 2023):

Merci Alexandre. I'll go that way :)

@molinch commented on GitHub (Dec 29, 2023): Merci Alexandre. I'll go that way :)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#646