You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support Incremental Parsing for Streaming Markdown Input/支持流式 Markdown 输入的增量解析 #414
Background
Currently, commonmark-java parses Markdown via Parser.parse(String markdown), which always processes the entire input from scratch and rebuilds the AST.
In streaming scenarios (e.g., live Markdown preview, collaborative editing, chat messages), new content is appended continuously. Re-parsing the whole document each time is inefficient and can cause performance issues for large documents.
Request
I would like to request incremental parsing support — the ability to parse only the newly added Markdown content and update the existing AST without re-parsing unchanged parts.
Possible Approach
Maintain a parsing context (ParserContext) that stores:
How would these benefit from incremental parsing? E.g. if a user makes an edit at the top of the file, you'd have to start over, right? Only if they just happen to append at the end could you use this kind of API. Or would you do the initial parse line by line and save all resulting parsing contexts (assuming they are immutable or can be copied)?
chat messages
This seems a bit strange too, wouldn't you just parse individual chat messages as individual markdown docs separately?
I'm not saying it wouldn't be a nice enhancement but I'd like to know more about your use case?
Activity
robinst commentedon Dec 24, 2025
How would these benefit from incremental parsing? E.g. if a user makes an edit at the top of the file, you'd have to start over, right? Only if they just happen to append at the end could you use this kind of API. Or would you do the initial parse line by line and save all resulting parsing contexts (assuming they are immutable or can be copied)?
This seems a bit strange too, wouldn't you just parse individual chat messages as individual markdown docs separately?
I'm not saying it wouldn't be a nice enhancement but I'd like to know more about your use case?