Skip to content

Commit

Permalink
Refactor to remove regular expressions
Browse files Browse the repository at this point in the history
...in favour of an algorithmic approach.

New features:

*   Add support for `silent` mode on tokenisers, which will
    detect whether a given value would match that tokeniser,
    but without eating any actual content.
*   Plugging into the parser is singificantly improved;
*   Searching for upcomming inline nodes is improved by allowing
    `locator`s to search for possible places where nodes start.

Fixes:

*   Better handling of mismatched parentheses in links;
*   Continued block-quotes in non-GFM-mode;
*   Block-quotes followed by lazy definitions in commonmark-mode;
*   Malformed HTML block elements are no longer supported;
*   Bug where GFM’s literal URL detection could detect e-mail addresses
    without an at-character;
*   Bug where `mailto:` literal URLs were not properly stripped
    of their protocol.

Todo:

*   A lot of places support escaped (a slash followed by another character),
    instead of allowing any character to be escaped, only certain characters
    should be supported (e.g., all ASCII-character for commonmark-mode, and
    several separate subsets on other flavours).

Closes GH-82.
  • Loading branch information
wooorm committed Dec 22, 2015
1 parent 2723d33 commit 25a26f2
Show file tree
Hide file tree
Showing 93 changed files with 16,471 additions and 2,580 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
build/
components/
coverage/
lib/expressions.js
build.js
mdast.js
mdast.min.js
Expand Down
2 changes: 0 additions & 2 deletions .jscs.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
"components/",
"coverage/",
"node_modules/",
"lib/expressions.js",
"script/build-expressions.js",
"build.js",
"mdast.js",
"mdast.min.js"
Expand Down
5 changes: 4 additions & 1 deletion component.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@
"scripts": [
"index.js",
"lib/defaults.js",
"lib/expressions.js",
"lib/parse.js",
"lib/stringify.js",
"lib/utilities.js"
],
"json": [
"lib/block-elements.json",
"lib/escape.json"
]
}
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
var unified = require('unified');
var Parser = require('./lib/parse.js');
var Compiler = require('./lib/stringify.js');
var escape = require('./lib/escape.json');

/*
* Exports.
Expand All @@ -26,5 +27,8 @@ var Compiler = require('./lib/stringify.js');
module.exports = unified({
'name': 'mdast',
'Parser': Parser,
'Compiler': Compiler
'Compiler': Compiler,
'data': {
'escape': escape
}
});
52 changes: 52 additions & 0 deletions lib/block-elements.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
[
"article",
"header",
"aside",
"hgroup",
"blockquote",
"hr",
"iframe",
"body",
"li",
"map",
"button",
"object",
"canvas",
"ol",
"caption",
"output",
"col",
"p",
"colgroup",
"pre",
"dd",
"progress",
"div",
"section",
"dl",
"table",
"td",
"dt",
"tbody",
"embed",
"textarea",
"fieldset",
"tfoot",
"figcaption",
"th",
"figure",
"thead",
"footer",
"tr",
"form",
"ul",
"h1",
"h2",
"h3",
"h4",
"h5",
"h6",
"video",
"script",
"style"
]
75 changes: 75 additions & 0 deletions lib/escape.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"default": [
"\\",
"`",
"*",
"{",
"}",
"[",
"]",
"(",
")",
"#",
"+",
"-",
".",
"!",
"_",
">"
],
"gfm": [
"\\",
"`",
"*",
"{",
"}",
"[",
"]",
"(",
")",
"#",
"+",
"-",
".",
"!",
"_",
">",
"~",
"|"
],
"commonmark": [
"\\",
"`",
"*",
"{",
"}",
"[",
"]",
"(",
")",
"#",
"+",
"-",
".",
"!",
"_",
">",
"~",
"|",
"\n",
"\"",
"$",
"%",
"&",
"'",
",",
"/",
":",
";",
"<",
"=",
"?",
"@",
"^"
]
}
74 changes: 0 additions & 74 deletions lib/expressions.js

This file was deleted.

22 changes: 22 additions & 0 deletions lib/inline-text-stop.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"default": [
"\\",
"<",
"!",
"[",
"_",
"*",
"`"
],
"gfm": [
"~",
"http://",
"https://",
"mailto:"
],
"commonmark": [],
"pedantic": [],
"breaks": [
"\n"
]
}
Loading

0 comments on commit 25a26f2

Please sign in to comment.