commonmark / commonmark/commonmark.js
Delegate node walking to others
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.6k
- Forks
- 231
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 3
Description
To reduce the scope of this package (easier to maintain), how about this:
- Remove the
walkerinterface. Instead, the AST parser builds into a real DOM directly.- On the browser, this would be an instance of
Document(that's what e.g. DOM Parser would output). - In node, something like JSDOM can be used.
- So either of those two would be a dependency for this library.
- On the browser, this would be an instance of
- That way, any sanitization or other DOM modification could either use an existing library, such as DOMPurify or write their own code using e.g.
myDocument.querySelectorAll. - Rendering to an HTML string be as simple as
myDocument.innerHTML, and others will likely just append that doc into the DOM directly, without ever producing an HTML string (perf win).
This change would radically lower the scope of this package (building on the shoulder of giants; existing web APIs basically), and would still preserve everything that's unique about this library, which is markdown parsing.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the current walker interface and how the AST parser produces output, then compare the browser Document and JSDOM approaches described in the issue. Done would mean the parser builds a DOM directly, walker-related scope is removed, and consumers can sanitize, query, append, or render the resulting document through existing DOM APIs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100