@kerebron/extension-codemirror 0.3.2 → 0.4.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 (242) hide show
  1. package/README.md +3 -3
  2. package/esm/_dnt.polyfills.d.ts +101 -0
  3. package/esm/_dnt.polyfills.d.ts.map +1 -0
  4. package/esm/_dnt.polyfills.js +127 -0
  5. package/esm/_dnt.shims.d.ts +6 -0
  6. package/esm/_dnt.shims.d.ts.map +1 -0
  7. package/esm/_dnt.shims.js +61 -0
  8. package/esm/editor/src/CoreEditor.d.ts +13 -4
  9. package/esm/editor/src/CoreEditor.d.ts.map +1 -1
  10. package/esm/editor/src/CoreEditor.js +64 -12
  11. package/esm/editor/src/Extension.d.ts +6 -1
  12. package/esm/editor/src/Extension.d.ts.map +1 -1
  13. package/esm/editor/src/Extension.js +21 -1
  14. package/esm/editor/src/ExtensionManager.d.ts +5 -6
  15. package/esm/editor/src/ExtensionManager.d.ts.map +1 -1
  16. package/esm/editor/src/ExtensionManager.js +43 -55
  17. package/esm/editor/src/Mark.d.ts +3 -0
  18. package/esm/editor/src/Mark.d.ts.map +1 -1
  19. package/esm/editor/src/Mark.js +11 -0
  20. package/esm/editor/src/Node.d.ts +5 -2
  21. package/esm/editor/src/Node.d.ts.map +1 -1
  22. package/esm/editor/src/Node.js +13 -2
  23. package/esm/editor/src/commands/CommandManager.d.ts +13 -6
  24. package/esm/editor/src/commands/CommandManager.d.ts.map +1 -1
  25. package/esm/editor/src/commands/CommandManager.js +59 -2
  26. package/esm/editor/src/commands/baseCommandFactories.d.ts +3 -0
  27. package/esm/editor/src/commands/baseCommandFactories.d.ts.map +1 -0
  28. package/esm/editor/src/commands/baseCommandFactories.js +836 -0
  29. package/esm/editor/src/commands/keyCommandFactories.d.ts +3 -0
  30. package/esm/editor/src/commands/keyCommandFactories.d.ts.map +1 -0
  31. package/esm/editor/src/commands/keyCommandFactories.js +10 -0
  32. package/esm/editor/src/commands/mod.d.ts +5 -53
  33. package/esm/editor/src/commands/mod.d.ts.map +1 -1
  34. package/esm/editor/src/commands/mod.js +14 -821
  35. package/esm/editor/src/commands/replaceCommandFactories.d.ts +3 -0
  36. package/esm/editor/src/commands/replaceCommandFactories.d.ts.map +1 -0
  37. package/esm/editor/src/commands/replaceCommandFactories.js +94 -0
  38. package/esm/editor/src/commands/types.d.ts +18 -0
  39. package/esm/editor/src/commands/types.d.ts.map +1 -0
  40. package/esm/editor/src/commands/types.js +1 -0
  41. package/esm/editor/src/mod.d.ts +2 -0
  42. package/esm/editor/src/mod.d.ts.map +1 -1
  43. package/esm/editor/src/mod.js +2 -0
  44. package/esm/editor/src/plugins/TrackSelecionPlugin.d.ts +6 -0
  45. package/esm/editor/src/plugins/TrackSelecionPlugin.d.ts.map +1 -0
  46. package/esm/editor/src/plugins/TrackSelecionPlugin.js +24 -0
  47. package/esm/editor/src/types.d.ts +19 -1
  48. package/esm/editor/src/types.d.ts.map +1 -1
  49. package/esm/editor/src/ui.d.ts +15 -0
  50. package/esm/editor/src/ui.d.ts.map +1 -0
  51. package/esm/editor/src/ui.js +16 -0
  52. package/esm/editor/src/utilities/SmartOutput.d.ts +9 -7
  53. package/esm/editor/src/utilities/SmartOutput.d.ts.map +1 -1
  54. package/esm/editor/src/utilities/SmartOutput.js +35 -20
  55. package/esm/editor/src/utilities/getShadowRoot.d.ts +2 -0
  56. package/esm/editor/src/utilities/getShadowRoot.d.ts.map +1 -0
  57. package/esm/editor/src/utilities/getShadowRoot.js +16 -0
  58. package/esm/editor/src/utilities/mod.d.ts +2 -0
  59. package/esm/editor/src/utilities/mod.d.ts.map +1 -1
  60. package/esm/editor/src/utilities/mod.js +2 -0
  61. package/esm/editor/src/utilities/toRawTextResult.d.ts +3 -0
  62. package/esm/editor/src/utilities/toRawTextResult.d.ts.map +1 -0
  63. package/esm/editor/src/utilities/toRawTextResult.js +21 -0
  64. package/esm/extension-autocomplete/src/AutocompletePlugin.d.ts +8 -0
  65. package/esm/extension-autocomplete/src/AutocompletePlugin.d.ts.map +1 -0
  66. package/esm/extension-autocomplete/src/AutocompletePlugin.js +232 -0
  67. package/esm/extension-autocomplete/src/DefaultRenderer.d.ts +17 -0
  68. package/esm/extension-autocomplete/src/DefaultRenderer.d.ts.map +1 -0
  69. package/esm/extension-autocomplete/src/DefaultRenderer.js +137 -0
  70. package/esm/extension-autocomplete/src/ExtensionAutocomplete.d.ts +26 -0
  71. package/esm/extension-autocomplete/src/ExtensionAutocomplete.d.ts.map +1 -0
  72. package/esm/extension-autocomplete/src/ExtensionAutocomplete.js +30 -0
  73. package/esm/extension-autocomplete/src/createDefaultMatcher.d.ts +11 -0
  74. package/esm/extension-autocomplete/src/createDefaultMatcher.d.ts.map +1 -0
  75. package/esm/extension-autocomplete/src/createDefaultMatcher.js +58 -0
  76. package/esm/extension-autocomplete/src/createRegexMatcher.d.ts +4 -0
  77. package/esm/extension-autocomplete/src/createRegexMatcher.d.ts.map +1 -0
  78. package/esm/extension-autocomplete/src/createRegexMatcher.js +50 -0
  79. package/esm/extension-autocomplete/src/mod.d.ts +3 -0
  80. package/esm/extension-autocomplete/src/mod.d.ts.map +1 -0
  81. package/esm/extension-autocomplete/src/mod.js +2 -0
  82. package/esm/extension-autocomplete/src/types.d.ts +60 -0
  83. package/esm/extension-autocomplete/src/types.d.ts.map +1 -0
  84. package/esm/extension-autocomplete/src/types.js +1 -0
  85. package/esm/extension-basic-editor/src/ExtensionHtml.d.ts +15 -0
  86. package/esm/extension-basic-editor/src/ExtensionHtml.d.ts.map +1 -0
  87. package/esm/extension-basic-editor/src/ExtensionHtml.js +108 -0
  88. package/esm/extension-basic-editor/src/NodeCodeBlock.d.ts +9 -0
  89. package/esm/extension-basic-editor/src/NodeCodeBlock.d.ts.map +1 -0
  90. package/esm/extension-basic-editor/src/NodeCodeBlock.js +58 -0
  91. package/esm/extension-basic-editor/src/remote-selection/ExtensionRemoteSelection.d.ts +24 -0
  92. package/esm/extension-basic-editor/src/remote-selection/ExtensionRemoteSelection.d.ts.map +1 -0
  93. package/esm/extension-basic-editor/src/remote-selection/ExtensionRemoteSelection.js +35 -0
  94. package/esm/extension-basic-editor/src/remote-selection/remoteSelectionPlugin.d.ts +25 -0
  95. package/esm/extension-basic-editor/src/remote-selection/remoteSelectionPlugin.d.ts.map +1 -0
  96. package/esm/extension-basic-editor/src/remote-selection/remoteSelectionPlugin.js +96 -0
  97. package/esm/extension-codemirror/src/ExtensionCodeMirror.d.ts +15 -2
  98. package/esm/extension-codemirror/src/ExtensionCodeMirror.d.ts.map +1 -1
  99. package/esm/extension-codemirror/src/ExtensionCodeMirror.js +74 -2
  100. package/esm/extension-codemirror/src/NodeCodeMirror.d.ts +13 -9
  101. package/esm/extension-codemirror/src/NodeCodeMirror.d.ts.map +1 -1
  102. package/esm/extension-codemirror/src/NodeCodeMirror.js +34 -122
  103. package/esm/extension-codemirror/src/codeMirrorBlockNodeView.d.ts +3 -3
  104. package/esm/extension-codemirror/src/codeMirrorBlockNodeView.d.ts.map +1 -1
  105. package/esm/extension-codemirror/src/codeMirrorBlockNodeView.js +155 -107
  106. package/esm/extension-codemirror/src/defaults.d.ts +1 -1
  107. package/esm/extension-codemirror/src/defaults.d.ts.map +1 -1
  108. package/esm/extension-codemirror/src/defaults.js +4 -3
  109. package/esm/extension-codemirror/src/languageLoaders.d.ts.map +1 -1
  110. package/esm/extension-codemirror/src/languageLoaders.js +1 -2
  111. package/esm/extension-codemirror/src/lsp/LSPExtension.d.ts +14 -0
  112. package/esm/extension-codemirror/src/lsp/LSPExtension.d.ts.map +1 -0
  113. package/esm/extension-codemirror/src/lsp/LSPExtension.js +38 -0
  114. package/esm/extension-codemirror/src/lsp/completion.d.ts +8 -0
  115. package/esm/extension-codemirror/src/lsp/completion.d.ts.map +1 -0
  116. package/esm/extension-codemirror/src/lsp/completion.js +179 -0
  117. package/esm/extension-codemirror/src/lsp/hover.d.ts +5 -0
  118. package/esm/extension-codemirror/src/lsp/hover.d.ts.map +1 -0
  119. package/esm/extension-codemirror/src/lsp/hover.js +81 -0
  120. package/esm/extension-codemirror/src/lsp/index.d.ts +7 -0
  121. package/esm/extension-codemirror/src/lsp/index.d.ts.map +1 -0
  122. package/esm/extension-codemirror/src/lsp/index.js +49 -0
  123. package/esm/extension-codemirror/src/lsp/plugin.d.ts +37 -0
  124. package/esm/extension-codemirror/src/lsp/plugin.d.ts.map +1 -0
  125. package/esm/extension-codemirror/src/lsp/plugin.js +125 -0
  126. package/esm/extension-codemirror/src/lsp/pos.d.ts +5 -0
  127. package/esm/extension-codemirror/src/lsp/pos.d.ts.map +1 -0
  128. package/esm/extension-codemirror/src/lsp/pos.js +8 -0
  129. package/esm/extension-codemirror/src/lsp/text.d.ts +2 -0
  130. package/esm/extension-codemirror/src/lsp/text.d.ts.map +1 -0
  131. package/esm/extension-codemirror/src/lsp/text.js +47 -0
  132. package/esm/extension-codemirror/src/lsp/theme.d.ts +2 -0
  133. package/esm/extension-codemirror/src/lsp/theme.d.ts.map +1 -0
  134. package/esm/extension-codemirror/src/lsp/theme.js +76 -0
  135. package/esm/extension-codemirror/src/{y-remote-selections.d.ts → remote-selections.d.ts} +5 -5
  136. package/esm/extension-codemirror/src/remote-selections.d.ts.map +1 -0
  137. package/esm/extension-codemirror/src/{y-remote-selections.js → remote-selections.js} +49 -69
  138. package/esm/extension-codemirror/src/remote-sync.d.ts +11 -0
  139. package/esm/extension-codemirror/src/remote-sync.d.ts.map +1 -0
  140. package/esm/extension-codemirror/src/{y-sync.js → remote-sync.js} +6 -6
  141. package/esm/extension-codemirror/src/types.d.ts +10 -10
  142. package/esm/extension-codemirror/src/types.d.ts.map +1 -1
  143. package/esm/extension-codemirror/src/utils.d.ts +7 -6
  144. package/esm/extension-codemirror/src/utils.d.ts.map +1 -1
  145. package/esm/extension-codemirror/src/utils.js +21 -10
  146. package/esm/extension-lsp/src/DiagnosticPlugin.d.ts +32 -0
  147. package/esm/extension-lsp/src/DiagnosticPlugin.d.ts.map +1 -0
  148. package/esm/extension-lsp/src/DiagnosticPlugin.js +131 -0
  149. package/esm/extension-lsp/src/ExtensionLsp.d.ts +25 -0
  150. package/esm/extension-lsp/src/ExtensionLsp.d.ts.map +1 -0
  151. package/esm/extension-lsp/src/ExtensionLsp.js +126 -0
  152. package/esm/extension-lsp/src/LSPClient.d.ts +56 -0
  153. package/esm/extension-lsp/src/LSPClient.d.ts.map +1 -0
  154. package/esm/extension-lsp/src/LSPClient.js +449 -0
  155. package/esm/extension-lsp/src/computeIncrementalChanges.d.ts +8 -0
  156. package/esm/extension-lsp/src/computeIncrementalChanges.d.ts.map +1 -0
  157. package/esm/extension-lsp/src/computeIncrementalChanges.js +82 -0
  158. package/esm/extension-lsp/src/createLspAutocomplete.d.ts +23 -0
  159. package/esm/extension-lsp/src/createLspAutocomplete.d.ts.map +1 -0
  160. package/esm/extension-lsp/src/createLspAutocomplete.js +68 -0
  161. package/esm/extension-lsp/src/mod.d.ts +4 -0
  162. package/esm/extension-lsp/src/mod.d.ts.map +1 -0
  163. package/esm/extension-lsp/src/mod.js +3 -0
  164. package/esm/extension-lsp/src/workspace.d.ts +62 -0
  165. package/esm/extension-lsp/src/workspace.d.ts.map +1 -0
  166. package/esm/extension-lsp/src/workspace.js +168 -0
  167. package/esm/extension-markdown/src/DocumentMarkdownInlineTokenizer.d.ts +36 -0
  168. package/esm/extension-markdown/src/DocumentMarkdownInlineTokenizer.d.ts.map +1 -0
  169. package/esm/extension-markdown/src/DocumentMarkdownInlineTokenizer.js +240 -0
  170. package/esm/extension-markdown/src/DocumentMarkdownTokenizer.d.ts +26 -0
  171. package/esm/extension-markdown/src/DocumentMarkdownTokenizer.d.ts.map +1 -0
  172. package/esm/extension-markdown/src/DocumentMarkdownTokenizer.js +115 -0
  173. package/esm/extension-markdown/src/ExtensionMarkdown.d.ts +22 -0
  174. package/esm/extension-markdown/src/ExtensionMarkdown.d.ts.map +1 -0
  175. package/esm/extension-markdown/src/ExtensionMarkdown.js +48 -0
  176. package/esm/extension-markdown/src/MarkdownParser.d.ts +61 -0
  177. package/esm/extension-markdown/src/MarkdownParser.d.ts.map +1 -0
  178. package/esm/extension-markdown/src/MarkdownParser.js +249 -0
  179. package/esm/extension-markdown/src/MarkdownSerializer.d.ts +42 -0
  180. package/esm/extension-markdown/src/MarkdownSerializer.d.ts.map +1 -0
  181. package/esm/extension-markdown/src/MarkdownSerializer.js +325 -0
  182. package/esm/extension-markdown/src/PositionMapper.d.ts +15 -0
  183. package/esm/extension-markdown/src/PositionMapper.d.ts.map +1 -0
  184. package/esm/extension-markdown/src/PositionMapper.js +100 -0
  185. package/esm/extension-markdown/src/TokenSource.d.ts +11 -0
  186. package/esm/extension-markdown/src/TokenSource.d.ts.map +1 -0
  187. package/esm/extension-markdown/src/TokenSource.js +39 -0
  188. package/esm/extension-markdown/src/mdToPmConverter.d.ts +5 -0
  189. package/esm/extension-markdown/src/mdToPmConverter.d.ts.map +1 -0
  190. package/esm/extension-markdown/src/mdToPmConverter.js +111 -0
  191. package/esm/extension-markdown/src/pmToMdConverter.d.ts +16 -0
  192. package/esm/extension-markdown/src/pmToMdConverter.d.ts.map +1 -0
  193. package/esm/extension-markdown/src/pmToMdConverter.js +433 -0
  194. package/esm/extension-markdown/src/token_handlers/basic_token_handlers.d.ts +4 -0
  195. package/esm/extension-markdown/src/token_handlers/basic_token_handlers.d.ts.map +1 -0
  196. package/esm/extension-markdown/src/token_handlers/basic_token_handlers.js +151 -0
  197. package/esm/extension-markdown/src/token_handlers/footnote_token_handlers.d.ts +3 -0
  198. package/esm/extension-markdown/src/token_handlers/footnote_token_handlers.d.ts.map +1 -0
  199. package/esm/extension-markdown/src/token_handlers/footnote_token_handlers.js +34 -0
  200. package/esm/extension-markdown/src/token_handlers/inline_token_handlers.d.ts +6 -0
  201. package/esm/extension-markdown/src/token_handlers/inline_token_handlers.d.ts.map +1 -0
  202. package/esm/extension-markdown/src/token_handlers/inline_token_handlers.js +380 -0
  203. package/esm/extension-markdown/src/token_handlers/lists_token_handlers.d.ts +3 -0
  204. package/esm/extension-markdown/src/token_handlers/lists_token_handlers.d.ts.map +1 -0
  205. package/esm/extension-markdown/src/token_handlers/lists_token_handlers.js +323 -0
  206. package/esm/extension-markdown/src/token_handlers/table_token_handlers.d.ts +9 -0
  207. package/esm/extension-markdown/src/token_handlers/table_token_handlers.d.ts.map +1 -0
  208. package/esm/extension-markdown/src/token_handlers/table_token_handlers.js +308 -0
  209. package/esm/extension-markdown/src/treeSitterTokenizer.d.ts +5 -0
  210. package/esm/extension-markdown/src/treeSitterTokenizer.d.ts.map +1 -0
  211. package/esm/extension-markdown/src/treeSitterTokenizer.js +769 -0
  212. package/esm/extension-markdown/src/types.d.ts +28 -0
  213. package/esm/extension-markdown/src/types.d.ts.map +1 -0
  214. package/esm/extension-markdown/src/types.js +131 -0
  215. package/esm/extension-markdown/src/utils.d.ts +8 -0
  216. package/esm/extension-markdown/src/utils.d.ts.map +1 -0
  217. package/esm/extension-markdown/src/utils.js +86 -0
  218. package/esm/tree-sitter-shim/src/main.d.ts +15 -0
  219. package/esm/tree-sitter-shim/src/main.d.ts.map +1 -0
  220. package/esm/tree-sitter-shim/src/main.js +25 -0
  221. package/esm/tree-sitter-shim/src/tree_sitter/node.d.ts +6 -0
  222. package/esm/tree-sitter-shim/src/tree_sitter/node.d.ts.map +1 -0
  223. package/esm/tree-sitter-shim/src/tree_sitter/node.js +1 -0
  224. package/esm/tree-sitter-shim/src/tree_sitter/parser.d.ts +7 -0
  225. package/esm/tree-sitter-shim/src/tree_sitter/parser.d.ts.map +1 -0
  226. package/esm/tree-sitter-shim/src/tree_sitter/parser.js +5 -0
  227. package/esm/tree-sitter-shim/src/tree_sitter/tree.d.ts +6 -0
  228. package/esm/tree-sitter-shim/src/tree_sitter/tree.d.ts.map +1 -0
  229. package/esm/tree-sitter-shim/src/tree_sitter/tree.js +1 -0
  230. package/esm/wasm/src/mod.d.ts +12 -0
  231. package/esm/wasm/src/mod.d.ts.map +1 -0
  232. package/esm/wasm/src/mod.js +48 -0
  233. package/esm/wasm/wasm.d.ts +138 -0
  234. package/esm/wasm/wasm.d.ts.map +1 -0
  235. package/esm/wasm/wasm.js +120 -0
  236. package/package.json +5 -25
  237. package/esm/extension-codemirror/src/NodeDocumentCode.d.ts +0 -7
  238. package/esm/extension-codemirror/src/NodeDocumentCode.d.ts.map +0 -1
  239. package/esm/extension-codemirror/src/NodeDocumentCode.js +0 -37
  240. package/esm/extension-codemirror/src/y-remote-selections.d.ts.map +0 -1
  241. package/esm/extension-codemirror/src/y-sync.d.ts +0 -11
  242. package/esm/extension-codemirror/src/y-sync.d.ts.map +0 -1
