scholarly-parse 0.2.0 → 0.2.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.
Files changed (94) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +3 -3
  3. package/changelog/0.2.x/0.2.1.md +45 -0
  4. package/dist/formats/html/metadata.d.ts +0 -8
  5. package/dist/formats/html/metadata.d.ts.map +1 -1
  6. package/dist/formats/html/metadata.js +18 -7
  7. package/dist/formats/html/metadata.js.map +1 -1
  8. package/dist/formats/html/references.d.ts.map +1 -1
  9. package/dist/formats/html/references.js +4 -18
  10. package/dist/formats/html/references.js.map +1 -1
  11. package/dist/formats/jats/blocks.d.ts.map +1 -1
  12. package/dist/formats/jats/blocks.js +57 -28
  13. package/dist/formats/jats/blocks.js.map +1 -1
  14. package/dist/formats/jats/fragment.d.ts +8 -2
  15. package/dist/formats/jats/fragment.d.ts.map +1 -1
  16. package/dist/formats/jats/fragment.js +187 -7
  17. package/dist/formats/jats/fragment.js.map +1 -1
  18. package/dist/formats/jats/front.d.ts +0 -5
  19. package/dist/formats/jats/front.d.ts.map +1 -1
  20. package/dist/formats/jats/front.js +49 -34
  21. package/dist/formats/jats/front.js.map +1 -1
  22. package/dist/formats/jats/inline.d.ts +3 -3
  23. package/dist/formats/jats/inline.d.ts.map +1 -1
  24. package/dist/formats/jats/inline.js +96 -40
  25. package/dist/formats/jats/inline.js.map +1 -1
  26. package/dist/formats/jats/parse.js +33 -5
  27. package/dist/formats/jats/parse.js.map +1 -1
  28. package/dist/formats/jats/references.d.ts +0 -5
  29. package/dist/formats/jats/references.d.ts.map +1 -1
  30. package/dist/formats/jats/references.js +153 -47
  31. package/dist/formats/jats/references.js.map +1 -1
  32. package/dist/formats/jats/text.d.ts +16 -0
  33. package/dist/formats/jats/text.d.ts.map +1 -1
  34. package/dist/formats/jats/text.js +77 -1
  35. package/dist/formats/jats/text.js.map +1 -1
  36. package/dist/formats/latexml/parse.d.ts +7 -1
  37. package/dist/formats/latexml/parse.d.ts.map +1 -1
  38. package/dist/formats/latexml/parse.js +42 -14
  39. package/dist/formats/latexml/parse.js.map +1 -1
  40. package/dist/formats/pdf/references.d.ts +0 -6
  41. package/dist/formats/pdf/references.d.ts.map +1 -1
  42. package/dist/formats/pdf/references.js +8 -2
  43. package/dist/formats/pdf/references.js.map +1 -1
  44. package/dist/formats/tei/parse.d.ts.map +1 -1
  45. package/dist/formats/tei/parse.js +39 -27
  46. package/dist/formats/tei/parse.js.map +1 -1
  47. package/dist/model/arxiv.d.ts +51 -0
  48. package/dist/model/arxiv.d.ts.map +1 -0
  49. package/dist/model/arxiv.js +167 -0
  50. package/dist/model/arxiv.js.map +1 -0
  51. package/dist/model/document.d.ts +17 -4
  52. package/dist/model/document.d.ts.map +1 -1
  53. package/dist/model/identifiers.d.ts +32 -0
  54. package/dist/model/identifiers.d.ts.map +1 -0
  55. package/dist/model/identifiers.js +61 -0
  56. package/dist/model/identifiers.js.map +1 -0
  57. package/dist/parse.d.ts +4 -1
  58. package/dist/parse.d.ts.map +1 -1
  59. package/dist/parse.js.map +1 -1
  60. package/dist/render/bare-url.d.ts +29 -0
  61. package/dist/render/bare-url.d.ts.map +1 -0
  62. package/dist/render/bare-url.js +207 -0
  63. package/dist/render/bare-url.js.map +1 -0
  64. package/dist/render/escape.d.ts +55 -9
  65. package/dist/render/escape.d.ts.map +1 -1
  66. package/dist/render/escape.js +217 -16
  67. package/dist/render/escape.js.map +1 -1
  68. package/dist/render/inline.d.ts +38 -55
  69. package/dist/render/inline.d.ts.map +1 -1
  70. package/dist/render/inline.js +682 -150
  71. package/dist/render/inline.js.map +1 -1
  72. package/dist/render/markdown.d.ts.map +1 -1
  73. package/dist/render/markdown.js +18 -6
  74. package/dist/render/markdown.js.map +1 -1
  75. package/dist/render/read-inline.d.ts +70 -0
  76. package/dist/render/read-inline.d.ts.map +1 -0
  77. package/dist/render/read-inline.js +376 -0
  78. package/dist/render/read-inline.js.map +1 -0
  79. package/dist/render/scan.d.ts +54 -0
  80. package/dist/render/scan.d.ts.map +1 -0
  81. package/dist/render/scan.js +145 -0
  82. package/dist/render/scan.js.map +1 -0
  83. package/dist/render/text.d.ts +3 -9
  84. package/dist/render/text.d.ts.map +1 -1
  85. package/dist/render/text.js +5 -160
  86. package/dist/render/text.js.map +1 -1
  87. package/dist/xml/ordered.d.ts.map +1 -1
  88. package/dist/xml/ordered.js +110 -14
  89. package/dist/xml/ordered.js.map +1 -1
  90. package/dist/xml/well-formed.d.ts +11 -3
  91. package/dist/xml/well-formed.d.ts.map +1 -1
  92. package/dist/xml/well-formed.js +25 -7
  93. package/dist/xml/well-formed.js.map +1 -1
  94. package/package.json +12 -8
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bare-url.js","sourceRoot":"","sources":["../../src/render/bare-url.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,0HAA0H;AAC1H,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAEpF,yFAAyF;AACzF,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAEtD,qDAAqD;AACrD,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAEtF,MAAM,QAAQ,GAAG,eAAe,CAAC;AACjC,MAAM,GAAG,GAAG,SAAS,CAAC;AACtB,MAAM,WAAW,GAAG,YAAY,CAAC;AACjC,MAAM,KAAK,GAAG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), `~` (GFM strikethrough) — always.
15
- * - `_` — only where it could delimit emphasis, so `snake_case` and `H_2` stay readable.
15
+ * - `_` — every one in a run that could delimit emphasis; a run with a letter or digit on
16
+ * both sides never can, so `snake_case`, `H_2`, and `foo__bar` stay readable.
16
17
  * - `](` — the sequence that would turn bracketed text into a link.
