@cosense-toolbox/parser 0.1.0-beta.2 → 0.1.0-beta.4

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/README.md CHANGED
@@ -12,7 +12,15 @@ Cosense (旧 Scrapbox) の記法を、位置情報つきの AST に変換する
12
12
 
13
13
  > **beta**:公開 API はまだ変わりうる。安定するまではバージョンを固定して使うほうが安全。
14
14
 
15
- ### 次のリリースでの変更
15
+ ### 0.1.0-beta.3 の変更
16
+
17
+ - Cosense の文字装飾の記号 `!"#%&'()*+,-./{|}<>_~=` からなる並びを、**拡張なしで**すべて装飾として読むようにした。
18
+ Cosense Web と同じ読み方で、`[! 注意]` は内部リンクではなく `markers: ['!']` の装飾になる。
19
+ 見た目 (bold などのフラグ) が付くのは今までどおり `* / - _` だけ。ほかの記号の見た目は CSS で付ける。
20
+ - **`customDecorations` を削除した**。集合の中の記号は既定で読むので、この拡張で足せるのは
21
+ Cosense Web が装飾にしない記号だけになり、Web 版と違う AST を作るため。渡していた箇所は消すだけでよい。
22
+
23
+ ### 0.1.0-beta.2 の変更
16
24
 
17
25
  - 記法の拡張 (`InlineConstruct` / `BracketRule`) は、成立しなければ **`null` を返す**普通の関数になった。
18
26
  これまでは effect の `Option` を返す必要があり、拡張を書くのに effect が要った。
@@ -30,8 +38,6 @@ beta.0 から上げるときは次の 2 点に注意。
30
38
  出現順・重複なしで入る。`toHtml` はこれを `deco-*` のような class として出す。
31
39
  装飾ノードを自分で組み立てている拡張は追随が要る。
32
40
 