@@ -0,0 +1,380 @@
1
+ export function escapeMarkdown(token) {
2
+ const markdownChars = [
3
+ { char: '\\', escape: '\\\\' },
4
+ // { char: '*', escape: '\\*' },
5
+ // { char: '_', escape: '\\_' },
6
+ { char: '#', escape: '\\#' },
7
+ // { char: '[', escape: '\\[' },
8
+ // { char: ']', escape: '\\]' },
9
+ // { char: '(', escape: '\\(' },
10
+ // { char: ')', escape: '\\)' },
11
+ // { char: '`', escape: '\\`' },
12
+ // { char: '>', escape: '\\>' },
13
+ { char: '<', escape: '\\<' },
14
+ // { char: '.', escape: '\\.' },
15
+ // { char: '!', escape: '\\!' },
16
+ // { char: '|', escape: '\\|' },
17
+ // { char: '{', escape: '\\{' },
18
+ // { char: '}', escape: '\\}' },
19
+ { char: '…', escape: '...' },
20
+ { char: '©', escape: '(c)' },
21
+ { char: '®', escape: '(r)' },
22
+ { char: '™', escape: '(tm)' },
23
+ { char: '±', escape: '+-' },
24
+ { char: '—', escape: '---' },
25
+ ];
26
+ const startPos = token.map && token.map.length > 0 ? token.map[0] : 0;
27
+ if (!startPos) {
28
+ let escapedText = token.content;
29
+ for (const { char, escape } of markdownChars) {
30
+ escapedText = escapedText.replaceAll(char, escape);
31
+ }
32
+ return [[escapedText, token]];
33
+ }
34
+ const charArr = token.content.split('');
35
+ const retVal = [];
36
+ const markdownCharsMap = Object.fromEntries(markdownChars.map((c) => [c.char, c.escape]));
37
+ let offset = 0;
38
+ let inStr = '';
39
+ let currentOutStr = '';
40
+ const flush = () => {
41
+ if (currentOutStr.length > 0) {
42
+ const tok = structuredClone(token);
43
+ tok.map = [startPos + offset];
44
+ retVal.push([
45
+ currentOutStr,
46
+ tok,
47
+ ]);
48
+ offset = inStr.length;
49
+ }
50
+ currentOutStr = '';
51
+ };
52
+ for (let idx = 0; idx < charArr.length; idx++) {
53
+ const char = charArr[idx];
54
+ inStr += char;
55
+ if (markdownCharsMap[char]) {
56
+ flush();
57
+ }
58
+ currentOutStr += markdownCharsMap[char] || char;
59
+ if (markdownCharsMap[char]) {
60
+ flush();
61
+ }
62
+ }
63
+ flush();
64
+ return retVal;
65
+ }
66
+ function getLinkTokensHandlers() {
67
+ return {
68
+ 'text': [
69
+ (token, ctx) => {
70
+ ctx.current.meta['link_text'] += token.content;
71
+ if (token.content && !ctx.current.meta['link_token_token']) {
72
+ ctx.current.meta['link_token_token'] = token;
73
+ }
74
+ },
75
+ ],
76
+ 'link_close': [
77
+ (token, ctx) => {
78
+ {
79
+ const lastStackToken = ctx.current.meta['link_open_token'];
80
+ const href = lastStackToken.attrGet('href') || '';
81
+ const title = lastStackToken.attrGet('title') || '';
82
+ if (!title && ctx.current.meta['link_text'] === href) {
83
+ ctx.current.log(href, token);
84
+ }
85
+ else if (!title && !href) {
86
+ ctx.current.log('[', token);
87
+ ctx.current.log(ctx.current.meta['link_text'], ctx.current.meta['link_token_token']);
88
+ ctx.current.log(`]${title}`, token);
89
+ }
90
+ else {
91
+ ctx.current.log('[', token);
92
+ ctx.current.log(ctx.current.meta['link_text'], ctx.current.meta['link_token_token']);
93
+ if (title) {
94
+ ctx.current.log(`](${href} ${title})`, token);
95
+ }
96
+ else {
97
+ ctx.current.log(`](${href})`, token);
98
+ }
99
+ }
100
+ ctx.unstash('getLinkTokensHandlers.link_close');
101
+ }
102
+ },
103
+ ],
104
+ default: [
105
+ (token, ctx) => {
106
+ // Ignore other stuff
107
+ // TODO: images?
108
+ },
109
+ ],
110
+ };
111
+ }
112
+ export function getInlineTokensHandlers() {
113
+ return {
114
+ 'text': [
115
+ (token, ctx) => {
116
+ if (token.meta === 'noEscText') {
117
+ for (const pair of escapeMarkdown(token)) {
118
+ ctx.current.log(token.content);
119
+ }
120
+ }
121
+ else {
122
+ for (const pair of escapeMarkdown(token)) {
123
+ ctx.current.log(pair[0], pair[1]);
124
+ }
125
+ }
126
+ },
127
+ ],
128
+ 'strong_open': [
129
+ (token, ctx) => {
130
+ ctx.current.log(token.markup || '**', token);
131
+ },
132
+ ],
133
+ 'strong_close': [
134
+ (token, ctx) => {
135
+ ctx.current.log(token.markup || '**', token);
136
+ },
137
+ ],
138
+ 'em_open': [
139
+ (token, ctx) => {
140
+ ctx.current.log(token.markup || '*', token);
141
+ },
142
+ ],
143
+ 'em_close': [
144
+ (token, ctx) => {
145
+ ctx.current.log(token.markup || '*', token);
146
+ },
147
+ ],
148
+ 'underline_open': [
149
+ (token, ctx) => {
150
+ ctx.current.log(token.markup || '_', token);
151
+ },
152
+ ],
153
+ 'underline_close': [
154
+ (token, ctx) => {
155
+ ctx.current.log(token.markup || '_', token);
156
+ },
157
+ ],
158
+ 'strike_open': [
159
+ (token, ctx) => {
160
+ ctx.current.log(token.markup || '~', token);
161
+ },
162
+ ],
163
+ 'strike_close': [
164
+ (token, ctx) => {
165
+ ctx.current.log(token.markup || '~', token);
166
+ },
167
+ ],
168
+ 'link_open': [
169
+ (token, ctx) => {
170
+ ctx.stash('getInlineTokensHandlers.link_open');
171
+ ctx.current.handlers = getLinkTokensHandlers();
172
+ ctx.current.meta['link_open_token'] = token;
173
+ ctx.current.meta['link_text'] = '';
174
+ ctx.current.meta['link_token_token'] = null;
175
+ },
176
+ ],
177
+ 'code_open': [
178
+ (token, ctx) => {
179
+ ctx.current.log('`', token);
180
+ },
181
+ ],
182
+ 'code_close': [
183
+ (token, ctx) => {
184
+ ctx.current.log('`', token);
185
+ },
186
+ ],
187
+ 'code_inline': [
188
+ (token, ctx) => {
189
+ ctx.current.log('`' + token.content + '`', token);
190
+ },
191
+ ],
192
+ 'math': [
193
+ (token, ctx) => {
194
+ ctx.current.log('$' + token.content + '$', token);
195
+ },
196
+ ],
197
+ 'hardbreak': [
198
+ (token, ctx) => {
199
+ ctx.current.log('\n', token);
200
+ },
201
+ ],
202
+ 'softbreak': [
203
+ (token, ctx) => {
204
+ ctx.current.log('\n', token);
205
+ },
206
+ ],
207
+ 'image': [
208
+ (token, ctx) => {
209
+ {
210
+ const src = token.attrGet('src');
211
+ const altAttr = token.attrGet('alt');
212
+ let alt = altAttr || '';
213
+ if (token.children) {
214
+ for (const child of token.children) {
215
+ if (child.type === 'text') {
216
+ alt += child.content;
217
+ }
218
+ }
219
+ }
220
+ ctx.current.log(`![${alt}]`, token);
221
+ // ctx.current.log(
222
+ // `(${src})`,
223
+ // token,
224
+ // );
225
+ const title = token.attrGet('title');
226
+ if (src) {
227
+ ctx.current.log(`(${src}${title ? ' ' + title : ''})`, token);
228
+ }
229
+ }
230
+ },
231
+ ],
232
+ 'html_block': [
233
+ (token, ctx) => {
234
+ ctx.current.log(token.content, token);
235
+ },
236
+ ],
237
+ 'footnote_ref': [
238
+ (token, ctx) => {
239
+ if (token.meta.label) {
240
+ ctx.current.log(`[^${token.meta.label}]`, token);
241
+ }
242
+ else {
243
+ ctx.current.log(`[^footnote_${token.meta.id}]`, token);
244
+ }
245
+ },
246
+ ],
247
+ };
248
+ }
249
+ function escapeHtml(text) {
250
+ return text; // TODO
251
+ }
252
+ export function getHtmlInlineTokensHandlers() {
253
+ return {
254
+ 'text': [
255
+ (token, ctx) => {
256
+ ctx.current.log(escapeHtml(token.content), token);
257
+ },
258
+ ],
259
+ 'strong_open': [
260
+ (token, ctx) => {
261
+ const tag = token.tag || 'strong';
262
+ ctx.current.log(`<${tag}>`, token);
263
+ },
264
+ ],
265
+ 'strong_close': [
266
+ (token, ctx) => {
267
+ const tag = token.tag || 'strong';
268
+ ctx.current.log(`</${tag}>`, token);
269
+ },
270
+ ],
271
+ 'em_open': [
272
+ (token, ctx) => {
273
+ const tag = token.tag || 'em';
274
+ ctx.current.log(`<${tag}>`, token);
275
+ },
276
+ ],
277
+ 'em_close': [
278
+ (token, ctx) => {
279
+ const tag = token.tag || 'em';
280
+ ctx.current.log(`</${tag}>`, token);
281
+ },
282
+ ],
283
+ 'strike_open': [
284
+ (token, ctx) => {
285
+ const tag = token.tag || 'strike';
286
+ ctx.current.log(`<${tag}>`, token);
287
+ },
288
+ ],
289
+ 'strike_close': [
290
+ (token, ctx) => {
291
+ const tag = token.tag || 'strike';
292
+ ctx.current.log(`</${tag}>`, token);
293
+ },
294
+ ],
295
+ 'link_open': [
296
+ (token, ctx) => {
297
+ ctx.stash('getHtmlInlineTokensHandlers.link_open');
298
+ const href = token.attrGet('href') || '';
299
+ const titleValue = token.attrGet('title');
300
+ const title = titleValue ? ' "' + titleValue + '"' : '';
301
+ ctx.current.log(`<a href="${href}">`, token);
302
+ },
303
+ ],
304
+ 'link_close': [
305
+ (token, ctx) => {
306
+ {
307
+ ctx.current.log('</a>', token);
308
+ ctx.unstash('getHtmlInlineTokensHandlers.link_close');
309
+ }
310
+ },
311
+ ],
312
+ 'code_open': [
313
+ (token, ctx) => {
314
+ const tag = token.tag || 'code';
315
+ ctx.current.log(`<${tag}>`, token);
316
+ },
317
+ ],
318
+ 'code_close': [
319
+ (token, ctx) => {
320
+ const tag = token.tag || 'code';
321
+ ctx.current.log(`<${tag}>`, token);
322
+ },
323
+ ],
324
+ // 'code_inline': [
325
+ // (token: Token, ctx: ContextStash) => {
326
+ // const tag = token.tag || 'code';
327
+ // ctx.current.log(`<${tag}>`, token);
328
+ // ctx.current.log(token.content || '', token);
329
+ // ctx.current.log(`</${tag}>`, token);
330
+ // },
331
+ // ],
332
+ 'hardbreak': [
333
+ (token, ctx) => {
334
+ const tag = token.tag || 'br';
335
+ ctx.current.log(`<${tag} />`, token);
336
+ },
337
+ ],
338
+ 'softbreak': [
339
+ (token, ctx) => {
340
+ const tag = token.tag || 'br';
341
+ ctx.current.log(`<${tag} />`, token);
342
+ },
343
+ ],
344
+ 'image': [
345
+ (token, ctx) => {
346
+ {
347
+ // const src = token.attrGet('src');
348
+ // const alt = token.attrGet('alt');
349
+ let alt = '';
350
+ if (token.children) {
351
+ for (const child of token.children) {
352
+ if (child.type === 'text') {
353
+ alt += child.content;
354
+ }
355
+ }
356
+ }
357
+ // const title = token.attrGet('title');
358
+ // ctx.current.log(`![${alt}]`, token);
359
+ // if (src) {
360
+ // ctx.current.log(
361
+ // `(${src}${title ? ' "' + title + '"' : ''})`, token
362
+ // );
363
+ // }
364
+ // TODO
365
+ const tag = token.tag || 'img';
366
+ ctx.current.log(`<${tag} />`, token);
367
+ }
368
+ },
369
+ ],
370
+ 'html_block': [
371
+ (token, ctx) => {
372
+ ctx.current.log(token.content, token);
373
+ },
374
+ ],
375
+ 'footnote_ref': [
376
+ (token, ctx) => {
377
+ },
378
+ ],
379
+ };
380
+ }
@@ -0,0 +1,3 @@
1
+ import { type TokenHandler } from '../MarkdownSerializer.js';
2
+ export declare function getListsTokensHandlers(): Record<string, Array<TokenHandler>>;
3
+ //# sourceMappingURL=lists_token_handlers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lists_token_handlers.d.ts","sourceRoot":"","sources":["../../../../src/extension-markdown/src/token_handlers/lists_token_handlers.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,YAAY,EAElB,MAAM,0BAA0B,CAAC;AA2NlC,wBAAgB,sBAAsB,IAAI,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,CAmK5E"}