CommonMark.js 0.27.0

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.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") 21.2.2.12 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 README.md.
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 README.md (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 release_checklist.md.
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 (http://google.com/?q= 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.