33
- 記号を増やす [`customDecorations`](https://cosense-toolbox.qaynam.dev/parser/extend/) も足した。
34
-
35
41
  ## インストール
36
42
 
37
43
  ```sh
@@ -65,7 +71,7 @@ toHtml(page) // → '<div class="page"><h1 class="title">今日のメモ</h1>…
65
71
  | `@cosense-toolbox/parser/utils` | ヘルパー。AST から取り出す | `visit` `find` `collect` `collectLinks` `firstImage` `rawTextOf` |
66
72
  | `@cosense-toolbox/parser/html` | AST を HTML 系の出力 (hast と HTML の文字列) にする | `toHast` `toHtml` `codeLineNumbers` `tableCellLineBreaks` |
67
73
  | `@cosense-toolbox/parser/compile` | AST を HTML 以外の形式にする | `toPlainText` `createCompiler` |
68
- | `@cosense-toolbox/parser/extensions` | 記法を足す | `Extension` `InlineConstruct` `BracketRule` `customDecorations` `tableCellNotation` |
74
+ | `@cosense-toolbox/parser/extensions` | 記法を足す | `Extension` `InlineConstruct` `BracketRule` `tableCellNotation` |
69
75
  | `@cosense-toolbox/parser/schema` | 外から来た値を検証する | `decodePage` |
70
76
 
71
77
  各 API の詳細はドキュメントにある。
@@ -1,18 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_decoration = require("./decoration-BYXIXxCA.cjs");
3
- let effect = require("effect");
4
- //#region src/extensions/custom-decoration.ts
5
- /**
6
- * 文字装飾記法として読む記号を増やす拡張。
7
- *
8
- * 既定では `* / - _` の 4 つだけを装飾として読み、それ以外は内部リンクになる。
9
- * 渡した記号は既定の記号と混ぜられ、`[*' x]` は太字かつ `markers: ['*', "'"]` になる。
10
- */
11
- const customDecorations = (markers) => {
12
- const rule = require_decoration.buildDecorationRule(require_decoration.OFFICIAL_MARKERS + markers.join(""));
13
- return { bracketRules: [(inner, ctx) => effect.Option.getOrNull(rule(inner, ctx))] };
14
- };
15
- //#endregion
16
2
  //#region src/extensions/table-cell-notation.ts
17
3
  /**
18
4
  * テーブルのセルの中でも、行と同じく記法を読む拡張。Cosense Web には無い振る舞い。
@@ -26,7 +12,6 @@ const customDecorations = (markers) => {
26
12
  */
27
13
  const tableCellNotation = (types) => ({ keepInTableCell: types === void 0 ? () => true : (node) => types.includes(node.type) });
28
14
  //#endregion
29
- exports.customDecorations = customDecorations;
30
15
  exports.tableCellNotation = tableCellNotation;
31
16
 
32
17
  //# sourceMappingURL=extensions.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"extensions.cjs","names":["buildDecorationRule","OFFICIAL_MARKERS","Option"],"sources":["../src/extensions/custom-decoration.ts","../src/extensions/table-cell-notation.ts"],"sourcesContent":["import { Option } from \"effect\"\n\nimport { buildDecorationRule, OFFICIAL_MARKERS } from \"../inline/bracket-rules/decoration\"\nimport type { Extension } from \"../inline/types\"\n\n/**\n * 文字装飾記法として読む記号を増やす拡張。\n *\n * 既定では `* / - _` の 4 つだけを装飾として読み、それ以外は内部リンクになる。\n * 渡した記号は既定の記号と混ぜられ、`[*' x]` は太字かつ `markers: ['*', \"'\"]` になる。\n */\nexport const customDecorations = (markers: readonly string[]): Extension => {\n const rule = buildDecorationRule(OFFICIAL_MARKERS + markers.join(\"\"))\n // 拡張のルールは null で返す形なので、中のルールの Option を外す。\n return { bracketRules: [(inner, ctx) => Option.getOrNull(rule(inner, ctx))] }\n}\n","import type { Extension } from \"../inline/types\"\nimport type { InlineNode } from \"../types\"\n\n/**\n * テーブルのセルの中でも、行と同じく記法を読む拡張。Cosense Web には無い振る舞い。\n *\n * 既定ではセルの中はリンクの記法だけを読み、それ以外は書いたままの文字になる (Cosense Web と同じ)。\n * `types` を渡すと、リンクに加えてその型のノードだけを読む。省くとすべての記法 (拡張の記法も含む) を読む。\n *\n * @example\n * parse(source, { extensions: [tableCellNotation()] }) // すべての記法\n * parse(source, { extensions: [tableCellNotation(['decoration'])] }) // リンクと装飾だけ\n */\nexport const tableCellNotation = (types?: readonly InlineNode[\"type\"][]): Extension => ({\n keepInTableCell: types === undefined ? () => true : (node) => types.includes(node.type),\n})\n"],"mappings":";;;;;;;;;;AAWA,MAAa,qBAAqB,YAA0C;CAC1E,MAAM,OAAOA,mBAAAA,oBAAoBC,mBAAAA,mBAAmB,QAAQ,KAAK,EAAE,CAAC;CAEpE,OAAO,EAAE,cAAc,EAAE,OAAO,QAAQC,OAAAA,OAAO,UAAU,KAAK,OAAO,GAAG,CAAC,CAAC,EAAE;AAC9E;;;;;;;;;;;;;ACFA,MAAa,qBAAqB,WAAsD,EACtF,iBAAiB,UAAU,KAAA,UAAkB,QAAQ,SAAS,MAAM,SAAS,KAAK,IAAI,EACxF"}
1
+ {"version":3,"file":"extensions.cjs","names":[],"sources":["../src/extensions/table-cell-notation.ts"],"sourcesContent":["import type { Extension } from \"../inline/types\"\nimport type { InlineNode } from \"../types\"\n\n/**\n * テーブルのセルの中でも、行と同じく記法を読む拡張。Cosense Web には無い振る舞い。\n *\n * 既定ではセルの中はリンクの記法だけを読み、それ以外は書いたままの文字になる (Cosense Web と同じ)。\n * `types` を渡すと、リンクに加えてその型のノードだけを読む。省くとすべての記法 (拡張の記法も含む) を読む。\n *\n * @example\n * parse(source, { extensions: [tableCellNotation()] }) // すべての記法\n * parse(source, { extensions: [tableCellNotation(['decoration'])] }) // リンクと装飾だけ\n */\nexport const tableCellNotation = (types?: readonly InlineNode[\"type\"][]): Extension => ({\n keepInTableCell: types === undefined ? () => true : (node) => types.includes(node.type),\n})\n"],"mappings":";;;;;;;;;;;;AAaA,MAAa,qBAAqB,WAAsD,EACtF,iBAAiB,UAAU,KAAA,UAAkB,QAAQ,SAAS,MAAM,SAAS,KAAK,IAAI,EACxF"}
@@ -1,14 +1,5 @@
1
1
  import { F as WithoutPosition, _ as InlineNodeInit, g as InlineNode } from "./types-gWMrsXPX.cjs";
2
2
  import { a as InlineConstruct, i as Extension, n as BracketRuleContext, o as InlineContext, r as ConstructMatch, s as Origin, t as BracketRule } from "./types-_-ZAyNkz.cjs";
3
- //#region src/extensions/custom-decoration.d.ts
4
- /**
5
- * 文字装飾記法として読む記号を増やす拡張。
6
- *
7
- * 既定では `* / - _` の 4 つだけを装飾として読み、それ以外は内部リンクになる。
8
- * 渡した記号は既定の記号と混ぜられ、`[*' x]` は太字かつ `markers: ['*', "'"]` になる。
9
- */
10
- declare const customDecorations: (markers: readonly string[]) => Extension;
11
- //#endregion
12
3
  //#region src/extensions/table-cell-notation.d.ts
13
4
  /**
14
5
  * テーブルのセルの中でも、行と同じく記法を読む拡張。Cosense Web には無い振る舞い。
@@ -22,5 +13,5 @@ declare const customDecorations: (markers: readonly string[]) => Extension;
22
13
  */
23
14
  declare const tableCellNotation: (types?: readonly InlineNode["type"][]) => Extension;
24
15
  //#endregion
25
- export { type BracketRule, type BracketRuleContext, type ConstructMatch, type Extension, type InlineConstruct, type InlineContext, type InlineNodeInit, type Origin, type WithoutPosition, customDecorations, tableCellNotation };
16
+ export { type BracketRule, type BracketRuleContext, type ConstructMatch, type Extension, type InlineConstruct, type InlineContext, type InlineNodeInit, type Origin, type WithoutPosition, tableCellNotation };
26
17
  //# sourceMappingURL=extensions.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"extensions.d.cts","names":[],"sources":["../src/extensions/custom-decoration.ts","../src/extensions/table-cell-notation.ts"],"mappings":";;;;;;;;;cAWa,oBAAqB,+BAA6B;;;;;;;;;;;;;cCElD,oBAAqB,iBAAiB,yBAAuB"}
1
+ {"version":3,"file":"extensions.d.cts","names":[],"sources":["../src/extensions/table-cell-notation.ts"],"mappings":";;;;;;;;;;;;;cAaa,oBAAqB,iBAAiB,yBAAuB"}
@@ -1,14 +1,5 @@
1
1
  import { F as WithoutPosition, _ as InlineNodeInit, g as InlineNode } from "./types-gWMrsXPX.mjs";
2
2
  import { a as InlineConstruct, i as Extension, n as BracketRuleContext, o as InlineContext, r as ConstructMatch, s as Origin, t as BracketRule } from "./types-CdiHju1P.mjs";
3
- //#region src/extensions/custom-decoration.d.ts
4
- /**
5
- * 文字装飾記法として読む記号を増やす拡張。
6
- *
7
- * 既定では `* / - _` の 4 つだけを装飾として読み、それ以外は内部リンクになる。
8
- * 渡した記号は既定の記号と混ぜられ、`[*' x]` は太字かつ `markers: ['*', "'"]` になる。
9
- */
10
- declare const customDecorations: (markers: readonly string[]) => Extension;
11
- //#endregion
12
3
  //#region src/extensions/table-cell-notation.d.ts
13
4
  /**
14
5
  * テーブルのセルの中でも、行と同じく記法を読む拡張。Cosense Web には無い振る舞い。
@@ -22,5 +13,5 @@ declare const customDecorations: (markers: readonly string[]) => Extension;
22
13
  */
23
14
  declare const tableCellNotation: (types?: readonly InlineNode["type"][]) => Extension;
24
15
  //#endregion
25
- export { type BracketRule, type BracketRuleContext, type ConstructMatch, type Extension, type InlineConstruct, type InlineContext, type InlineNodeInit, type Origin, type WithoutPosition, customDecorations, tableCellNotation };
16
+ export { type BracketRule, type BracketRuleContext, type ConstructMatch, type Extension, type InlineConstruct, type InlineContext, type InlineNodeInit, type Origin, type WithoutPosition, tableCellNotation };
26
17
  //# sourceMappingURL=extensions.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"extensions.d.mts","names":[],"sources":["../src/extensions/custom-decoration.ts","../src/extensions/table-cell-notation.ts"],"mappings":";;;;;;;;;cAWa,oBAAqB,+BAA6B;;;;;;;;;;;;;cCElD,oBAAqB,iBAAiB,yBAAuB"}
1
+ {"version":3,"file":"extensions.d.mts","names":[],"sources":["../src/extensions/table-cell-notation.ts"],"mappings":";;;;;;;;;;;;;cAaa,oBAAqB,iBAAiB,yBAAuB"}
@@ -1,17 +1,3 @@
1
- import { n as buildDecorationRule, t as OFFICIAL_MARKERS } from "./decoration-BB1cS4lH.mjs";
2
- import { Option } from "effect";
3
- //#region src/extensions/custom-decoration.ts
4
- /**
5
- * 文字装飾記法として読む記号を増やす拡張。
6
- *
7
- * 既定では `* / - _` の 4 つだけを装飾として読み、それ以外は内部リンクになる。
8
- * 渡した記号は既定の記号と混ぜられ、`[*' x]` は太字かつ `markers: ['*', "'"]` になる。
9
- */
10
- const customDecorations = (markers) => {
11
- const rule = buildDecorationRule(OFFICIAL_MARKERS + markers.join(""));
12
- return { bracketRules: [(inner, ctx) => Option.getOrNull(rule(inner, ctx))] };
13
- };
14
- //#endregion
15
1
  //#region src/extensions/table-cell-notation.ts
16
2
  /**
17
3
  * テーブルのセルの中でも、行と同じく記法を読む拡張。Cosense Web には無い振る舞い。
@@ -25,6 +11,6 @@ const customDecorations = (markers) => {
25
11
  */
26
12
  const tableCellNotation = (types) => ({ keepInTableCell: types === void 0 ? () => true : (node) => types.includes(node.type) });
27
13
  //#endregion
28
- export { customDecorations, tableCellNotation };
14
+ export { tableCellNotation };
29
15
 
30
16
  //# sourceMappingURL=extensions.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"extensions.mjs","names":[],"sources":["../src/extensions/custom-decoration.ts","../src/extensions/table-cell-notation.ts"],"sourcesContent":["import { Option } from \"effect\"\n\nimport { buildDecorationRule, OFFICIAL_MARKERS } from \"../inline/bracket-rules/decoration\"\nimport type { Extension } from \"../inline/types\"\n\n/**\n * 文字装飾記法として読む記号を増やす拡張。\n *\n * 既定では `* / - _` の 4 つだけを装飾として読み、それ以外は内部リンクになる。\n * 渡した記号は既定の記号と混ぜられ、`[*' x]` は太字かつ `markers: ['*', \"'\"]` になる。\n */\nexport const customDecorations = (markers: readonly string[]): Extension => {\n const rule = buildDecorationRule(OFFICIAL_MARKERS + markers.join(\"\"))\n // 拡張のルールは null で返す形なので、中のルールの Option を外す。\n return { bracketRules: [(inner, ctx) => Option.getOrNull(rule(inner, ctx))] }\n}\n","import type { Extension } from \"../inline/types\"\nimport type { InlineNode } from \"../types\"\n\n/**\n * テーブルのセルの中でも、行と同じく記法を読む拡張。Cosense Web には無い振る舞い。\n *\n * 既定ではセルの中はリンクの記法だけを読み、それ以外は書いたままの文字になる (Cosense Web と同じ)。\n * `types` を渡すと、リンクに加えてその型のノードだけを読む。省くとすべての記法 (拡張の記法も含む) を読む。\n *\n * @example\n * parse(source, { extensions: [tableCellNotation()] }) // すべての記法\n * parse(source, { extensions: [tableCellNotation(['decoration'])] }) // リンクと装飾だけ\n */\nexport const tableCellNotation = (types?: readonly InlineNode[\"type\"][]): Extension => ({\n keepInTableCell: types === undefined ? () => true : (node) => types.includes(node.type),\n})\n"],"mappings":";;;;;;;;;AAWA,MAAa,qBAAqB,YAA0C;CAC1E,MAAM,OAAO,oBAAoB,mBAAmB,QAAQ,KAAK,EAAE,CAAC;CAEpE,OAAO,EAAE,cAAc,EAAE,OAAO,QAAQ,OAAO,UAAU,KAAK,OAAO,GAAG,CAAC,CAAC,EAAE;AAC9E;;;;;;;;;;;;;ACFA,MAAa,qBAAqB,WAAsD,EACtF,iBAAiB,UAAU,KAAA,UAAkB,QAAQ,SAAS,MAAM,SAAS,KAAK,IAAI,EACxF"}
1
+ {"version":3,"file":"extensions.mjs","names":[],"sources":["../src/extensions/table-cell-notation.ts"],"sourcesContent":["import type { Extension } from \"../inline/types\"\nimport type { InlineNode } from \"../types\"\n\n/**\n * テーブルのセルの中でも、行と同じく記法を読む拡張。Cosense Web には無い振る舞い。\n *\n * 既定ではセルの中はリンクの記法だけを読み、それ以外は書いたままの文字になる (Cosense Web と同じ)。\n * `types` を渡すと、リンクに加えてその型のノードだけを読む。省くとすべての記法 (拡張の記法も含む) を読む。\n *\n * @example\n * parse(source, { extensions: [tableCellNotation()] }) // すべての記法\n * parse(source, { extensions: [tableCellNotation(['decoration'])] }) // リンクと装飾だけ\n */\nexport const tableCellNotation = (types?: readonly InlineNode[\"type\"][]): Extension => ({\n keepInTableCell: types === undefined ? () => true : (node) => types.includes(node.type),\n})\n"],"mappings":";;;;;;;;;;;AAaA,MAAa,qBAAqB,WAAsD,EACtF,iBAAiB,UAAU,KAAA,UAAkB,QAAQ,SAAS,MAAM,SAAS,KAAK,IAAI,EACxF"}
package/dist/index.cjs CHANGED
@@ -1,7 +1,29 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_image_url = require("./image-url-YcTed8tg.cjs");
3
- const require_decoration = require("./decoration-BYXIXxCA.cjs");
4
3
  let effect = require("effect");
4
+ //#region src/core/position.ts
5
+ const originOfLine = (line, offset) => ({
6
+ line,
7
+ column: 0,
8
+ offset
9
+ });
10
+ /** Origin を `by` 文字ぶん進める (部分文字列を再帰的に走査するときに使う)。 */
11
+ const shiftOrigin = (origin, by) => ({
12
+ line: origin.line,
13
+ column: origin.column + by,
14
+ offset: origin.offset + by
15
+ });
16
+ const pointAt = (origin, index) => ({
17
+ line: origin.line,
18
+ column: origin.column + index,
19
+ offset: origin.offset + index
20
+ });
21
+ /** 走査対象の `[start, end)` が占める Position。end は exclusive。 */
22
+ const spanAt = (origin, start, end) => ({
23
+ start: pointAt(origin, start),
24
+ end: pointAt(origin, end)
25
+ });
26
+ //#endregion
5
27
  //#region src/inline/constructs/bare-url.ts
6
28
  const URL_RE = /^https?:\/\/[^\s\]]+/i;
7
29
  /**
@@ -54,6 +76,61 @@ const isTagBoundary = (s, index) => {
54
76
  return prev === " " || prev === " " || prev === " ";
55
77
  };
56
78
  //#endregion
79
+ //#region src/inline/bracket-rules/decoration.ts
80
+ /**
81
+ * `[<記号の並び> 中身]`。記号は Cosense の文字装飾の記号 `` !"#%&'()*+,-./{|}<>_~= `` で、
82
+ * Cosense Web はこの集合からなる並びをすべて装飾として読む (help-jp「文字装飾記法」)。
83
+ * `=` は help-jp が将来の別用途のために使わないよう求めているが、今の Cosense Web は
84
+ * 装飾として読むので含める。
85
+ * どの記号が装飾になるかは構文なので、設定で変えられるようにしない。
86
+ * `$` と `[` はこの一覧に無い。`[$ x]` は数式、`[[x]]` は太字の別の記法で、どちらも別のルールが読む。
87
+ *
88
+ * 文字列から組み立てずに正規表現のリテラルで持つのは、トップレベルで関数を呼ばないため
89
+ * (`sideEffects: false`)。
90
+ */
91
+ const DECORATION_PATTERN = /^([!"#%&'()*+,\-./{|}<>_~=]+)\s+([\s\S]+)$/;
92
+ /**
93
+ * 見た目が決まっている記号。bold などのフラグはこれだけから決める。
94
+ * ほかの記号は `markers` に残るだけで、見た目はプロジェクトの UserCSS が付ける。
95
+ */
96
+ const STYLED_MARKERS = {
97
+ bold: "*",
98
+ italic: "/",
99
+ strike: "-",
100
+ underline: "_"
101
+ };
102
+ const MAX_SIZE_LEVEL = 4;
103
+ /** 出現順を保ったまま重複を落とす。`[*** x]` の markers は `['*']` になる。 */
104
+ const uniqueChars = (marks) => [...new Set(marks)];
105
+ /**
106
+ * `[* 太字]` `[/ 斜体]` `[- 打消し]` `[_ 下線]` とその複合 (`[-/ x]`)、
107
+ * および見た目の付かない記号の装飾 (`[! 注意]`)。
108
+ *
109
+ * 中身はリンクやアイコンとして再帰的に解釈するが、**装飾の入れ子は不可**。
110
+ * そのため子の走査は allowDecoration=false で行う。
111
+ * 例: `[* [* 太字]ですね]` の内側は装飾ではなく内部リンクになる。
112
+ */
113
+ const decorationRule = (inner, ctx) => {
114
+ if (!ctx.allowDecoration) return effect.Option.none();
115
+ const match = inner.match(DECORATION_PATTERN);
116
+ if (!match) return effect.Option.none();
117
+ const marks = match[1] ?? "";
118
+ const value = match[2] ?? "";
119
+ const stars = [...marks].filter((mark) => mark === STYLED_MARKERS.bold).length;
120
+ const valueOffset = inner.length - value.length;
121
+ return effect.Option.some({
122
+ type: "decoration",
123
+ value,
124
+ markers: uniqueChars(marks),
125
+ bold: stars > 0,
126
+ italic: marks.includes(STYLED_MARKERS.italic),
127
+ strike: marks.includes(STYLED_MARKERS.strike),
128
+ underline: marks.includes(STYLED_MARKERS.underline),
129
+ sizeLevel: Math.min(Math.max(stars - 1, 0), MAX_SIZE_LEVEL),
130
+ children: ctx.tokenize(value, shiftOrigin(ctx.innerOrigin, valueOffset), false)
131
+ });
132
+ };
133
+ //#endregion
57
134
  //#region src/inline/bracket-rules/formula.ts
58
135
  /** `[$ x^2]` — 中身は解釈せず生のまま返す (KaTeX 等に渡す想定)。 */
59
136
  const formulaRule = (inner) => inner.startsWith("$") ? effect.Option.some({
@@ -186,7 +263,7 @@ const urlRule = (inner) => {
186
263
  //#endregion
187
264
  //#region src/inline/bracket-rules/index.ts
188
265
  /** 中身に角括弧を含んでいても成立しうるルール。 */
189
- const bracketRules = [formulaRule, require_decoration.decorationRule];
266
+ const bracketRules = [formulaRule, decorationRule];
190
267
  /**
191
268
  * 「単純ターゲット」のルール。中身に `[` / `]` を含むときは試さない (Cosense Web に合わせている)。
192
269
  * これにより `[[そうね] ですね]` の外側は記法にならず、先頭の `[` が素の文字になる。
@@ -219,7 +296,7 @@ const bracketConstruct = (source, index, ctx) => {
219
296
  if (inner.trim() === "") return effect.Option.none();
220
297
  const innerCtx = {
221
298
  ...ctx,
222
- innerOrigin: require_decoration.shiftOrigin(ctx.origin, index + 1)
299
+ innerOrigin: shiftOrigin(ctx.origin, index + 1)
223
300
  };
224
301
  return (0, effect.pipe)(parseInner(inner, innerCtx), effect.Option.map((node) => ({
225
302
  node,
@@ -295,7 +372,7 @@ const strongBracketConstruct = (source, index, ctx) => {
295
372
  strike: false,
296
373
  underline: false,
297
374
  sizeLevel: 0,
298
- children: ctx.tokenize(inner, require_decoration.shiftOrigin(ctx.origin, index + 2), false)
375
+ children: ctx.tokenize(inner, shiftOrigin(ctx.origin, index + 2), false)
299
376
  },
300
377
  length
301
378
  });
@@ -362,7 +439,7 @@ const scan = (source, origin, allowDecoration, rules) => {
362
439
  out.push({
363
440
  type: "text",
364
441
  value: source.slice(textStart, end),
365
- position: require_decoration.spanAt(origin, textStart, end)
442
+ position: spanAt(origin, textStart, end)
366
443
  });
367
444
  };
368
445
  while (index < source.length) {
@@ -373,7 +450,7 @@ const scan = (source, origin, allowDecoration, rules) => {
373
450
  }
374
451
  flushText(index);
375
452
  const { node, length } = match.value;
376
- out.push(withPosition(node, require_decoration.spanAt(origin, index, index + length)));
453
+ out.push(withPosition(node, spanAt(origin, index, index + length)));
377
454
  index += length;
378
455
  textStart = index;
379
456
  }
@@ -456,8 +533,8 @@ const indentOf = (raw) => leadingWhitespace(raw).length;
456
533
  * この複数行のまとまりを作るのがここの仕事で、行の中身の解釈は注入された tokenize に任せる
457
534
  * (どの記法ルールを使うかを知らずに済むので、拡張入りのパーサーでもここは変わらない)。
458
535
  */
459
- const lineOrigin = (line) => require_decoration.originOfLine(line.index, line.offset);
460
- const wholeLine = (line) => require_decoration.spanAt(lineOrigin(line), 0, line.text.length);
536
+ const lineOrigin = (line) => originOfLine(line.index, line.offset);
537
+ const wholeLine = (line) => spanAt(lineOrigin(line), 0, line.text.length);
461
538
  /** インデントを `amount` 文字ぶん浅くする。空白より多くは削らない。 */
462
539
  const dedent = (text, amount) => text.slice(Math.min(amount, indentOf(text)));
463
540
  const titleBlock = (line, tokenize) => ({
@@ -492,8 +569,8 @@ const tableCells = (line, tokenize) => {
492
569
  return {
493
570
  type: "tableCell",
494
571
  value,
495
- children: tokenize(value, require_decoration.shiftOrigin(origin, start)),
496
- position: require_decoration.spanAt(origin, start, start + value.length)
572
+ children: tokenize(value, shiftOrigin(origin, start)),
573
+ position: spanAt(origin, start, start + value.length)
497
574
  };
498
575
  });
499
576
  };
@@ -628,7 +705,7 @@ const keepNotation = (nodes, source, origin, keep) => {
628
705
  const literal = (start, end) => start >= end ? [] : [{
629
706
  type: "text",
630
707
  value: source.slice(start - origin.offset, end - origin.offset),
631
- position: require_decoration.spanAt(origin, start - origin.offset, end - origin.offset)
708
+ position: spanAt(origin, start - origin.offset, end - origin.offset)
632
709
  }];
633
710
  const inside = (children) => mergeTexts(children.flatMap(demote));
634
711
  /** 装飾の記号だけを文字に戻し、中身は辿る。中身が空なら丸ごと文字にする。 */