@minamorl/markdown-next 2.2.1 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/src/parser.js +6 -4
  2. package/package.json +12 -12
package/lib/src/parser.js CHANGED
@@ -171,7 +171,7 @@ class Parser {
171
171
  });
172
172
  const inlines = inline.atLeast(1).map(join);
173
173
  const paragraphBegin = inlines;
174
- const paragraphEnd = ignore(/```\n.*\n```/);
174
+ const paragraphEnd = ignore(/```[^`\r\n]*\n[\s\S]*?\n```/);
175
175
  const paragraphLine = P.lazy(() => P.alt(P.seq(paragraphBegin, linebreak.skip(paragraphEnd).result(mapper('br')(null)), paragraphLine).map(join), inlines));
176
176
  const paragraph = paragraphLine.map(mapper('p'));
177
177
  const listIndent = P.string(' ');
@@ -278,9 +278,11 @@ class Parser {
278
278
  const codeBlockBegin = P.regexp(/^```/);
279
279
  const codeBlockEnd = P.regexp(/^```/);
280
280
  const codeBlockDefinitionStr = P.regexp(/[^`\r\n]*/);
281
- const codeBlockStr = P.regexp(/[^\r\n]+/);
282
- const codeBlock = P.seqMap(codeBlockBegin, codeBlockDefinitionStr, linebreak, linebreak.or(codeBlockStr.lookahead(linebreak)).many(), codeBlockEnd, (_1, definition, _2, code, _3) => {
283
- if (code.length > 0) {
281
+ // Match a code line that is NOT a closing fence (``` at start of line)
282
+ const codeBlockStr = P.regexp(/(?!```)[^\r\n]+/);
283
+ const codeBlock = P.seqMap(codeBlockBegin, codeBlockDefinitionStr, linebreak, linebreak.or(codeBlockStr).many(), linebreak.atMost(1), codeBlockEnd, (_1, definition, _2, code, _3, _4) => {
284
+ // Remove trailing linebreak consumed by .many() before the closing fence
285
+ while (code.length > 0 && (code[code.length - 1] === '\n' || code[code.length - 1] === '\r\n' || code[code.length - 1] === '\r' || code[code.length - 1] === '')) {
284
286
  code.pop();
285
287
  }
286
288
  if (definition === '')
package/package.json CHANGED
@@ -3,6 +3,16 @@
3
3
  "description": "Markdown parser with Aozora bunko ruby support and HTML passthrough",
4
4
  "main": "./lib/src/parser.js",
5
5
  "types": "./lib/src/parser.d.ts",
6
+ "scripts": {
7
+ "build": "tsc",
8
+ "example": "cd examples && webpack",
9
+ "prepublish": "pnpm run build",
10
+ "test": "pnpm run build && mocha lib/test",
11
+ "lint": "eslint src test",
12
+ "lint:fix": "eslint src test --fix",
13
+ "format": "prettier --write 'src/**/*.ts' 'test/**/*.ts'",
14
+ "format:check": "prettier --check 'src/**/*.ts' 'test/**/*.ts'"
15
+ },
6
16
  "author": "minamorl",
7
17
  "license": "MIT",
8
18
  "files": [
@@ -36,15 +46,5 @@
36
46
  "url": "https://github.com/minamorl/markdown-next/issues"
37
47
  },
38
48
  "homepage": "https://github.com/minamorl/markdown-next#readme",
39
- "version": "2.2.1",
40
- "scripts": {
41
- "build": "tsc",
42
- "example": "cd examples && webpack",
43
- "prepublish": "pnpm run build",
44
- "test": "pnpm run build && mocha lib/test",
45
- "lint": "eslint src test",
46
- "lint:fix": "eslint src test --fix",
47
- "format": "prettier --write 'src/**/*.ts' 'test/**/*.ts'",
48
- "format:check": "prettier --check 'src/**/*.ts' 'test/**/*.ts'"
49
- }
50
- }
49
+ "version": "2.2.2"
50
+ }