17
18
  * - `<` — only before a letter, `/`, `!`, or `?`, where it could open an HTML tag.
18
19
  * - `&` — only where it would read as an entity reference.
20
+ * - A bare URL GFM would link (`https://…`, `www.…`) that holds or meets one of those
21
+ * escapes becomes an explicit link to the URL as the source has it, and text that only
22
+ * the escapes would make a URL links nothing ({@link bareUrlReader}).
19
23
  *
20
24
  * Readers join the escaped text of adjacent elements, so the text's end is closed as if
21
25
  * anything could follow it, as the `_` rule already does: a trailing `\` is doubled, and
22
26
  * a trailing `<`, `!` (an image's opener), or `&` with a partial entity name is escaped.
23
- * A `](` split across two pieces is left to `joinInlineSeams`.
27
+ * A `](` split across two pieces, and markup another piece writes after a bare URL, are
28
+ * left to `joinInlineSeams`.
24
29
  *
25
30
  * Soft hyphens are dropped: they only mark where a word may break.
26
31
  */
27
32
  export declare function escapeInline(text: string): string;
33
+ /**
34
+ * {@link escapeInline} without its bare-URL rule, for link text: GFM links no bare URL
35
+ * there, and an explicit link would nest inside the outer one.
36
+ */
37
+ export declare function escapeText(text: string): string;
38
+ /** A bare URL in Markdown and how to write it: what ends there is the same text. */
39
+ export interface BareUrl {
40
+ end: number;
41
+ written: string;
42
+ }
43
+ /**
44
+ * A reader of the bare URLs GFM links in `markdown`: given where one may start, whether it
45
+ * does, where it ends, and how to write it. One that holds a backslash escape or markup
46
+ * this package writes (an emphasis marker, a math or code delimiter, or the `[` of a link,
47
+ * at one of `linkOpeners`) is written as an explicit link to the URL GFM would link in the
48
+ * text as the source has it — its escapes undone, up to the first marker — and ends there:
49
+ * an autolink, or for a `www.` URL a link that keeps its text. Any other bare URL is
50
+ * written as it is, to the end GFM gives it. Asked in ascending order, it reads each
51
+ * stretch of the text a bounded number of times.
52
+ */
53
+ export declare function bareUrlReader(markdown: string, linkOpeners?: ReadonlySet<number>): (start: number) => BareUrl | undefined;
54
+ /** True when an odd run of backslashes ends right before `at`: the last one escapes what follows. */
55
+ export declare function oddBackslashesBefore(markdown: string, at: number): boolean;
28
56
  /**
29
57
  * Escape a character sequence that would change meaning at the start of a block:
30
- * an ATX heading, a quote, a list marker, a thematic break, a table row, or a link
31
- * reference definition.
58
+ * an ATX heading, a quote, a list marker (alone on the line too, where it would open an
59
+ * empty item), a tilde code fence, a thematic break, a table row, or a link
60
+ * reference definition, whose label holds no unescaped bracket (a `[` before a link's
61
+ * text that holds `]:` opens no definition, and escaping it would break the link).
32
62
  */
33
63
  export declare function escapeBlockStart(text: string): string;
34
64
  /**
35
65
  * Keep TeX from reading as markup where a Markdown renderer without math support treats
36
- * `$…$` as ordinary text: a `<` that could open an HTML tag and a `](` that could open a
37
- * link get a space between them, which math mode ignores.
66
+ * it as ordinary text: a `<` that could open an HTML tag and a `](` that could open a link
67
+ * get a space between them, which math mode ignores, and a backtick, which could open a
68
+ * code span, is written `\grave{}` (the accent command `` \` `` as `\grave`), which both
69
+ * KaTeX and MathJax list. For TeX between `$…$` (`inline`), what would end the delimiters
70
+ * early is closed too: a `$` is escaped, and a trailing backslash, which would escape the
71
+ * closing `$`, becomes a control space. Every backslash run is read once.
38
72
  */
39
- export declare function escapeTex(tex: string): string;
73
+ export declare function escapeTex(tex: string, { inline }?: {
74
+ inline?: boolean;
75
+ }): string;
40
76
  /** Escape a value for a GFM table cell: pipes and line breaks would break the row. */
41
77
  export declare function escapeTableCell(text: string): string;
42
78
  /**
@@ -51,8 +87,18 @@ export declare function codeSpan(text: string): string;
51
87
  /** True when `url` is safe to emit as a Markdown link target. */
52
88
  export declare function isSafeUrl(url: string): boolean;
53
89
  /**
54
- * Escape a URL for use as a Markdown link destination: whitespace, angle brackets, and
55
- * parentheses (an unbalanced one ends the destination) are percent-encoded.
90
+ * Escape a URL for use as an autolink's target, `<…>`: whitespace, control characters,
91
+ * and angle brackets, which an autolink cannot hold, are percent-encoded. Parentheses are
92
+ * left as written.
93
+ */
94
+ export declare function escapeAutolink(url: string): string;
95
+ /**
96
+ * Escape a URL for use as a Markdown link destination, so the destination holds the URL as
97
+ * written: whitespace, angle brackets, parentheses (an unbalanced one ends the destination),
98
+ * and backticks (one could open a code span across the link) are percent-encoded; a
99
+ * backslash before punctuation or at the end, an `&` that would read as a character
100
+ * reference, and a `$` (which the readers of inline math would pair with another) are
101
+ * escaped.
56
102
  */
57
103
  export declare function escapeUrl(url: string): string;
58
104
  //# sourceMappingURL=escape.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"escape.d.ts","sourceRoot":"","sources":["../../src/render/escape.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAOH;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAWjD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQrD;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,sFAAsF;AACtF,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED,oFAAoF;AACpF,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,SAAI,GAAG,MAAM,CAG3D;AAED,6EAA6E;AAC7E,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAI7C;AAKD,iEAAiE;AACjE,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE9C;AAKD;;;GAGG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C"}
1
+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,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE9C;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAElD;AAKD;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAO7C"}
@@ -9,57 +9,241 @@
9
9
  * @module src/render/escape
10
10
  */
11
11
  import { largest } from '../model/extremes.js';
12
+ import { bareUrlEnd, bareUrlStarts } from './bare-url.js';
13
+ import { ESCAPABLE } from './scan.js';
12
14
  /** ASCII punctuation CommonMark allows a backslash to escape. */
13
15
  const ESCAPABLE_AFTER_BACKSLASH = /\\(?=[!-/:-@[-`{-~])/g;
16
+ /** A letter or digit ending the text before an underscore run. */
17
+ const ENDS_IN_LETTER_OR_DIGIT = /[\p{L}\p{N}]$/u;
18
+ /** A letter or digit starting the text after an underscore run. */
19
+ const STARTS_WITH_LETTER_OR_DIGIT = /^[\p{L}\p{N}]/u;
14
20
  /**
15
21
  * Escape source text for use inside inline Markdown.
16
22
  *
17
23
  * - `\` before punctuation, `*`, `` ` ``, `$` (math delimiter), `~` (GFM strikethrough) — always.
18
- * - `_` — only where it could delimit emphasis, so `snake_case` and `H_2` stay readable.
24
+ * - `_` — every one in a run that could delimit emphasis; a run with a letter or digit on
25
+ * both sides never can, so `snake_case`, `H_2`, and `foo__bar` stay readable.
19
26
  * - `](` — the sequence that would turn bracketed text into a link.
20
27
  * - `<` — only before a letter, `/`, `!`, or `?`, where it could open an HTML tag.
21
28
  * - `&` — only where it would read as an entity reference.
29
+ * - A bare URL GFM would link (`https://…`, `www.…`) that holds or meets one of those
30
+ * escapes becomes an explicit link to the URL as the source has it, and text that only
31
+ * the escapes would make a URL links nothing ({@link bareUrlReader}).
22
32
  *
23
33
  * Readers join the escaped text of adjacent elements, so the text's end is closed as if
24
34
  * anything could follow it, as the `_` rule already does: a trailing `\` is doubled, and
25
35
  * a trailing `<`, `!` (an image's opener), or `&` with a partial entity name is escaped.
26
- * A `](` split across two pieces is left to `joinInlineSeams`.
36
+ * A `](` split across two pieces, and markup another piece writes after a bare URL, are
37
+ * left to `joinInlineSeams`.
27
38
  *
28
39
  * Soft hyphens are dropped: they only mark where a word may break.
29
40
  */
30
41
  export function escapeInline(text) {
42
+ return writeBareUrls(escapeText(text));
43
+ }
44
+ /**
45
+ * {@link escapeInline} without its bare-URL rule, for link text: GFM links no bare URL
46
+ * there, and an explicit link would nest inside the outer one.
47
+ */
48
+ export function escapeText(text) {
31
49
  return text
32
50
  .replace(/\u00AD/g, '')
33
51
  .replace(ESCAPABLE_AFTER_BACKSLASH, '\\\\')
34
52
  .replace(/\\$/, '\\\\')
35
53
  .replace(/[*`$~]/g, '\\$&')
36
- .replace(/(^|[^\p{L}\p{N}])_|_(?=$|[^\p{L}\p{N}])/gu, (match) => match.replace('_', '\\_'))
54
+ .replace(/_+/g, (run, at, whole) => ENDS_IN_LETTER_OR_DIGIT.test(whole.slice(Math.max(0, at - 2), at)) &&
55
+ STARTS_WITH_LETTER_OR_DIGIT.test(whole.slice(at + run.length, at + run.length + 2))
56
+ ? run
57
+ : run.replace(/_/g, '\\_'))
37
58
  .replace(/\]\(/g, '\\](')
38
59
  .replace(/<(?=[A-Za-z/!?]|$)/g, '\\<')
39
60
  .replace(/!$/, '\\!')
40
61
  .replace(/&(?=#?[A-Za-z0-9]+;|#?[A-Za-z0-9]*$)/g, '\\&');
41
62
  }
63
+ /** Where a bare URL can start. */
64
+ const BARE_URL_START = /https?:\/\/|www\./gi;
65
+ /** Escaped text with each bare URL in it written as {@link bareUrlReader} writes it, in one pass. */
66
+ function writeBareUrls(markdown) {
67
+ const bareUrlAt = bareUrlReader(markdown);
68
+ let out = '';
69
+ let at = 0;
70
+ const start = new RegExp(BARE_URL_START);
71
+ for (let found = start.exec(markdown); found; found = start.exec(markdown)) {
72
+ const url = bareUrlAt(found.index);
73
+ if (!url)
74
+ continue;
75
+ out += markdown.slice(at, found.index) + url.written;
76
+ at = start.lastIndex = url.end;
77
+ }
78
+ return out + markdown.slice(at);
79
+ }
80
+ /** Markup this package writes that GFM reads as part of a bare URL it touches. */
81
+ const MARKUP = new Set(['*', '~', '$', '`']);
82
+ const SPACE = /^\s$/;
83
+ /**
84
+ * A reader of the bare URLs GFM links in `markdown`: given where one may start, whether it
85
+ * does, where it ends, and how to write it. One that holds a backslash escape or markup
86
+ * this package writes (an emphasis marker, a math or code delimiter, or the `[` of a link,
87
+ * at one of `linkOpeners`) is written as an explicit link to the URL GFM would link in the
88
+ * text as the source has it — its escapes undone, up to the first marker — and ends there:
89
+ * an autolink, or for a `www.` URL a link that keeps its text. Any other bare URL is
90
+ * written as it is, to the end GFM gives it. Asked in ascending order, it reads each
91
+ * stretch of the text a bounded number of times.
92
+ */
93
+ export function bareUrlReader(markdown, linkOpeners = new Set()) {
94
+ /** The stretch last searched for markup: from where, and the markup, space, or `<` that ends it. */
95
+ let searchedFrom = -1;
96
+ let markupAt = -1;
97
+ const firstMarkup = (start) => {
98
+ if (start < searchedFrom || start > markupAt) {
99
+ searchedFrom = markupAt = start;
100
+ for (let c = markdown.charAt(markupAt); c && c !== '<' && !SPACE.test(c);) {
101
+ if (MARKUP.has(c) || linkOpeners.has(markupAt))
102
+ break;
103
+ if (c === '\\' && ESCAPABLE.test(markdown.charAt(markupAt + 1)))
104
+ break;
105
+ c = markdown.charAt(++markupAt);
106
+ }
107
+ }
108
+ return markupAt;
109
+ };
110
+ /**
111
+ * The stretch last read as the source has it, and where each of its characters starts in
112
+ * `markdown`. A URL starting later in the same stretch reads the rest of it, so the
113
+ * stretch is read once.
114
+ */
115
+ let stretch;
116
+ const sourceFrom = (start) => {
117
+ let offset = stretch?.at.get(start);
118
+ if (!stretch || offset === undefined) {
119
+ const { from, source } = sourceUrl(markdown, start, linkOpeners);
120
+ stretch = { at: new Map(from.map((position, index) => [position, index])), from, source };
121
+ offset = 0;
122
+ }
123
+ return { offset, ...stretch };
124
+ };
125
+ return (start) => {
126
+ if (!bareUrlStarts(markdown, start))
127
+ return;
128
+ const limit = firstMarkup(start);
129
+ const end = bareUrlEnd(markdown, start, limit);
130
+ if (end === -1)
131
+ return;
132
+ if (end <= limit)
133
+ return { end, written: markdown.slice(start, end) };
134
+ const { from, offset, source } = sourceFrom(start);
135
+ const urlEnd = bareUrlEnd(source, offset);
136
+ if (urlEnd === -1)
137
+ return unlinked(markdown, start);
138
+ const url = source.slice(offset, urlEnd);
139
+ // GFM links a `www.` URL whose dot it gives back as `www` alone.
140
+ const written = /^https?:/i.test(url)
141
+ ? `<${escapeAutolink(url)}>`
142
+ : `[${wwwLinkText(url)}](http://${escapeUrl(url)})`;
143
+ return {
144
+ end: from[urlEnd] ?? start,
145
+ // A backslash the text has before the link would escape its `<`.
146
+ written: oddBackslashesBefore(markdown, start) ? `\\${written}` : written,
147
+ };
148
+ };
149
+ }
150
+ /**
151
+ * A bare URL that only the escapes make one (a `_` escaped in the domain's last two
152
+ * segments, where GFM accepts none) written with its scheme's `:` or its `www.` dot
153
+ * escaped, so GFM links nothing there, and ending past that character.
154
+ */
155
+ function unlinked(markdown, start) {
156
+ const at = markdown.indexOf(/^www\./i.test(markdown.slice(start, start + 4)) ? '.' : ':', start);
157
+ return { end: at + 1, written: `${markdown.slice(start, at)}\\${markdown.charAt(at)}` };
158
+ }
159
+ /** True when an odd run of backslashes ends right before `at`: the last one escapes what follows. */
160
+ export function oddBackslashesBefore(markdown, at) {
161
+ return countBackslashesBefore(markdown, at) % 2 === 1;
162
+ }
163
+ /**
164
+ * The text of the bare URL at `start` as the source has it: escapes undone, up to a
165
+ * marker, a link's `[` (one of `linkOpeners`), a space, an angle bracket (which an
166
+ * autolink cannot hold as written), or a `](` or `][` (where the URL ends whatever
167
+ * follows), with where in `markdown` each character came from, and where the text stops
168
+ * last.
169
+ */
170
+ function sourceUrl(markdown, start, linkOpeners) {
171
+ let source = '';
172
+ const from = [];
173
+ let at = start;
174
+ for (;;) {
175
+ const escaped = markdown.charAt(at) === '\\' && ESCAPABLE.test(markdown.charAt(at + 1));
176
+ const next = at + (escaped ? 1 : 0);
177
+ const char = markdown.charAt(next);
178
+ const after = markdown.charAt(next + 1);
179
+ if (!char || char === '<' || char === '>' || SPACE.test(char))
180
+ break;
181
+ if (!escaped && (MARKUP.has(char) || linkOpeners.has(next)))
182
+ break;
183
+ if (char === ']' && (after === '(' || after === '['))
184
+ break;
185
+ from.push(at);
186
+ source += char;
187
+ at = next + 1;
188
+ }
189
+ from.push(at);
190
+ return { from, source };
191
+ }
192
+ /** A `www.` URL escaped as link text, every bracket escaped so the link's own enclose it. */
193
+ function wwwLinkText(url) {
194
+ return escapeText(url).replace(/\\[\s\S]|[[\]]/g, (m) => (m.length === 2 ? m : `\\${m}`));
195
+ }
42
196
  /**
43
197
  * Escape a character sequence that would change meaning at the start of a block:
44
- * an ATX heading, a quote, a list marker, a thematic break, a table row, or a link
45
- * reference definition.
198
+ * an ATX heading, a quote, a list marker (alone on the line too, where it would open an
199
+ * empty item), a tilde code fence, a thematic break, a table row, or a link
200
+ * reference definition, whose label holds no unescaped bracket (a `[` before a link's
201
+ * text that holds `]:` opens no definition, and escaping it would break the link).
46
202
  */
47
203
  export function escapeBlockStart(text) {
48
204
  return text
49
205
  .replace(/^(#{1,6})(?=\s|$)/, '\\$1')
50
- .replace(/^([>|])/, '\\$1')
51
- .replace(/^([-+])(?=\s)/, '\\$1')
52
- .replace(/^(\d{1,9})([.)])(?=\s)/, '$1\\$2')
206
+ .replace(/^([>|]|~(?=~~))/, '\\$1')
207
+ .replace(/^([-+*])(?=\s|$)/, '\\$1')
208
+ .replace(/^(\d{1,9})([.)])(?=\s|$)/, '$1\\$2')
53
209
  .replace(/^(=+|-{3,})\s*$/, '\\$1')
54
- .replace(/^\[(?=[^\]]*\]:)/, '\\[');
210
+ .replace(/^\[(?=(?:\\[\s\S]|[^\\[\]])*\]:)/, '\\[');
55
211
  }
56
212
  /**
57
213
  * Keep TeX from reading as markup where a Markdown renderer without math support treats
58
- * `$…$` as ordinary text: a `<` that could open an HTML tag and a `](` that could open a
59
- * link get a space between them, which math mode ignores.
214
+ * it as ordinary text: a `<` that could open an HTML tag and a `](` that could open a link
215
+ * get a space between them, which math mode ignores, and a backtick, which could open a
216
+ * code span, is written `\grave{}` (the accent command `` \` `` as `\grave`), which both
217
+ * KaTeX and MathJax list. For TeX between `$…$` (`inline`), what would end the delimiters
218
+ * early is closed too: a `$` is escaped, and a trailing backslash, which would escape the
219
+ * closing `$`, becomes a control space. Every backslash run is read once.
60
220
  */
61
- export function escapeTex(tex) {
62
- return tex.replace(/<(?=[A-Za-z/!?])/g, '< ').replace(/\]\(/g, '] (');
221
+ export function escapeTex(tex, { inline = false } = {}) {
222
+ const escaped = tex
223
+ .replace(/\\+|[`$]/g, (match, at, whole) => {
224
+ if (match.startsWith('\\')) {
225
+ // An odd run escapes the character after it: `` \` `` is the grave accent.
226
+ return match.length % 2 === 1 && whole.charAt(at + match.length) === '`'
227
+ ? `${match.slice(0, -1)}\\grave `
228
+ : match;
229
+ }
230
+ const escapedBefore = countBackslashesBefore(whole, at) % 2 === 1;
231
+ if (match === '`')
232
+ return escapedBefore ? '' : '\\grave{}';
233
+ return inline && !escapedBefore ? `\\${match}` : match;
234
+ })
235
+ .replace(/<(?=[A-Za-z/!?])/g, '< ')
236
+ .replace(/\]\(/g, '] (');
237
+ return inline && countBackslashesBefore(escaped, escaped.length) % 2 === 1
238
+ ? `${escaped} `
239
+ : escaped;
240
+ }
241
+ /** How many backslashes come right before `at`. */
242
+ function countBackslashesBefore(text, at) {
243
+ let backslashes = 0;
244
+ while (text.charAt(at - 1 - backslashes) === '\\')
245
+ backslashes++;
246
+ return backslashes;
63
247
  }
64
248
  /** Escape a value for a GFM table cell: pipes and line breaks would break the row. */
65
249
  export function escapeTableCell(text) {
@@ -89,13 +273,30 @@ const SAFE_URL = /^(?:https?|ftp|mailto):/i;
89
273
  export function isSafeUrl(url) {
90
274
  return SAFE_URL.test(url.trim());
91
275
  }
276
+ /**
277
+ * Escape a URL for use as an autolink's target, `<…>`: whitespace, control characters,
278
+ * and angle brackets, which an autolink cannot hold, are percent-encoded. Parentheses are
279
+ * left as written.
280
+ */
281
+ export function escapeAutolink(url) {
282
+ return url.trim().replace(/[\p{Cc}\s<>]/gu, encodeURIComponent);
283
+ }
92
284
  /** Parentheses, which `encodeURIComponent` leaves as they are. */
93
285
  const PARENTHESES = { '(': '%28', ')': '%29' };
94
286
  /**
95
- * Escape a URL for use as a Markdown link destination: whitespace, angle brackets, and
96
- * parentheses (an unbalanced one ends the destination) are percent-encoded.
287
+ * Escape a URL for use as a Markdown link destination, so the destination holds the URL as
288
+ * written: whitespace, angle brackets, parentheses (an unbalanced one ends the destination),
289
+ * and backticks (one could open a code span across the link) are percent-encoded; a
290
+ * backslash before punctuation or at the end, an `&` that would read as a character
291
+ * reference, and a `$` (which the readers of inline math would pair with another) are
292
+ * escaped.
97
293
  */
98
294
  export function escapeUrl(url) {
99
- return url.trim().replace(/[\s()<>]/g, (c) => PARENTHESES[c] ?? encodeURIComponent(c));
295
+ return url
296
+ .trim()
297
+ .replace(/[\s()<>`]/g, (c) => PARENTHESES[c] ?? encodeURIComponent(c))
298
+ .replace(/\\(?=[!-/:-@[-`{-~]|$)/g, '\\\\')
299
+ .replace(/&(?=#?[A-Za-z0-9]+;)/g, '\\&')
300
+ .replace(/\$/g, '\\$');
100
301
  }
101
302
  //# sourceMappingURL=escape.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"escape.js","sourceRoot":"","sources":["../../src/render/escape.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,iEAAiE;AACjE,MAAM,yBAAyB,GAAG,uBAAuB,CAAC;AAE1D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,OAAO,IAAI;SACR,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC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O,CAAC,yBAAyB,EAAE,MAAM,CAAC;SAC1C,OAAO,CAAC,uBAAuB,EAAE,KAAK,CAAC;SACvC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAC3B,CAAC"}
@@ -1,26 +1,32 @@
1
1
  /**
2
2
  * Wrap already-rendered Markdown in an emphasis marker (`*`, `**`, `~~`). Whitespace at
3
3
  * the edges moves outside the markers, where CommonMark requires it, and empty content
4
- * renders as itself. The edges are found by trimming, which reads each end once.
4
+ * renders as itself. The edges are found by trimming, which reads each end once; a
5
+ * backslash the trim leaves at the end is escaped, so it does not escape the closer. A
6
+ * marker between punctuation inside and a word outside cannot open or close;
7
+ * `joinInlineSeams` repairs that once the text beside it is known.
5
8
  */
6
9
  export declare function emphasis(markdown: string, marker: string): string;
7
10
  /**
8
11
  * A superscript. Citation numbers become a bracketed marker (`[12,13]`), so they do not
9
12
  * fuse with the word before them; anything else uses TeX-style notation (`10^{-5}`,
10
13
  * `x^2`) that stays readable as plain text. A marker's text is escaped like any source
11
- * text.
14
+ * text, a backslash the trim leaves at the end is escaped, so it escapes nothing after the
15
+ * script, and a bare URL that ends a group is written as a link ({@link scriptGroup}).
12
16
  *
13
17
  * `isCitation` is the parser's judgment that the superscript holds only citation links;
14
18
  * an unlinked run of several citation numbers is recognized from its text.
15
19
  */
16
20
  export declare function superscript(markdown: string, plain: string, isCitation: boolean): string;
17
- /** A subscript in TeX-style notation: `CO_2`, `IC_{50}`. */
21
+ /** A subscript in TeX-style notation: `CO_2`, `IC_{50}`, a group as {@link superscript} writes one. */
18
22
  export declare function subscript(markdown: string, plain: string): string;
19
23
  /**
20
24
  * A link. An unsafe scheme (`javascript:`, `data:`) renders as its text only, or as the
21
- * target as escaped text when there is none; a link whose text is its own URL renders as
22
- * an autolink. A bracket in the text with no partner is escaped, so the link's own
23
- * brackets enclose the whole text.
25
+ * target as escaped text when there is none; a link whose text is its own URL, as written
26
+ * or as `escapeInline` writes it, renders as an autolink. A bracket in the text with no
27
+ * partner, or in a pair a `(` follows, is escaped, and so is a backslash the trim leaves at
28
+ * its end, so the link's own brackets enclose the whole text; a link the text holds is
29
+ * written as its text: links do not nest.
24
30
  */
25
31
  export declare function link(markdown: string, url: string | undefined): string;
26
32
  /**
@@ -30,23 +36,41 @@ export declare function link(markdown: string, url: string | undefined): string;
30
36
  export declare const FORMULA_IMAGE = "[formula]";
31
37
  /** Inline math: `$tex$`. Empty TeX renders nothing. */
32
38
  export declare function inlineMath(tex: string): string;
33
- /** ASCII punctuation, which a backslash escapes. */
34
- export declare const ESCAPABLE: RegExp;
35
39
  /**
36
40
  * Inline Markdown assembled from separately escaped pieces, with the seams between them
37
41
  * repaired: the escaping of each piece cannot see what the next one adds.
38
42
  *
39
43
  * - Touching inline formulas join into one (`$a$$b$` would read as a display-math
40
44
  * delimiter), with a space where the TeX at the joint would open an HTML tag or a link,
41
- * as `escapeTex` writes it. Source text never yields `$$` (its dollar signs are
42
- * escaped), so every `$$` is such a seam.
43
- * - A `](` that `link` did not write, one not followed by a web or mail destination, is
44
- * escaped, so no link forms with any other destination.
45
+ * as `escapeTex` writes it, or where a control word (`\alpha`) would take in the letters
46
+ * after it. Source text never yields `$$` (its dollar signs are escaped), so every `$$`
47
+ * is such a seam.
48
+ * - Touching code spans join into one (`touchingCodeReader`): their fences would meet as
49
+ * one run that closes neither.
50
+ * - A `](` that `link` did not write, one not followed by a web or mail destination as
51
+ * `escapeUrl` writes one, is escaped, so no link forms with any other destination, nor
52
+ * one that runs into a code span, autolink, or formula written after it.
53
+ * - A bare URL that an escape, a marker, or a link after it would join is written as an
54
+ * explicit link to the URL as the source has it (`bareUrlReader`), unless it stands inside
55
+ * link text, where GFM links no bare URL.
45
56
  * - A `!` before a link is escaped, so the link does not read as an image.
57
+ * - Two emphasis, strong, or strikethrough spans of one kind that touch, whose markers GFM
58
+ * reads as one run, join into one span ({@link joinTouchingSpans}): `**K****-step**`
59
+ * becomes `**K-step**`.
60
+ * - An emphasis, strong, or strikethrough pair that cannot form because punctuation at
61
+ * the emphasized text's edge meets a word outside the marker is repaired
62
+ * ({@link repairStuckMarkers}): the punctuation moves outside the marker
63
+ * (`*daf-16-*dependent` becomes `*daf-16*-dependent`), or, where that cannot work, the
64
+ * markers are dropped and the text kept.
46
65
  *
47
66
  * Code spans, autolinks, and link destinations are left as written, and a backslash
48
- * escapes only the one character after it, so an escaped backslash escapes nothing. The
49
- * text is read once, plus once more when it holds a `![`.
67
+ * escapes only the one character after it, so an escaped backslash escapes nothing. A
68
+ * joint or a repair can put a character GFM starts a bare URL after before a `www.`
69
+ * (`x*-www.` becomes `x-*www.`), and the backslash before a `](` can meet the bare URL
70
+ * that ends there (`https://a.co/x\](`), so the seams are read again wherever the text
71
+ * changed. The text is read once, plus once more when it holds a `![`, up to four times
72
+ * more when spans touch, up to four times more when a marker stands between punctuation
73
+ * and a word, and once more after any change.
50
74
  */
51
75
  export declare function joinInlineSeams(markdown: string): string;
52
76
  /**
@@ -54,47 +78,6 @@ export declare function joinInlineSeams(markdown: string): string;
54
78
  * between its separately escaped pieces repaired ({@link joinInlineSeams}).
55
79
  */
56
80
  export declare function collapseInline(markdown: string): string;
57
- /**
58
- * Each `[` paired with its `]` as CommonMark pairs them, in one pass: a bracket a
59
- * backslash escapes, or one inside a code span or an autolink, does not count, and nested
60
- * pairs balance on a stack. Inline math gets no special treatment, as in CommonMark,
61
- * unless `skipMath` asks for `$…$` to be read as a span too, as `stripInline` reads it.
62
- * `pairs` maps each paired `[` to its `]`; `unpaired` holds the rest, in ascending order.
63
- */
64
- export declare function pairBrackets(markdown: string, { skipMath }?: {
65
- skipMath?: boolean;
66
- }): {
67
- pairs: Map<number, number>;
68
- unpaired: number[];
69
- };
70
- /**
71
- * The backtick run at `start`, and the code span it opens: `content` is undefined, and
72
- * `end` the end of the run, when no run of its length closes it.
73
- */
74
- export declare function codeSpanAt(markdown: string, start: number, codeSpanEnd: (length: number, from: number) => number | undefined): {
75
- content?: string;
76
- end: number;
77
- };
78
- /**
79
- * A finder of code-span closers for `markdown`: the start of the first run of exactly
80
- * `length` backticks at or after `from`, which a run of that length opening before
81
- * `from` closes. Runs are found once, and the search for each length only moves forward,
82
- * as the text is read.
83
- */
84
- export declare function codeSpanCloser(markdown: string): (length: number, from: number) => number | undefined;
85
- /**
86
- * The first `$` at or after `from` that no odd run of backslashes escapes, counting none
87
- * before `from`, or -1. When there is none, there is none after a later `$` either.
88
- */
89
- export declare function unescapedDollar(markdown: string, from: number): number;
90
- /**
91
- * An autolink at `start`: its target up to the next `>`, which no `<` comes before (a
92
- * written URL has its angle brackets percent-encoded).
93
- */
94
- export declare function autolinkAt(markdown: string, start: number): {
95
- end: number;
96
- target: string;
97
- } | undefined;
98
81
  /** Inline code. */
99
82
  export declare function inlineCode(text: string): string;
100
83
  //# sourceMappingURL=inline.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"inline.d.ts","sourceRoot":"","sources":["../../src/render/inline.ts"],"names":[],"mappings":"AAQA;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAKjE;AAQD;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,GAAG,MAAM,CAOxF;AAED,4DAA4D;AAC5D,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAIjE;AAED;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAMtE;AA2BD;;;GAGG;AACH,eAAO,MAAM,aAAa,cAAc,CAAC;AAEzC,uDAAuD;AACvD,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG9C;AAKD,oDAAoD;AACpD,eAAO,MAAM,SAAS,QAAqB,CAA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