markdown-it
Advanced tools
Comparing version 11.0.1 to 12.0.0
@@ -15,38 +15,42 @@ #!/usr/bin/env node | ||
prog: 'markdown-it', | ||
version: require('../package.json').version, | ||
addHelp: true | ||
add_help: true | ||
}); | ||
cli.addArgument([ '--no-html' ], { | ||
cli.add_argument('-v', '--version', { | ||
action: 'version', | ||
version: require('../package.json').version | ||
}); | ||
cli.add_argument('--no-html', { | ||
help: 'Disable embedded HTML', | ||
action: 'storeTrue' | ||
action: 'store_true' | ||
}); | ||
cli.addArgument([ '-l', '--linkify' ], { | ||
cli.add_argument('-l', '--linkify', { | ||
help: 'Autolink text', | ||
action: 'storeTrue' | ||
action: 'store_true' | ||
}); | ||
cli.addArgument([ '-t', '--typographer' ], { | ||
cli.add_argument('-t', '--typographer', { | ||
help: 'Enable smartquotes and other typographic replacements', | ||
action: 'storeTrue' | ||
action: 'store_true' | ||
}); | ||
cli.addArgument([ '--trace' ], { | ||
cli.add_argument('--trace', { | ||
help: 'Show stack trace on error', | ||
action: 'storeTrue' | ||
action: 'store_true' | ||
}); | ||
cli.addArgument([ 'file' ], { | ||
cli.add_argument('file', { | ||
help: 'File to read', | ||
nargs: '?', | ||
defaultValue: '-' | ||
default: '-' | ||
}); | ||
cli.addArgument([ '-o', '--output' ], { | ||
cli.add_argument('-o', '--output', { | ||
help: 'File to write', | ||
defaultValue: '-' | ||
default: '-' | ||
}); | ||
var options = cli.parseArgs(); | ||
var options = cli.parse_args(); | ||
@@ -53,0 +57,0 @@ |
@@ -9,2 +9,20 @@ # Changelog | ||
## [12.0.0] - 2020-10-14 | ||
### Added | ||
- `.gitattributes`, force unix eol under windows, for development. | ||
### Changed | ||
- Added 3rd argument to `highlight(code, lang, attrs)`, #626. | ||
- Rewrite tables according to latest GFM spec, #697. | ||
- Use `rollup.js` to browserify sources. | ||
- Drop `bower.json` (bower reached EOL). | ||
- Deps bump. | ||
- Tune `specsplit.js` options. | ||
- Drop `Makefile` in favour of npm scrips. | ||
### Fixed | ||
- Fix mappings for table rows (amended fix made in 11.0.1), #705. | ||
- `%25` is no longer decoded in beautified urls, #720. | ||
## [11.0.1] - 2020-09-14 | ||
@@ -510,2 +528,3 @@ ### Fixed | ||
[12.0.0]: https://github.com/markdown-it/markdown-it/compare/11.0.1...12.0.0 | ||
[11.0.1]: https://github.com/markdown-it/markdown-it/compare/11.0.0...11.0.1 | ||
@@ -512,0 +531,0 @@ [11.0.0]: https://github.com/markdown-it/markdown-it/compare/10.0.0...11.0.0 |
@@ -18,3 +18,3 @@ // Main parser class | ||
var config = { | ||
'default': require('./presets/default'), | ||
default: require('./presets/default'), | ||
zero: require('./presets/zero'), | ||
@@ -85,3 +85,4 @@ commonmark: require('./presets/commonmark') | ||
return mdurl.decode(mdurl.format(parsed)); | ||
// add '%' to exclude list because of https://github.com/markdown-it/markdown-it/issues/720 | ||
return mdurl.decode(mdurl.format(parsed), mdurl.decode.defaultChars + '%'); | ||
} | ||
@@ -88,0 +89,0 @@ |
@@ -43,10 +43,13 @@ /** | ||
langName = '', | ||
highlighted, i, tmpAttrs, tmpToken; | ||
langAttrs = '', | ||
highlighted, i, arr, tmpAttrs, tmpToken; | ||
if (info) { | ||
langName = info.split(/\s+/g)[0]; | ||
arr = info.split(/(\s+)/g); | ||
langName = arr[0]; | ||
langAttrs = arr.slice(2).join(''); | ||
} | ||
if (options.highlight) { | ||
highlighted = options.highlight(token.content, langName) || escapeHtml(token.content); | ||
highlighted = options.highlight(token.content, langName, langAttrs) || escapeHtml(token.content); | ||
} else { | ||
@@ -53,0 +56,0 @@ highlighted = escapeHtml(token.content); |
@@ -1,2 +0,2 @@ | ||
// GFM table, non-standard | ||
// GFM table, https://github.github.com/gfm/#tables-extension- | ||
@@ -20,6 +20,5 @@ 'use strict'; | ||
ch, | ||
escapes = 0, | ||
isEscaped = false, | ||
lastPos = 0, | ||
backTicked = false, | ||
lastBackTick = 0; | ||
current = ''; | ||
@@ -29,36 +28,22 @@ ch = str.charCodeAt(pos); | ||
while (pos < max) { | ||
if (ch === 0x60/* ` */) { | ||
if (backTicked) { | ||
// make \` close code sequence, but not open it; | ||
// the reason is: `\` is correct code block | ||
backTicked = false; | ||
lastBackTick = pos; | ||
} else if (escapes % 2 === 0) { | ||
backTicked = true; | ||
lastBackTick = pos; | ||
if (ch === 0x7c/* | */) { | ||
if (!isEscaped) { | ||
// pipe separating cells, '|' | ||
result.push(current + str.substring(lastPos, pos)); | ||
current = ''; | ||
lastPos = pos + 1; | ||
} else { | ||
// escaped pipe, '\|' | ||
current += str.substring(lastPos, pos - 1); | ||
lastPos = pos; | ||
} | ||
} else if (ch === 0x7c/* | */ && (escapes % 2 === 0) && !backTicked) { | ||
result.push(str.substring(lastPos, pos)); | ||
lastPos = pos + 1; | ||
} | ||
if (ch === 0x5c/* \ */) { | ||
escapes++; | ||
} else { | ||
escapes = 0; | ||
} | ||
isEscaped = (ch === 0x5c/* \ */); | ||
pos++; | ||
// If there was an un-closed backtick, go back to just after | ||
// the last backtick, but as if it was a normal character | ||
if (pos === max && backTicked) { | ||
backTicked = false; | ||
pos = lastBackTick + 1; | ||
} | ||
ch = str.charCodeAt(pos); | ||
} | ||
result.push(str.substring(lastPos)); | ||
result.push(current + str.substring(lastPos)); | ||
@@ -70,4 +55,5 @@ return result; | ||
module.exports = function table(state, startLine, endLine, silent) { | ||
var ch, lineText, pos, i, nextLine, columns, columnCount, token, | ||
aligns, t, tableLines, tbodyLines; | ||
var ch, lineText, pos, i, l, nextLine, columns, columnCount, token, | ||
aligns, t, tableLines, tbodyLines, oldParentType, terminate, | ||
terminatorRules; | ||
@@ -131,11 +117,20 @@ // should have at least two lines | ||
if (state.sCount[startLine] - state.blkIndent >= 4) { return false; } | ||
columns = escapedSplit(lineText.replace(/^\||\|$/g, '')); | ||
columns = escapedSplit(lineText); | ||
if (columns.length && columns[0] === '') columns.shift(); | ||
if (columns.length && columns[columns.length - 1] === '') columns.pop(); | ||
// header row will define an amount of columns in the entire table, | ||
// and align row shouldn't be smaller than that (the rest of the rows can) | ||
// and align row should be exactly the same (the rest of the rows can differ) | ||
columnCount = columns.length; | ||
if (columnCount > aligns.length) { return false; } | ||
if (columnCount !== aligns.length) { return false; } | ||
if (silent) { return true; } | ||
oldParentType = state.parentType; | ||
state.parentType = 'table'; | ||
// use 'blockquote' lists for termination because it's | ||
// the most similar to tables | ||
terminatorRules = state.md.block.ruler.getRules('blockquote'); | ||
token = state.push('table_open', 'table', 1); | ||
@@ -152,3 +147,2 @@ token.map = tableLines = [ startLine, 0 ]; | ||
token = state.push('th_open', 'th', 1); | ||
token.map = [ startLine, startLine + 1 ]; | ||
if (aligns[i]) { | ||
@@ -160,3 +154,2 @@ token.attrs = [ [ 'style', 'text-align:' + aligns[i] ] ]; | ||
token.content = columns[i].trim(); | ||
token.map = [ startLine, startLine + 1 ]; | ||
token.children = []; | ||
@@ -170,17 +163,31 @@ | ||
token = state.push('tbody_open', 'tbody', 1); | ||
token.map = tbodyLines = [ startLine + 2, 0 ]; | ||
for (nextLine = startLine + 2; nextLine < endLine; nextLine++) { | ||
if (state.sCount[nextLine] < state.blkIndent) { break; } | ||
terminate = false; | ||
for (i = 0, l = terminatorRules.length; i < l; i++) { | ||
if (terminatorRules[i](state, nextLine, endLine, true)) { | ||
terminate = true; | ||
break; | ||
} | ||
} | ||
if (terminate) { break; } | ||
lineText = getLine(state, nextLine).trim(); | ||
if (lineText.indexOf('|') === -1) { break; } | ||
if (!lineText) { break; } | ||
if (state.sCount[nextLine] - state.blkIndent >= 4) { break; } | ||
columns = escapedSplit(lineText.replace(/^\||\|$/g, '')); | ||
columns = escapedSplit(lineText); | ||
if (columns.length && columns[0] === '') columns.shift(); | ||
if (columns.length && columns[columns.length - 1] === '') columns.pop(); | ||
token = state.push('tr_open', 'tr', 1); | ||
if (nextLine === startLine + 2) { | ||
token = state.push('tbody_open', 'tbody', 1); | ||
token.map = tbodyLines = [ startLine + 2, 0 ]; | ||
} | ||
token = state.push('tr_open', 'tr', 1); | ||
token.map = [ nextLine, nextLine + 1 ]; | ||
for (i = 0; i < columnCount; i++) { | ||
token = state.push('td_open', 'td', 1); | ||
token.map = [ nextLine, nextLine + 1 ]; | ||
if (aligns[i]) { | ||
@@ -191,3 +198,2 @@ token.attrs = [ [ 'style', 'text-align:' + aligns[i] ] ]; | ||
token = state.push('inline', '', 0); | ||
token.map = [ nextLine, nextLine + 1 ]; | ||
token.content = columns[i] ? columns[i].trim() : ''; | ||
@@ -200,8 +206,14 @@ token.children = []; | ||
} | ||
token = state.push('tbody_close', 'tbody', -1); | ||
if (tbodyLines) { | ||
token = state.push('tbody_close', 'tbody', -1); | ||
tbodyLines[1] = nextLine; | ||
} | ||
token = state.push('table_close', 'table', -1); | ||
tableLines[1] = nextLine; | ||
tableLines[1] = tbodyLines[1] = nextLine; | ||
state.parentType = oldParentType; | ||
state.line = nextLine; | ||
return true; | ||
}; |
{ | ||
"name": "markdown-it", | ||
"version": "11.0.1", | ||
"version": "12.0.0", | ||
"description": "Markdown-it - modern pluggable markdown parser.", | ||
@@ -20,3 +20,3 @@ "keywords": [ | ||
"lint": "eslint .", | ||
"test": "npm run lint && nyc mocha && node support/specsplit.js test/fixtures/commonmark/spec.txt", | ||
"test": "npm run lint && nyc mocha && node support/specsplit.js", | ||
"coverage": "npm run test && nyc report --reporter html", | ||
@@ -28,2 +28,6 @@ "report-coveralls": "nyc report --reporter=text-lcov | coveralls", | ||
"gh-demo": "npm run demo && gh-pages -d demo -f -b master -r git@github.com:markdown-it/markdown-it.github.io.git", | ||
"browserify": "rollup -c support/rollup.config.js", | ||
"benchmark-deps": "npm install --prefix benchmark/extra/ -g marked@0.3.6 commonmark@0.26.0 markdown-it/markdown-it.git#2.2.1", | ||
"specsplit": "support/specsplit.js good -o test/fixtures/commonmark/good.txt && support/specsplit.js bad -o test/fixtures/commonmark/bad.txt && support/specsplit.js", | ||
"todo": "grep 'TODO' -n -r ./lib 2>/dev/null", | ||
"prepublishOnly": "npm run gh-demo && npm run gh-doc" | ||
@@ -38,3 +42,3 @@ }, | ||
"dependencies": { | ||
"argparse": "^1.0.7", | ||
"argparse": "^2.0.1", | ||
"entities": "~2.0.0", | ||
@@ -46,6 +50,8 @@ "linkify-it": "^3.0.1", | ||
"devDependencies": { | ||
"@rollup/plugin-commonjs": "^15.1.0", | ||
"@rollup/plugin-json": "^4.1.0", | ||
"@rollup/plugin-node-resolve": "^9.0.0", | ||
"ansi": "^0.3.0", | ||
"autoprefixer-stylus": "^1.0.0", | ||
"benchmark": "~2.1.0", | ||
"browserify": "^16.3.0", | ||
"chai": "^4.2.0", | ||
@@ -72,6 +78,8 @@ "coveralls": "^3.0.4", | ||
"pug-cli": "^1.0.0-alpha6", | ||
"rollup": "^2.29.0", | ||
"rollup-plugin-node-polyfills": "^0.2.1", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"shelljs": "^0.8.4", | ||
"stylus": "^0.54.5", | ||
"supertest": "^4.0.2", | ||
"terser": "^4.1.2" | ||
"supertest": "^5.0.0" | ||
}, | ||
@@ -78,0 +86,0 @@ "mocha": { |
@@ -32,3 +32,3 @@ # markdown-it | ||
- [Benchmark](#benchmark) | ||
- [Support markdown-it](#support-markdown-it) | ||
- [markdown-it for enterprise](#markdown-it-for-enterprise) | ||
- [Authors](#authors) | ||
@@ -39,7 +39,6 @@ - [References / Thanks](#references--thanks) | ||
**node.js** & **bower**: | ||
**node.js**: | ||
```bash | ||
npm install markdown-it --save | ||
bower install markdown-it --save | ||
``` | ||
@@ -46,0 +45,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
13611
1
2
565222
33
308
+ Addedargparse@2.0.1(transitive)
- Removedargparse@1.0.10(transitive)
- Removedsprintf-js@1.0.3(transitive)
Updatedargparse@^2.0.1