@cosense-toolbox/parser 0.1.0-beta.0 → 0.1.0-beta.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 (86) hide show
  1. package/README.md +76 -758
  2. package/dist/{ast-uYWtkHwT.cjs → ast-C0BGz7X2.cjs} +2 -2
  3. package/dist/ast-C0BGz7X2.cjs.map +1 -0
  4. package/dist/{ast-CIKXwSl5.mjs → ast-CMQYawYl.mjs} +2 -2
  5. package/dist/ast-CMQYawYl.mjs.map +1 -0
  6. package/dist/compile.cjs +2 -212
  7. package/dist/compile.cjs.map +1 -1
  8. package/dist/compile.d.cts +17 -125
  9. package/dist/compile.d.cts.map +1 -1
  10. package/dist/compile.d.mts +17 -125
  11. package/dist/compile.d.mts.map +1 -1
  12. package/dist/compile.mjs +3 -206
  13. package/dist/compile.mjs.map +1 -1
  14. package/dist/decoration-BB1cS4lH.mjs +72 -0
  15. package/dist/decoration-BB1cS4lH.mjs.map +1 -0
  16. package/dist/decoration-BYXIXxCA.cjs +107 -0
  17. package/dist/decoration-BYXIXxCA.cjs.map +1 -0
  18. package/dist/extensions.cjs +32 -0
  19. package/dist/extensions.cjs.map +1 -0
  20. package/dist/extensions.d.cts +26 -0
  21. package/dist/extensions.d.cts.map +1 -0
  22. package/dist/extensions.d.mts +26 -0
  23. package/dist/extensions.d.mts.map +1 -0
  24. package/dist/extensions.mjs +30 -0
  25. package/dist/extensions.mjs.map +1 -0
  26. package/dist/html.cjs +458 -0
  27. package/dist/html.cjs.map +1 -0
  28. package/dist/html.d.cts +274 -0
  29. package/dist/html.d.cts.map +1 -0
  30. package/dist/html.d.mts +274 -0
  31. package/dist/html.d.mts.map +1 -0
  32. package/dist/html.mjs +447 -0
  33. package/dist/html.mjs.map +1 -0
  34. package/dist/image-url-YcTed8tg.cjs.map +1 -1
  35. package/dist/image-url-eQ6X-oN0.mjs.map +1 -1
  36. package/dist/index-CrIlOW1k.d.mts +78 -0
  37. package/dist/index-CrIlOW1k.d.mts.map +1 -0
  38. package/dist/index-_o1STNhP.d.cts +78 -0
  39. package/dist/index-_o1STNhP.d.cts.map +1 -0
  40. package/dist/index.cjs +118 -94
  41. package/dist/index.cjs.map +1 -1
  42. package/dist/index.d.cts +4 -77
  43. package/dist/index.d.mts +4 -77
  44. package/dist/index.mjs +110 -86
  45. package/dist/index.mjs.map +1 -1
  46. package/dist/schema.cjs +2 -0
  47. package/dist/schema.cjs.map +1 -1
  48. package/dist/schema.d.cts +1 -1
  49. package/dist/schema.d.cts.map +1 -1
  50. package/dist/schema.d.mts +1 -1
  51. package/dist/schema.d.mts.map +1 -1
  52. package/dist/schema.mjs +2 -0
  53. package/dist/schema.mjs.map +1 -1
  54. package/dist/{types-BXlnUFr0.d.mts → types-CdiHju1P.d.mts} +15 -12
  55. package/dist/types-CdiHju1P.d.mts.map +1 -0
  56. package/dist/{types-DVwlUtla.d.cts → types-_-ZAyNkz.d.cts} +15 -12
  57. package/dist/types-_-ZAyNkz.d.cts.map +1 -0
  58. package/dist/{types-Bo_BrmvK.d.cts → types-gWMrsXPX.d.cts} +31 -22
  59. package/dist/types-gWMrsXPX.d.cts.map +1 -0
  60. package/dist/{types-Bo_BrmvK.d.mts → types-gWMrsXPX.d.mts} +31 -22
  61. package/dist/types-gWMrsXPX.d.mts.map +1 -0
  62. package/dist/utils.cjs +2 -2
  63. package/dist/utils.cjs.map +1 -1
  64. package/dist/utils.d.cts +2 -2
  65. package/dist/utils.d.cts.map +1 -1
  66. package/dist/utils.d.mts +2 -2
  67. package/dist/utils.d.mts.map +1 -1
  68. package/dist/utils.mjs +2 -2
  69. package/dist/utils.mjs.map +1 -1
  70. package/package.json +33 -10
  71. package/dist/ast-CIKXwSl5.mjs.map +0 -1
  72. package/dist/ast-uYWtkHwT.cjs.map +0 -1
  73. package/dist/create-compiler-CvlndKOA.d.cts +0 -23
  74. package/dist/create-compiler-CvlndKOA.d.cts.map +0 -1
  75. package/dist/create-compiler-jdA408ny.d.mts +0 -23
  76. package/dist/create-compiler-jdA408ny.d.mts.map +0 -1
  77. package/dist/index.d.cts.map +0 -1
  78. package/dist/index.d.mts.map +0 -1
  79. package/dist/plugin.cjs +0 -0
  80. package/dist/plugin.d.cts +0 -4
  81. package/dist/plugin.d.mts +0 -4
  82. package/dist/plugin.mjs +0 -1
  83. package/dist/types-BXlnUFr0.d.mts.map +0 -1
  84. package/dist/types-Bo_BrmvK.d.cts.map +0 -1
  85. package/dist/types-Bo_BrmvK.d.mts.map +0 -1
  86. package/dist/types-DVwlUtla.d.cts.map +0 -1
