CommonMark.js 0.29.1

CommonMark.js is a reference implementation for JavaScript. (And a C version available as well). It parses the document format, provides a modifyable abstract syntax tree, and can render to HTML, XML, or per DOM. It's also readily available as NPM/io.js module.

Tags javascript commonmark markdown rendering html5 browser
License BSDL-2
State stable

Recent Releases

0.29.110 Jan 2020 06:05 minor feature: Export Renderer (#162, Federico Ramirez). Export the Renderer class so consumers can use it as a base class for their own customRenderer's. API change . end source position for fenced code and raw HTML. Ensure that is treated as punctuation character. Remove redundant token from reHtmlBlockOpen (Vas Sudanagunta). Remove unused variable reWhitespace. Don't decode url before encoding it again (Daniel Berndt). Don't allow link destinations with unbalanced unescaped parens. Don't put quote delims on stack if not --smart. Don't add to delim stack if !can_open !can_. Remove no longer used argument to escapeXml (#169, Robin Stocker). Avoid numerical conversion for file names in argv (#164, Alex Kocharin). Adapt existing encoding-based regression test and add 25-based regression test (Daniel Berndt). Add pathological test for #172 illustrating quadratic time. pathological case commonmark/cmark#178. Add pathological test for cmark#178. Dingus: remove deging console.log. Sync.editorconfig indent_size to actual (#178, Vas Sudanagunta). Add lint rule for unused variables. Apply npm audit suggestions. invalid package.json dependency entries (Vas Sudanagunta).
0.29.009 Apr 2019 14:05 minor feature: Update spec to 0.29. parsing of setext headers after reference link definitions. code span normalization to conform to spec change. Allow empty destinations in link refs. See commonmark/commonmark#172. Update link destination parsing. dingus: add dependency version requirements (#159, Vas Sudanagunta). Dingus was rendering incorrectly with Bootstrap 4. Added a bower.json which requires Bootstrap, jQuery and Lodash with major version equal to what's currently live. Likewise the minimum patch version. package.json: Add version for bower in devDependencies. package.json - use operator for versions. Allow internal delim runs to match if both have lengths that are multiples of 3. See commonmark/commonmark#528. Remove now unused 'preserve_entities' option on escapeXml. This was formerly used (incorrectly) in the HTML renderer. It isn't needed any more. API change . html renderer: Don't preserve entities when rendering href, src, title, info string. This gives rise to double-encoding errors, when the original markdown is e.g. amp;colon;, since the commonmark reader already unescapes entities. Thanks to Sebastiaan Knijnenburg for noticing this. More efficient checking for loose lists. This a case like commonmark/cmark#284. Disallow unescaped ( in parenthesized link title. Add pathological test. Comment out failing pathological test for now. Add pathological tests for #157. two exponential regex backtracking vulnerabilities (#157, Anders Kaseorg). ESCAPED_CHAR already matches , so matching it again in another alternative was causing exponential complexity explosion. This makes the following behavior changes: foo is no longer incorrectly accepted as a link reference. is no longer incorrectly accepted as an angle-bracketed link destination. package.json: require lodash = 4.17.11. Require cached-path-relative = 1.0.2. This a security vulnerability, but it's only in the dev dependencies. Update fenced block parsing for spec change. Require space before title in referen
0.27.019 Nov 2016 10:25 minor feature: Update spec to 0.27. Use correct name in DOCTYPE declaration for XML output. It should be document, not CommonMark. Node type names in README (Jan Marthedal Rasmussen). Allow shortcut link before a (. See jgm/CommonMark#427. Added all characters in Pc, Pd, Pe, Pf, Pi, Po, Ps to rePunctuation (#108, problem not recognizing East Asian punctuation). Allow tab after setext header line. Recognize h2..h6 as block tags (see jgm/CommonMark#430). Enforce spec's distinction between Unicode whitespace and regular whitespace (Timothy Gu, see jgm/CommonMark#343). Per ECMA-262 6th Edition. ("ECMAScript 2015") CharacterClassEscape , the JavaScript s. escape character matches the characters specified by "Unicode whitespace," but not "whitespace." Rename the existing regular expression variable to UnicodeWhitespace, and create and use a new regular expression variable that only matches the limited set of "whitespace" characters. Removed unused definition.
0.26.016 Jul 2016 15:45 minor feature: Implemented spec changes to lists: Don't allow ordered lists to interrupt a paragraph unless. they start with 1. Remove two-blanks-break-out-of-lists feature. Blank list item can't interrupt paragraph. . Don't allow ordered lists to interrupt a paragraph unless they start with 1. Remove two-blanks-break-out-of-lists feature. Blank list item can't interrupt paragraph. minor regex with raw HTML blocks. This would affect things like: SPACE SPACE . x which, with the change, gets parsed as a raw HTML block, instead of a. single paragraph with inline HTML, a line break, and 'x'. The new behavior conforms to the spec. See #7 in 4.6. Added regression. . Remove unnecessary check (Nik Ryby). It looks like columns is always true in this block, so there's no need to check it during the assignment to count. Simplify and optimize brackets processing (links/images) (Robin Stocker). Together, these changes make the "nested brackets 10000 deep" pathological case go from 400 ms to 20 ms. Changes in emph/strong emph parsing to match changes in spec. This implements the rule that we can't have emphasis matches when (a) one of the delimiters can open AND can, and (b) the sum of the lengths of the delimiter runs containing open and delimiters is a multiple of 3. not existing property usage (Maksim Dzikun). tabs in ATX headers and thematic breaks. Remove unused write-only variable (Maksim Dzikun).
0.25.117 Apr 2016 13:25 minor feature: Ensure that advanceNextNonspace resets partiallyConsumedTab. This a regression in which the first character after a tab would sometimes be dropped. Added regression tests. XML renderer: escape attribute values (muji). dingus vulnerability (muji). Use an iframe and innerHTML to prevent tags from executing. Dingus: let preview show when query has text=. Previously we had these URLs open the HTML pane first, but now that we have XSS protection (the iframe), it should be okay to open the preview pane first. Dingus: don't print sourcepos attributes in HTML/AST view.
0.25.027 Mar 2016 01:25 minor feature: API change Added abstract renderer; adjusted HTML renderer to use. its prototype (muji, jgm). tabs in list indentation. This advanceOffset to better handle cases where a list indent doesn't consume all of the virtual spaces represented by a tab. Proper tab handling with blockquotes, fenced code, lists. handling of partially consumed tabs. logic with blank line after empty list item. Ensured render directory is installed by npm (muji). Better ECMAScript 5 style inheritance (muji). Don't require sudo for make bench. Added command line usage (Daniel Baird). Brought CLI options in line with cmark. Now you say -t xml instead of --xml. Use minima for cli option parsing, add --help. Tweaked description of commonmark program. Now that we have --help we can forego a detailed description of options.
0.24.015 Jan 2016 01:45 minor feature: API change Added version. Added --version to cli program. Updated spec.txt to 0.24. Updated test runner to new spec format. Allow multiline setext header content. Don't allow spaces in link destinations, even in . Updated recognizer for absolute URIs. We no longer use a whitelist of valid schemes. Remove unused variable markerStartCol (Nik Nyby). inaccurate comment about UnmatchedBlocks (Nik Nyby). This function is void, and doesn't return true.
0.23.003 Jan 2016 06:25 minor feature: API change Rename nodes: "Html" - "HtmlInline". API change Add CustomBlock, CustomInline. API change Rename "HorizontalRule" - "ThematicBreak". API change Rename "Header" - "Heading" (spec change). Don't allow whitespace between link text and link label of a reference link (spec change.). calculation of list offsets. Allow tab after bullet list marker. advanceOffset - copy the code from libcmark. a list/tab/padding corner case. Escape HTML contents in xml output, as the DTD requires PCDATA. xml renderer - added xmlns attribute. Test on node.js 5.x and 4.x (Nik Nyby). Remove testing on iojs. Initialize _listData to when creating Node. Added version check for uglify; updated dist files. typo in breakOutOfLists description (Nik Nyby). Updated benchmarks in
0.22.120 Nov 2015 16:05 minor feature: README: Use an https URL for commonmark.js. README: typo. Reset container after closing containing lists. Use mdurl 1.0.1, to avoid problems with Google closure compiler. Adjusted.npmignore so the package doesn't include extraneous files (#72, Hypercubed).
0.22.025 Aug 2015 08:05 minor feature: Added iframe to whitelist of HTML block tags (as per spec). Removed pre from rule 6 of html blocks (see jgm/CommonMark#355). Logic error in calculation of offset. Here's a test case this: echo -en "1. t tthere" bin/commonmark. Disallow list item starting with multiple blank lines in list-start parser. Changed smart quote algorithm to agree with cmark. The change only Involves double quotes, which now need to be both left flanking and Not right flanking to count as "can open.". Replacement of multiple apostrophes in the same paragraph with --smart (Brandon Frohs). Make bench: renice to -10 rather than 99.
0.21.015 Jul 2015 09:45 minor feature: Updated to version 0.21 of spec. Implemented safe option. This suppresses output of raw HTML and potentially unsafe URLs. Documented smart option. Allow non-initial hyphens in html tag names. This allows for custom tags, which in HTML5 MUST contain a hyphen. See jgm/CommonMark#239. Revised HTML block parsing to conform to new spec. Imposed 9-digit limit on ordered list markers, per spec. Improved smart_punct.txt tests, and added some commentary (a proto-spec). Improved smart handling of dashes. We now process whole strings of hyphens in such a way as to ensure that we don't get a mix of hyphens and em and en dashes (#56, Brandon Frohs). Dingus: Removed duplicated CSS line (Aurelio Jargas). Dingus: Make permalink record whether 'smart' was selected. Dingus: Removed Makefile dependency on html5-entities.js. Reset options before calling inlineParser. Otherwise, if the main parser's options have changed since it was instantiated, the new options won't be visible to the inlineParser. Properly split on whitespace in HTML renderer. Fixed bench for new version of showdown (soomtong). processEmphasis: renamed potential_openers - openers_bottom. better logic for setting lower bound in openers_bottom. Fixed emphasis/link parsing bug. Reset this.column on new parse. Fixed test runner to handle visible tabs in spec HTML. Improved detection of column with tabs in input. Added advanceNextNonspace and advanceOffset functions. Removed detabLine and tabs-to-spaces conversion. Added column and nextNonspaceColumn to parser. Adjust these in findNextNonspace. Added note on README about how to fetch dependencies. Fix link reference definition edge case (Benjamin Dumke- von der Ehe). If the reference seems to have a valid title that does not go until the end of the line, check if the reference becomes valid when discarding the title. Fixed link label recognizer. Allow a backslash-escaped backslash. Use mdurl instead of copied encode.js, decode.js. Use entities from npm instead
0.20.009 Jun 2015 12:05 minor feature: Ensure that link labels contain non-whitespace (jgm/CommonMark#322). Strip brackets in normalize-reference. Otherwise the stripping. of leading/trailing whitespace doesn't work. For example: hi . hi : url. . Use U+FFFD for entities resolving to 0 (jgm/CommonMark#323). Fixed bug with list items indented = 4 spaces. Extract regex test results in scanDelims as local variables (Robin Stocker). Also, abort earlier when no delims where found. Allow a partial open block tag to be recognized when followed by a newline with no space. For example: . Added test for alternate line endings. Added travis npm buttons to (Vitaly Puzrin). Travis-CI: refresh node.js versions use docker containers (Vitaly Puzrin). Dingus css: set colors for textarea. Otherwise we may run into problems for people who have set their textarea default colors.
0.19.023 May 2015 09:45 minor feature: Fixed underscore emphasis to conform to spec changes. Fixed variable shadowing (linter warnings) in test.js. Makefile: Moved lint first to avoid regenerating dist by accident. Dingus: Fixed word wrapping in text area. Updated spec.txt in test/. Added
0.18.223 Apr 2015 03:15 minor feature: Fixed walker so that it stops at this.root, even when this is not the document root. Fixed typo (Ed Adams). Removed unused argument from processEmphasis (Robin Stocker). Shortened code for removing a sequence of delimiters, changing the links on the edges rather than dropping them one by one (Eli Barzilay). Code layout improvements for readability (Eli Barzilay). Dingus: rewrote without ACE editor for better accessibility and to fix layout in smal windows. Optimize checking for final spaces in parseNewline (Robin Stocker). This yields a 5-10 speed improvement in make bench. Consolidated regex definitions (Robin Stocker). Return boolean from spnl and parseBackticks for consistency (Robin Stocker). Removed unnecessary check for hrule in parseListMarker (Robin Stocker). Return error status if tests fail. Use encode/decode from markdown-it/mdurl for URL normalization. This fixes cases like link ( 3f) which was formerly wrongly converted to link. Refactored test.js, adding smart_punct tests from cmark, and factoring out specTest function. Make unmatched double quotes left quotes with smart_punct. Code cleanup in finalize.