shelving 1.317.0 → 1.317.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.
- package/docs/llms-full.txt +5 -2
- package/docs/markup/AUTOLINK_RULE.md +2 -1
- package/docs/markup/ORDERED_RULE.md +1 -0
- package/docs/markup/UNORDERED_RULE.md +1 -0
- package/docs/markup.md +1 -1
- package/markup/rule/link.d.ts +2 -1
- package/markup/rule/link.js +8 -3
- package/markup/rule/ordered.d.ts +1 -0
- package/markup/rule/ordered.js +12 -4
- package/markup/rule/unordered.d.ts +1 -0
- package/markup/rule/unordered.js +12 -4
- package/package.json +1 -1
package/docs/llms-full.txt
CHANGED
|
@@ -10030,7 +10030,7 @@ If the text reaches you straight from a `StringSchema`-validated field it is alr
|
|
|
10030
10030
|
- [INLINE_RULE](markup/INLINE_RULE.md): Inline strong, emphasis, insert, delete, highlight.
|
|
10031
10031
|
- [LINEBREAK_RULE](markup/LINEBREAK_RULE.md): Hard linebreak (<br /> tag).
|
|
10032
10032
|
- [LINK_RULE](markup/LINK_RULE.md): Markdown-style link.
|
|
10033
|
-
- [AUTOLINK_RULE](markup/AUTOLINK_RULE.md): Autolinked URL starts with scheme: (any scheme in MarkupOptions.schemes) and matches an unlimited number of non-space characters.
|
|
10033
|
+
- [AUTOLINK_RULE](markup/AUTOLINK_RULE.md): Autolinked URL starts with scheme: (any scheme in MarkupOptions.schemes) and matches an unlimited number of non-space characters (except < and >).
|
|
10034
10034
|
- [ORDERED_RULE](markup/ORDERED_RULE.md): Ordered list.
|
|
10035
10035
|
- [PARAGRAPH_RULE](markup/PARAGRAPH_RULE.md): Paragraph.
|
|
10036
10036
|
- [SEPARATOR_RULE](markup/SEPARATOR_RULE.md): Separator (horizontal rule / thematic break).
|
|
@@ -10658,7 +10658,8 @@ new MarkupParser({ rules: [LINK_RULE] }).parse("[Google Maps](http://google.com/
|
|
|
10658
10658
|
- Kind: constant
|
|
10659
10659
|
- Import: `import { AUTOLINK_RULE } from "shelving/markup";`
|
|
10660
10660
|
|
|
10661
|
-
Autolinked URL starts with `scheme:` (any scheme in `MarkupOptions.schemes`) and matches an unlimited number of non-space characters.
|
|
10661
|
+
Autolinked URL starts with `scheme:` (any scheme in `MarkupOptions.schemes`) and matches an unlimited number of non-space characters (except `<` and `>`).
|
|
10662
|
+
- URL can be wrapped in `<>` angle brackets (the standard Markdown autolink syntax), e.g. `<http://google.com/maps>`. The brackets are not part of the link.
|
|
10662
10663
|
- If followed by space and then text in `()` round or `[]` square brackets that will be used as the title, e.g. `http://google.com/maps (Google Maps)` or `http://google.com/maps [Google Maps]` (this syntax is from Todoist and maybe other things too).
|
|
10663
10664
|
- If no title is specified a cleaned up version of the URL will be used, e.g. `google.com/maps`
|
|
10664
10665
|
- If link is not valid (using `new URL(url)` then unparsed text will be returned.
|
|
@@ -10682,6 +10683,7 @@ Ordered list.
|
|
|
10682
10683
|
- Line starting with number, followed by `.`, `)` or `:` character, then one or more space characters.
|
|
10683
10684
|
- No spaces can appear before the number character.
|
|
10684
10685
|
- Second-level list can be created by indenting with `\t` one tab.
|
|
10686
|
+
- Continuation lines can also be indented with spaces to the width of the number and its spaces, e.g. three spaces after `1. `, so a fenced code block can go inside an item.
|
|
10685
10687
|
- List block runs until a blank line that is not followed by another item or an indented continuation line.
|
|
10686
10688
|
- A list with blank lines between its items (or before a continuation paragraph) is "loose": its items are wrapped in `<p>` tags.
|
|
10687
10689
|
- Sparse lists are not supported.
|
|
@@ -10764,6 +10766,7 @@ Unordered list.
|
|
|
10764
10766
|
- Line starting with `-`, `*`, `•`, or `+` character followed by one or more space characters.
|
|
10765
10767
|
- No spaces can appear before the bullet character.
|
|
10766
10768
|
- Second-level list can be created by indenting with `\t` one tab.
|
|
10769
|
+
- Continuation lines can also be indented with spaces to the width of the bullet and its spaces, e.g. two spaces after `- `, so a fenced code block can go inside an item.
|
|
10767
10770
|
- List block runs until a blank line that is not followed by another item or an indented continuation line.
|
|
10768
10771
|
- A list with blank lines between its items (or before a continuation paragraph) is "loose": its items are wrapped in `<p>` tags.
|
|
10769
10772
|
- An item starting with `[ ]` or `[x]` (case-insensitive) is a todo item: a checkbox `<input>` plus the content wrapped in a `<label>` so clicking it toggles the checkbox.
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
- Kind: constant
|
|
4
4
|
- Import: `import { AUTOLINK_RULE } from "shelving/markup";`
|
|
5
5
|
|
|
6
|
-
Autolinked URL starts with `scheme:` (any scheme in `MarkupOptions.schemes`) and matches an unlimited number of non-space characters.
|
|
6
|
+
Autolinked URL starts with `scheme:` (any scheme in `MarkupOptions.schemes`) and matches an unlimited number of non-space characters (except `<` and `>`).
|
|
7
|
+
- URL can be wrapped in `<>` angle brackets (the standard Markdown autolink syntax), e.g. `<http://google.com/maps>`. The brackets are not part of the link.
|
|
7
8
|
- If followed by space and then text in `()` round or `[]` square brackets that will be used as the title, e.g. `http://google.com/maps (Google Maps)` or `http://google.com/maps [Google Maps]` (this syntax is from Todoist and maybe other things too).
|
|
8
9
|
- If no title is specified a cleaned up version of the URL will be used, e.g. `google.com/maps`
|
|
9
10
|
- If link is not valid (using `new URL(url)` then unparsed text will be returned.
|
|
@@ -7,6 +7,7 @@ Ordered list.
|
|
|
7
7
|
- Line starting with number, followed by `.`, `)` or `:` character, then one or more space characters.
|
|
8
8
|
- No spaces can appear before the number character.
|
|
9
9
|
- Second-level list can be created by indenting with `\t` one tab.
|
|
10
|
+
- Continuation lines can also be indented with spaces to the width of the number and its spaces, e.g. three spaces after `1. `, so a fenced code block can go inside an item.
|
|
10
11
|
- List block runs until a blank line that is not followed by another item or an indented continuation line.
|
|
11
12
|
- A list with blank lines between its items (or before a continuation paragraph) is "loose": its items are wrapped in `<p>` tags.
|
|
12
13
|
- Sparse lists are not supported.
|
|
@@ -7,6 +7,7 @@ Unordered list.
|
|
|
7
7
|
- Line starting with `-`, `*`, `•`, or `+` character followed by one or more space characters.
|
|
8
8
|
- No spaces can appear before the bullet character.
|
|
9
9
|
- Second-level list can be created by indenting with `\t` one tab.
|
|
10
|
+
- Continuation lines can also be indented with spaces to the width of the bullet and its spaces, e.g. two spaces after `- `, so a fenced code block can go inside an item.
|
|
10
11
|
- List block runs until a blank line that is not followed by another item or an indented continuation line.
|
|
11
12
|
- A list with blank lines between its items (or before a continuation paragraph) is "loose": its items are wrapped in `<p>` tags.
|
|
12
13
|
- An item starting with `[ ]` or `[x]` (case-insensitive) is a todo item: a checkbox `<input>` plus the content wrapped in a `<label>` so clicking it toggles the checkbox.
|
package/docs/markup.md
CHANGED
|
@@ -168,7 +168,7 @@ If the text reaches you straight from a `StringSchema`-validated field it is alr
|
|
|
168
168
|
- [INLINE_RULE](markup/INLINE_RULE.md): Inline strong, emphasis, insert, delete, highlight.
|
|
169
169
|
- [LINEBREAK_RULE](markup/LINEBREAK_RULE.md): Hard linebreak (<br /> tag).
|
|
170
170
|
- [LINK_RULE](markup/LINK_RULE.md): Markdown-style link.
|
|
171
|
-
- [AUTOLINK_RULE](markup/AUTOLINK_RULE.md): Autolinked URL starts with scheme: (any scheme in MarkupOptions.schemes) and matches an unlimited number of non-space characters.
|
|
171
|
+
- [AUTOLINK_RULE](markup/AUTOLINK_RULE.md): Autolinked URL starts with scheme: (any scheme in MarkupOptions.schemes) and matches an unlimited number of non-space characters (except < and >).
|
|
172
172
|
- [ORDERED_RULE](markup/ORDERED_RULE.md): Ordered list.
|
|
173
173
|
- [PARAGRAPH_RULE](markup/PARAGRAPH_RULE.md): Paragraph.
|
|
174
174
|
- [SEPARATOR_RULE](markup/SEPARATOR_RULE.md): Separator (horizontal rule / thematic break).
|
package/markup/rule/link.d.ts
CHANGED
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
*/
|
|
12
12
|
export declare const LINK_RULE: import("../MarkupRule.js").MarkupRule;
|
|
13
13
|
/**
|
|
14
|
-
* Autolinked URL starts with `scheme:` (any scheme in `MarkupOptions.schemes`) and matches an unlimited number of non-space characters.
|
|
14
|
+
* Autolinked URL starts with `scheme:` (any scheme in `MarkupOptions.schemes`) and matches an unlimited number of non-space characters (except `<` and `>`).
|
|
15
|
+
* - URL can be wrapped in `<>` angle brackets (the standard Markdown autolink syntax), e.g. `<http://google.com/maps>`. The brackets are not part of the link.
|
|
15
16
|
* - If followed by space and then text in `()` round or `[]` square brackets that will be used as the title, e.g. `http://google.com/maps (Google Maps)` or `http://google.com/maps [Google Maps]` (this syntax is from Todoist and maybe other things too).
|
|
16
17
|
* - If no title is specified a cleaned up version of the URL will be used, e.g. `google.com/maps`
|
|
17
18
|
* - If link is not valid (using `new URL(url)` then unparsed text will be returned.
|
package/markup/rule/link.js
CHANGED
|
@@ -20,8 +20,13 @@ function _renderLink(key, { title, href }, parser) {
|
|
|
20
20
|
*/
|
|
21
21
|
export const LINK_RULE = createMarkupRule(getRegExp(/\[(?<title>[^\]\n]*?)\]\((?<href>[^)\n]*?)\)/), //
|
|
22
22
|
_renderLink, ["inline", "list"]);
|
|
23
|
+
/** Render an autolink from whichever of its two URL forms matched. */
|
|
24
|
+
function _renderAutolink(key, { angled, href = "", ...data }, parser) {
|
|
25
|
+
return _renderLink(key, { ...data, href: angled ?? href }, parser);
|
|
26
|
+
}
|
|
23
27
|
/**
|
|
24
|
-
* Autolinked URL starts with `scheme:` (any scheme in `MarkupOptions.schemes`) and matches an unlimited number of non-space characters.
|
|
28
|
+
* Autolinked URL starts with `scheme:` (any scheme in `MarkupOptions.schemes`) and matches an unlimited number of non-space characters (except `<` and `>`).
|
|
29
|
+
* - URL can be wrapped in `<>` angle brackets (the standard Markdown autolink syntax), e.g. `<http://google.com/maps>`. The brackets are not part of the link.
|
|
25
30
|
* - If followed by space and then text in `()` round or `[]` square brackets that will be used as the title, e.g. `http://google.com/maps (Google Maps)` or `http://google.com/maps [Google Maps]` (this syntax is from Todoist and maybe other things too).
|
|
26
31
|
* - If no title is specified a cleaned up version of the URL will be used, e.g. `google.com/maps`
|
|
27
32
|
* - If link is not valid (using `new URL(url)` then unparsed text will be returned.
|
|
@@ -32,5 +37,5 @@ _renderLink, ["inline", "list"]);
|
|
|
32
37
|
*/
|
|
33
38
|
export const AUTOLINK_RULE = createMarkupRule(
|
|
34
39
|
// Scheme length is bounded (`{3,64}?`) so a long run of letters with no `:` can't force O(n²) backtracking.
|
|
35
|
-
getRegExp(/(?<href>[a-z]{3,64}
|
|
36
|
-
|
|
40
|
+
getRegExp(/(?:<(?<angled>[a-z]{3,64}?:[^\s<>]+)>|(?<href>[a-z]{3,64}?:[^\s<>]+))(?: +(?:\((?<title>[^)\n]*?)\)))?/), //
|
|
41
|
+
_renderAutolink, ["inline", "list"]);
|
package/markup/rule/ordered.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* - Line starting with number, followed by `.`, `)` or `:` character, then one or more space characters.
|
|
4
4
|
* - No spaces can appear before the number character.
|
|
5
5
|
* - Second-level list can be created by indenting with `\t` one tab.
|
|
6
|
+
* - Continuation lines can also be indented with spaces to the width of the number and its spaces, e.g. three spaces after `1. `, so a fenced code block can go inside an item.
|
|
6
7
|
* - List block runs until a blank line that is not followed by another item or an indented continuation line.
|
|
7
8
|
* - A list with blank lines between its items (or before a continuation paragraph) is "loose": its items are wrapped in `<p>` tags.
|
|
8
9
|
* - Sparse lists are not supported.
|
package/markup/rule/ordered.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { createMarkupRule } from "../MarkupRule.js";
|
|
3
3
|
import { BLOCK_CONTENT_REGEXP, BLOCK_SPACE_REGEXP, BLOCK_START_REGEXP, createBlockRegExp, LINE_SPACE_REGEXP } from "../util/regexp.js";
|
|
4
|
-
const _INDENT = /^\t/gm; // Nesting is recognised with tabs only.
|
|
5
4
|
const _NUMBER = "\\d{1,9}[.):]"; // Number for a numbered list, e.g. `1.` or `2)` or `3:` followed by one or more spaces.
|
|
6
|
-
const _ITEM = new RegExp(`(?:^|\n)(${_NUMBER})(
|
|
5
|
+
const _ITEM = new RegExp(`(?:^|\n)(${_NUMBER})(?:(${LINE_SPACE_REGEXP}+)(${BLOCK_CONTENT_REGEXP}))?${BLOCK_SPACE_REGEXP}*(?=\n${_NUMBER}(?:\\s|$)|$)`, "g");
|
|
7
6
|
// End of a list block: the end of the string, or a blank line that is *not* followed by another
|
|
8
7
|
// item or an indented continuation line. A blank line before a new item or a continuation
|
|
9
8
|
// paragraph keeps the list going (a "loose" list); anything else ends the list.
|
|
@@ -16,6 +15,7 @@ const _LOOSE = new RegExp(`\\n${LINE_SPACE_REGEXP}*\\n`);
|
|
|
16
15
|
* - Line starting with number, followed by `.`, `)` or `:` character, then one or more space characters.
|
|
17
16
|
* - No spaces can appear before the number character.
|
|
18
17
|
* - Second-level list can be created by indenting with `\t` one tab.
|
|
18
|
+
* - Continuation lines can also be indented with spaces to the width of the number and its spaces, e.g. three spaces after `1. `, so a fenced code block can go inside an item.
|
|
19
19
|
* - List block runs until a blank line that is not followed by another item or an indented continuation line.
|
|
20
20
|
* - A list with blank lines between its items (or before a continuation paragraph) is "loose": its items are wrapped in `<p>` tags.
|
|
21
21
|
* - Sparse lists are not supported.
|
|
@@ -29,7 +29,15 @@ function* _getOrderedItems(list, parser) {
|
|
|
29
29
|
// Items of a loose list are parsed as blocks so `PARAGRAPH_RULE` wraps their content in `<p>`.
|
|
30
30
|
const context = _LOOSE.test(list) ? "block" : "list";
|
|
31
31
|
let key = 0;
|
|
32
|
-
for (const [_unused, number = "", item = ""] of list.matchAll(_ITEM)) {
|
|
33
|
-
yield (_jsx("li", { value: Number.parseInt(number, 10), children: parser.parse(item
|
|
32
|
+
for (const [_unused, number = "", space = "", item = ""] of list.matchAll(_ITEM)) {
|
|
33
|
+
yield (_jsx("li", { value: Number.parseInt(number, 10), children: parser.parse(_unindent(item, number.length + space.length), context) }, key++));
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Remove one level of indent from each continuation line of a list item.
|
|
38
|
+
* - One tab is one level (used for nested lists).
|
|
39
|
+
* - Up to `width` spaces is one level, where `width` is the width of the item's marker plus its spaces (as in standard Markdown).
|
|
40
|
+
*/
|
|
41
|
+
function _unindent(item, width) {
|
|
42
|
+
return item.replace(new RegExp(`^(?:\\t| {1,${width}})`, "gm"), "");
|
|
43
|
+
}
|
|
@@ -5,6 +5,7 @@ import type { MarkupParser } from "../MarkupParser.js";
|
|
|
5
5
|
* - Line starting with `-`, `*`, `•`, or `+` character followed by one or more space characters.
|
|
6
6
|
* - No spaces can appear before the bullet character.
|
|
7
7
|
* - Second-level list can be created by indenting with `\t` one tab.
|
|
8
|
+
* - Continuation lines can also be indented with spaces to the width of the bullet and its spaces, e.g. two spaces after `- `, so a fenced code block can go inside an item.
|
|
8
9
|
* - List block runs until a blank line that is not followed by another item or an indented continuation line.
|
|
9
10
|
* - A list with blank lines between its items (or before a continuation paragraph) is "loose": its items are wrapped in `<p>` tags.
|
|
10
11
|
* - An item starting with `[ ]` or `[x]` (case-insensitive) is a todo item: a checkbox `<input>` plus the content wrapped in a `<label>` so clicking it toggles the checkbox.
|
package/markup/rule/unordered.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { createMarkupRule } from "../MarkupRule.js";
|
|
3
3
|
import { BLOCK_CONTENT_REGEXP, BLOCK_SPACE_REGEXP, BLOCK_START_REGEXP, createBlockRegExp, LINE_SPACE_REGEXP } from "../util/regexp.js";
|
|
4
|
-
const _INDENT = /^\t/gm; // Nesting is recognised with tabs only.
|
|
5
4
|
const _BULLET = "[-*•+]"; // Allowed bullet symbol.
|
|
6
|
-
const _ITEM = new RegExp(`(?:^|\n)${_BULLET}(
|
|
5
|
+
const _ITEM = new RegExp(`(?:^|\n)${_BULLET}(?:(${LINE_SPACE_REGEXP}+)(${BLOCK_CONTENT_REGEXP}))?${BLOCK_SPACE_REGEXP}*(?=\n${_BULLET}(?:\\s|$)|$)`, "g");
|
|
7
6
|
// A GitHub-style todo checkbox at the start of an item: `[ ]` (unchecked) or `[x]` (checked,
|
|
8
7
|
// case-insensitive), which must be followed by whitespace or the end of the item.
|
|
9
8
|
const _CHECKBOX = /^\[([ xX])\](?!\S)[^\n\S]*/;
|
|
@@ -19,6 +18,7 @@ const _LOOSE = new RegExp(`\\n${LINE_SPACE_REGEXP}*\\n`);
|
|
|
19
18
|
* - Line starting with `-`, `*`, `•`, or `+` character followed by one or more space characters.
|
|
20
19
|
* - No spaces can appear before the bullet character.
|
|
21
20
|
* - Second-level list can be created by indenting with `\t` one tab.
|
|
21
|
+
* - Continuation lines can also be indented with spaces to the width of the bullet and its spaces, e.g. two spaces after `- `, so a fenced code block can go inside an item.
|
|
22
22
|
* - List block runs until a blank line that is not followed by another item or an indented continuation line.
|
|
23
23
|
* - A list with blank lines between its items (or before a continuation paragraph) is "loose": its items are wrapped in `<p>` tags.
|
|
24
24
|
* - An item starting with `[ ]` or `[x]` (case-insensitive) is a todo item: a checkbox `<input>` plus the content wrapped in a `<label>` so clicking it toggles the checkbox.
|
|
@@ -33,8 +33,8 @@ export function* _getItems(list, parser) {
|
|
|
33
33
|
// Items of a loose list are parsed as blocks so `PARAGRAPH_RULE` wraps their content in `<p>`.
|
|
34
34
|
const context = _LOOSE.test(list) ? "block" : "list";
|
|
35
35
|
let key = 0;
|
|
36
|
-
for (const [_unused, raw = ""] of list.matchAll(_ITEM)) {
|
|
37
|
-
const item = raw
|
|
36
|
+
for (const [_unused, space = "", raw = ""] of list.matchAll(_ITEM)) {
|
|
37
|
+
const item = _unindent(raw, 1 + space.length);
|
|
38
38
|
// A todo item renders a checkbox; the `<label>` wrapping the content toggles it on click.
|
|
39
39
|
const checkbox = _CHECKBOX.exec(item);
|
|
40
40
|
if (checkbox) {
|
|
@@ -45,3 +45,11 @@ export function* _getItems(list, parser) {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Remove one level of indent from each continuation line of a list item.
|
|
50
|
+
* - One tab is one level (used for nested lists).
|
|
51
|
+
* - Up to `width` spaces is one level, where `width` is the width of the item's marker plus its spaces (as in standard Markdown).
|
|
52
|
+
*/
|
|
53
|
+
function _unindent(item, width) {
|
|
54
|
+
return item.replace(new RegExp(`^(?:\\t| {1,${width}})`, "gm"), "");
|
|
55
|
+
}
|