@@ -0,0 +1,107 @@
1
+ let effect = require("effect");
2
+ //#region src/core/position.ts
3
+ const originOfLine = (line, offset) => ({
4
+ line,
5
+ column: 0,
6
+ offset
7
+ });
8
+ /** Origin を `by` 文字ぶん進める (部分文字列を再帰的に走査するときに使う)。 */
9
+ const shiftOrigin = (origin, by) => ({
10
+ line: origin.line,
11
+ column: origin.column + by,
12
+ offset: origin.offset + by
13
+ });
14
+ const pointAt = (origin, index) => ({
15
+ line: origin.line,
16
+ column: origin.column + index,
17
+ offset: origin.offset + index
18
+ });
19
+ /** 走査対象の `[start, end)` が占める Position。end は exclusive。 */
20
+ const spanAt = (origin, start, end) => ({
21
+ start: pointAt(origin, start),
22
+ end: pointAt(origin, end)
23
+ });
24
+ //#endregion
25
+ //#region src/inline/bracket-rules/decoration.ts
26
+ /** 意味を持つ文字装飾記法の記号。 */
27
+ const OFFICIAL_MARKERS = "*/-_";
28
+ const MAX_SIZE_LEVEL = 4;
29
+ /** 文字クラスの中で特別扱いされる文字を潰す。 */
30
+ const escapeForCharClass = (chars) => chars.replace(/[\\\]^-]/g, "\\$&");
31
+ /** 出現順を保ったまま重複を落とす。`[*** x]` の markers は `['*']` になる。 */
32
+ const uniqueChars = (marks) => [...new Set(marks)];
33
+ /**
34
+ * `[<記号> 中身]` を文字装飾記法として読む。`markerChars` に含まれる記号だけを受け付ける。
35
+ *
36
+ * 中身はリンクやアイコンとして再帰的に解釈するが、**装飾の入れ子は不可**。
37
+ * そのため子の走査は allowDecoration=false で行う。
38
+ * 例: `[* [* 太字]ですね]` の内側は装飾ではなく内部リンクになる。
39
+ */
40
+ /**
41
+ * 文脈は拡張に渡るものと同じ形 (`BracketRuleContext`) だけを使う。
42
+ * `customDecorations` が拡張のルールとしても使うため。
43
+ */
44
+ const buildDecorationRule = (markerChars) => {
45
+ const pattern = new RegExp(`^([${escapeForCharClass(markerChars)}]+)\\s+([\\s\\S]+)$`);
46
+ return (inner, ctx) => {
47
+ if (!ctx.allowDecoration) return effect.Option.none();
48
+ const match = inner.match(pattern);
49
+ if (!match) return effect.Option.none();
50
+ const marks = match[1] ?? "";
51
+ const value = match[2] ?? "";
52
+ const stars = (marks.match(/\*/g) ?? []).length;
53
+ const valueOffset = inner.length - value.length;
54
+ return effect.Option.some({
55
+ type: "decoration",
56
+ value,
57
+ markers: uniqueChars(marks),
58
+ bold: stars > 0,
59
+ italic: marks.includes("/"),
60
+ strike: marks.includes("-"),
61
+ underline: marks.includes("_"),
62
+ sizeLevel: Math.min(Math.max(stars - 1, 0), MAX_SIZE_LEVEL),
63
+ children: ctx.tokenize(value, shiftOrigin(ctx.innerOrigin, valueOffset), false)
64
+ });
65
+ };
66
+ };
67
+ /** `[* 太字]` `[/ 斜体]` `[- 打消し]` `[_ 下線]` とその複合 (`[-/ x]`)。 */
68
+ const decorationRule = buildDecorationRule(OFFICIAL_MARKERS);
69
+ //#endregion
70
+ Object.defineProperty(exports, "OFFICIAL_MARKERS", {
71
+ enumerable: true,
72
+ get: function() {
73
+ return OFFICIAL_MARKERS;
74
+ }
75
+ });
76
+ Object.defineProperty(exports, "buildDecorationRule", {
77
+ enumerable: true,
78
+ get: function() {
79
+ return buildDecorationRule;
80
+ }
81
+ });
82
+ Object.defineProperty(exports, "decorationRule", {
83
+ enumerable: true,
84
+ get: function() {
85
+ return decorationRule;
86
+ }
87
+ });
88
+ Object.defineProperty(exports, "originOfLine", {
89
+ enumerable: true,
90
+ get: function() {
91
+ return originOfLine;
92
+ }
93
+ });
94
+ Object.defineProperty(exports, "shiftOrigin", {
95
+ enumerable: true,
96
+ get: function() {
97
+ return shiftOrigin;
98
+ }
99
+ });
100
+ Object.defineProperty(exports, "spanAt", {
101
+ enumerable: true,
102
+ get: function() {
103
+ return spanAt;
104
+ }
105
+ });
106
+
107
+ //# sourceMappingURL=decoration-BYXIXxCA.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decoration-BYXIXxCA.cjs","names":["Option"],"sources":["../src/core/position.ts","../src/inline/bracket-rules/decoration.ts"],"sourcesContent":["/**\n * position.ts — 位置情報の組み立て。\n *\n * インラインの走査は「1 行の中の部分文字列」を対象にするため、走査対象の先頭が\n * ソース上のどこかを表す Origin を持ち回り、そこからの相対インデックスで位置を作る。\n * 位置計算をここ 1 箇所に集約することで、装飾の中の再帰でオフセットがずれる事故を防ぐ。\n */\nimport type { Point, Position } from \"../types\"\n\n/** 走査対象の文字列のインデックス 0 が、ソース上のどこにあるか。 */\nexport interface Origin {\n readonly line: number\n readonly column: number\n readonly offset: number\n}\n\nexport const originOfLine = (line: number, offset: number): Origin => ({ line, column: 0, offset })\n\n/** Origin を `by` 文字ぶん進める (部分文字列を再帰的に走査するときに使う)。 */\nexport const shiftOrigin = (origin: Origin, by: number): Origin => ({\n line: origin.line,\n column: origin.column + by,\n offset: origin.offset + by,\n})\n\nexport const pointAt = (origin: Origin, index: number): Point => ({\n line: origin.line,\n column: origin.column + index,\n offset: origin.offset + index,\n})\n\n/** 走査対象の `[start, end)` が占める Position。end は exclusive。 */\nexport const spanAt = (origin: Origin, start: number, end: number): Position => ({\n start: pointAt(origin, start),\n end: pointAt(origin, end),\n})\n","import { Option } from \"effect\"\n\nimport { shiftOrigin } from \"../../core/position\"\nimport type { InlineNodeInit } from \"../../types\"\nimport type { InternalBracketRule } from \"../internal-types\"\nimport type { BracketRuleContext } from \"../types\"\n\n/** 意味を持つ文字装飾記法の記号。 */\nexport const OFFICIAL_MARKERS = \"*/-_\"\n\nconst MAX_SIZE_LEVEL = 4\n\n/** 文字クラスの中で特別扱いされる文字を潰す。 */\nconst escapeForCharClass = (chars: string): string => chars.replace(/[\\\\\\]^-]/g, \"\\\\$&\")\n\n/** 出現順を保ったまま重複を落とす。`[*** x]` の markers は `['*']` になる。 */\nconst uniqueChars = (marks: string): readonly string[] => [...new Set(marks)]\n\n/**\n * `[<記号> 中身]` を文字装飾記法として読む。`markerChars` に含まれる記号だけを受け付ける。\n *\n * 中身はリンクやアイコンとして再帰的に解釈するが、**装飾の入れ子は不可**。\n * そのため子の走査は allowDecoration=false で行う。\n * 例: `[* [* 太字]ですね]` の内側は装飾ではなく内部リンクになる。\n */\n/**\n * 文脈は拡張に渡るものと同じ形 (`BracketRuleContext`) だけを使う。\n * `customDecorations` が拡張のルールとしても使うため。\n */\nexport const buildDecorationRule = (\n markerChars: string,\n): ((inner: string, ctx: BracketRuleContext) => Option.Option<InlineNodeInit>) => {\n const pattern = new RegExp(`^([${escapeForCharClass(markerChars)}]+)\\\\s+([\\\\s\\\\S]+)$`)\n\n return (inner, ctx) => {\n if (!ctx.allowDecoration) return Option.none()\n\n const match = inner.match(pattern)\n if (!match) return Option.none()\n\n const marks = match[1] ?? \"\"\n const value = match[2] ?? \"\"\n const stars = (marks.match(/\\*/g) ?? []).length\n\n // 正規表現が末尾まで貪欲にマッチするので、中身は inner の末尾側の部分文字列になる。\n const valueOffset = inner.length - value.length\n\n return Option.some({\n type: \"decoration\",\n value,\n markers: uniqueChars(marks),\n bold: stars > 0,\n italic: marks.includes(\"/\"),\n strike: marks.includes(\"-\"),\n underline: marks.includes(\"_\"),\n sizeLevel: Math.min(Math.max(stars - 1, 0), MAX_SIZE_LEVEL),\n children: ctx.tokenize(value, shiftOrigin(ctx.innerOrigin, valueOffset), false),\n })\n }\n}\n\n/** `[* 太字]` `[/ 斜体]` `[- 打消し]` `[_ 下線]` とその複合 (`[-/ x]`)。 */\nexport const decorationRule: InternalBracketRule = buildDecorationRule(OFFICIAL_MARKERS)\n"],"mappings":";;AAgBA,MAAa,gBAAgB,MAAc,YAA4B;CAAE;CAAM,QAAQ;CAAG;AAAO;;AAGjG,MAAa,eAAe,QAAgB,QAAwB;CAClE,MAAM,OAAO;CACb,QAAQ,OAAO,SAAS;CACxB,QAAQ,OAAO,SAAS;AAC1B;AAEA,MAAa,WAAW,QAAgB,WAA0B;CAChE,MAAM,OAAO;CACb,QAAQ,OAAO,SAAS;CACxB,QAAQ,OAAO,SAAS;AAC1B;;AAGA,MAAa,UAAU,QAAgB,OAAe,SAA2B;CAC/E,OAAO,QAAQ,QAAQ,KAAK;CAC5B,KAAK,QAAQ,QAAQ,GAAG;AAC1B;;;;AC3BA,MAAa,mBAAmB;AAEhC,MAAM,iBAAiB;;AAGvB,MAAM,sBAAsB,UAA0B,MAAM,QAAQ,aAAa,MAAM;;AAGvF,MAAM,eAAe,UAAqC,CAAC,GAAG,IAAI,IAAI,KAAK,CAAC;;;;;;;;;;;;AAa5E,MAAa,uBACX,gBACgF;CAChF,MAAM,UAAU,IAAI,OAAO,MAAM,mBAAmB,WAAW,EAAE,oBAAoB;CAErF,QAAQ,OAAO,QAAQ;EACrB,IAAI,CAAC,IAAI,iBAAiB,OAAOA,OAAAA,OAAO,KAAK;EAE7C,MAAM,QAAQ,MAAM,MAAM,OAAO;EACjC,IAAI,CAAC,OAAO,OAAOA,OAAAA,OAAO,KAAK;EAE/B,MAAM,QAAQ,MAAM,MAAM;EAC1B,MAAM,QAAQ,MAAM,MAAM;EAC1B,MAAM,SAAS,MAAM,MAAM,KAAK,KAAK,CAAC,EAAA,CAAG;EAGzC,MAAM,cAAc,MAAM,SAAS,MAAM;EAEzC,OAAOA,OAAAA,OAAO,KAAK;GACjB,MAAM;GACN;GACA,SAAS,YAAY,KAAK;GAC1B,MAAM,QAAQ;GACd,QAAQ,MAAM,SAAS,GAAG;GAC1B,QAAQ,MAAM,SAAS,GAAG;GAC1B,WAAW,MAAM,SAAS,GAAG;GAC7B,WAAW,KAAK,IAAI,KAAK,IAAI,QAAQ,GAAG,CAAC,GAAG,cAAc;GAC1D,UAAU,IAAI,SAAS,OAAO,YAAY,IAAI,aAAa,WAAW,GAAG,KAAK;EAChF,CAAC;CACH;AACF;;AAGA,MAAa,iBAAsC,oBAAoB,gBAAgB"}
@@ -0,0 +1,32 @@
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
+ //#region src/extensions/table-cell-notation.ts
17
+ /**
18
+ * テーブルのセルの中でも、行と同じく記法を読む拡張。Cosense Web には無い振る舞い。
19
+ *
20
+ * 既定ではセルの中はリンクの記法だけを読み、それ以外は書いたままの文字になる (Cosense Web と同じ)。
21
+ * `types` を渡すと、リンクに加えてその型のノードだけを読む。省くとすべての記法 (拡張の記法も含む) を読む。
22
+ *
23
+ * @example
24
+ * parse(source, { extensions: [tableCellNotation()] }) // すべての記法
25
+ * parse(source, { extensions: [tableCellNotation(['decoration'])] }) // リンクと装飾だけ
26
+ */
27
+ const tableCellNotation = (types) => ({ keepInTableCell: types === void 0 ? () => true : (node) => types.includes(node.type) });
28
+ //#endregion
29
+ exports.customDecorations = customDecorations;
30
+ exports.tableCellNotation = tableCellNotation;
31
+
32
+ //# sourceMappingURL=extensions.cjs.map
@@ -0,0 +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"}
@@ -0,0 +1,26 @@
1
+ import { F as WithoutPosition, _ as InlineNodeInit, g as InlineNode } from "./types-gWMrsXPX.cjs";
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
+ //#region src/extensions/table-cell-notation.d.ts
13
+ /**
14
+ * テーブルのセルの中でも、行と同じく記法を読む拡張。Cosense Web には無い振る舞い。
15
+ *
16
+ * 既定ではセルの中はリンクの記法だけを読み、それ以外は書いたままの文字になる (Cosense Web と同じ)。
17
+ * `types` を渡すと、リンクに加えてその型のノードだけを読む。省くとすべての記法 (拡張の記法も含む) を読む。
18
+ *
19
+ * @example
20
+ * parse(source, { extensions: [tableCellNotation()] }) // すべての記法
21
+ * parse(source, { extensions: [tableCellNotation(['decoration'])] }) // リンクと装飾だけ
22
+ */
23
+ declare const tableCellNotation: (types?: readonly InlineNode["type"][]) => Extension;
24
+ //#endregion
25
+ export { type BracketRule, type BracketRuleContext, type ConstructMatch, type Extension, type InlineConstruct, type InlineContext, type InlineNodeInit, type Origin, type WithoutPosition, customDecorations, tableCellNotation };
26
+ //# sourceMappingURL=extensions.d.cts.map
@@ -0,0 +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"}
@@ -0,0 +1,26 @@
1
+ import { F as WithoutPosition, _ as InlineNodeInit, g as InlineNode } from "./types-gWMrsXPX.mjs";
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
+ //#region src/extensions/table-cell-notation.d.ts
13
+ /**
14
+ * テーブルのセルの中でも、行と同じく記法を読む拡張。Cosense Web には無い振る舞い。
15
+ *
16
+ * 既定ではセルの中はリンクの記法だけを読み、それ以外は書いたままの文字になる (Cosense Web と同じ)。
17
+ * `types` を渡すと、リンクに加えてその型のノードだけを読む。省くとすべての記法 (拡張の記法も含む) を読む。
18
+ *
19
+ * @example
20
+ * parse(source, { extensions: [tableCellNotation()] }) // すべての記法
21
+ * parse(source, { extensions: [tableCellNotation(['decoration'])] }) // リンクと装飾だけ
22
+ */
23
+ declare const tableCellNotation: (types?: readonly InlineNode["type"][]) => Extension;
24
+ //#endregion
25
+ export { type BracketRule, type BracketRuleContext, type ConstructMatch, type Extension, type InlineConstruct, type InlineContext, type InlineNodeInit, type Origin, type WithoutPosition, customDecorations, tableCellNotation };
26
+ //# sourceMappingURL=extensions.d.mts.map
@@ -0,0 +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"}
@@ -0,0 +1,30 @@
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
+ //#region src/extensions/table-cell-notation.ts
16
+ /**
17
+ * テーブルのセルの中でも、行と同じく記法を読む拡張。Cosense Web には無い振る舞い。
18
+ *
19
+ * 既定ではセルの中はリンクの記法だけを読み、それ以外は書いたままの文字になる (Cosense Web と同じ)。
20
+ * `types` を渡すと、リンクに加えてその型のノードだけを読む。省くとすべての記法 (拡張の記法も含む) を読む。
21
+ *
22
+ * @example
23
+ * parse(source, { extensions: [tableCellNotation()] }) // すべての記法
24
+ * parse(source, { extensions: [tableCellNotation(['decoration'])] }) // リンクと装飾だけ
25
+ */
26
+ const tableCellNotation = (types) => ({ keepInTableCell: types === void 0 ? () => true : (node) => types.includes(node.type) });
27
+ //#endregion
28
+ export { customDecorations, tableCellNotation };
29
+
30
+ //# sourceMappingURL=extensions.mjs.map
@@ -0,0 +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"}