tarsec 0.3.0 → 0.3.1
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.
|
@@ -3,20 +3,22 @@ export * from "./inline.js";
|
|
|
3
3
|
export * from "./blocks.js";
|
|
4
4
|
export * from "./references.js";
|
|
5
5
|
export * from "./frontmatter.js";
|
|
6
|
-
import { seq,
|
|
6
|
+
import { seq, or, optional, many, capture, seqC, map } from "../../combinators.js";
|
|
7
7
|
import { spaces, newline } from "../../parsers.js";
|
|
8
8
|
import { headingParser, codeBlockParser, blockQuoteParser, paragraphParser, imageParser, horizontalRuleParser, setextHeadingParser, indentedCodeBlockParser, listParser, tableParser, htmlBlockParser, } from "./blocks.js";
|
|
9
9
|
import { linkDefinitionParser, footnoteDefinitionParser, resolveReferences, } from "./references.js";
|
|
10
10
|
import { frontmatterParser } from "./frontmatter.js";
|
|
11
|
-
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
|
|
11
|
+
const blockAlt = or(setextHeadingParser, horizontalRuleParser, headingParser, codeBlockParser, indentedCodeBlockParser, tableParser, blockQuoteParser, listParser, htmlBlockParser, linkDefinitionParser, footnoteDefinitionParser, paragraphParser, imageParser);
|
|
12
|
+
// A block followed by zero-or-more trailing newlines. Blocks differ in whether
|
|
13
|
+
// they consume their own terminating "\n" (e.g. headingParser does, codeBlock
|
|
14
|
+
// doesn't), so we can't use sepBy(many1(newline), block) — it would fail to
|
|
15
|
+
// separate two blocks when the first already ate its newline (e.g. a heading
|
|
16
|
+
// directly followed by a list with no intervening blank line).
|
|
17
|
+
const blockEntry = map(seqC(capture(blockAlt, "b"), many(newline)), ({ b }) => b);
|
|
16
18
|
const _markdownParser = seq([
|
|
17
19
|
optional(frontmatterParser),
|
|
18
20
|
optional(spaces),
|
|
19
|
-
|
|
21
|
+
many(blockEntry),
|
|
20
22
|
optional(spaces),
|
|
21
23
|
], (r) => {
|
|
22
24
|
const fm = r[0];
|