commonmark / commonmark/commonmark.js

Delegate node walking to others

Open
#267 3 comments 0 reactions 0 assignees View on GitHub

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 walker interface. 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.
  • 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.