@linloir/limr 0.1.0 → 1.0.0

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 (80) hide show
  1. package/README.en.md +123 -0
  2. package/README.md +63 -138
  3. package/dist/base.css +10 -7
  4. package/dist/{chunk-65V5OZ4G.js → chunk-3ILUZKDB.js} +77 -17
  5. package/dist/chunk-3ILUZKDB.js.map +1 -0
  6. package/dist/{chunk-ETHLPBKQ.js → chunk-N77VD2YR.js} +96 -51
  7. package/dist/chunk-N77VD2YR.js.map +1 -0
  8. package/dist/{chunk-7JF5HHVF.js → chunk-TTISGBST.js} +14 -1
  9. package/dist/{chunk-7JF5HHVF.js.map → chunk-TTISGBST.js.map} +1 -1
  10. package/dist/core/index.d.ts +6 -3
  11. package/dist/core/index.js +3 -1
  12. package/dist/extensions/index.d.ts +2 -2
  13. package/dist/extensions/index.js +2 -2
  14. package/dist/index.d.ts +2 -2
  15. package/dist/index.js +7 -3
  16. package/dist/react/index.d.ts +4 -3
  17. package/dist/react/index.js +5 -3
  18. package/dist/styles.css +10 -7
  19. package/dist/{translations-BliabrPd.d.ts → translations-DHnYMg4h.d.ts} +11 -3
  20. package/docs/README.md +13 -0
  21. package/docs/api.md +5 -158
  22. package/docs/assets/rendered.svg +9 -0
  23. package/docs/assets/source.svg +9 -0
  24. package/docs/en/README.md +26 -0
  25. package/docs/en/ai-skills.md +57 -0
  26. package/docs/en/annotations.md +84 -0
  27. package/docs/en/api.md +107 -0
  28. package/docs/en/architecture.md +33 -0
  29. package/docs/en/extensions.md +159 -0
  30. package/docs/en/getting-started.md +67 -0
  31. package/docs/en/integration.md +130 -0
  32. package/docs/en/modules.md +80 -0
  33. package/docs/en/performance.md +53 -0
  34. package/docs/en/plugin-packages.md +68 -0
  35. package/docs/en/styles.md +80 -0
  36. package/docs/en/syntax.md +352 -0
  37. package/docs/extensions.md +5 -306
  38. package/docs/implementation.md +5 -76
  39. package/docs/performance.md +5 -81
  40. package/docs/screenshots/blocks.png +0 -0
  41. package/docs/screenshots/dark.png +0 -0
  42. package/docs/screenshots/desktop.png +0 -0
  43. package/docs/screenshots/plugin-mobile.png +0 -0
  44. package/docs/styles.md +5 -100
  45. package/docs/visual-upgrade.md +5 -145
  46. package/docs/zh-CN/README.md +26 -0
  47. package/docs/zh-CN/ai-skills.md +57 -0
  48. package/docs/zh-CN/annotations.md +84 -0
  49. package/docs/zh-CN/api.md +107 -0
  50. package/docs/zh-CN/architecture.md +33 -0
  51. package/docs/zh-CN/extensions.md +159 -0
  52. package/docs/zh-CN/getting-started.md +67 -0
  53. package/docs/zh-CN/integration.md +130 -0
  54. package/docs/zh-CN/modules.md +80 -0
  55. package/docs/zh-CN/performance.md +53 -0
  56. package/docs/zh-CN/plugin-packages.md +68 -0
  57. package/docs/zh-CN/styles.md +80 -0
  58. package/docs/zh-CN/syntax.md +352 -0
  59. package/examples/notes.tsx +18 -11
  60. package/examples/packages/paper-theme/index.css +25 -0
  61. package/examples/packages/paper-theme/package.json +7 -0
  62. package/examples/packages/reading-tools/index.d.ts +2 -0
  63. package/examples/packages/reading-tools/index.js +25 -0
  64. package/examples/packages/reading-tools/package.json +16 -0
  65. package/package.json +9 -5
  66. package/skills/limr-plugin-development/SKILL.md +22 -0
  67. package/skills/limr-plugin-development/agents/openai.yaml +4 -0
  68. package/skills/limr-plugin-development/assets/plugin-template/README.md +30 -0
  69. package/skills/limr-plugin-development/assets/plugin-template/package.json +36 -0
  70. package/skills/limr-plugin-development/assets/plugin-template/src/index.tsx +50 -0
  71. package/skills/limr-plugin-development/assets/plugin-template/src/styles.css +9 -0
  72. package/skills/limr-plugin-development/assets/plugin-template/tsconfig.json +20 -0
  73. package/skills/limr-plugin-development/assets/plugin-template/tsup.config.ts +8 -0
  74. package/skills/limr-plugin-development/references/contract.md +45 -0
  75. package/skills/limr-use/SKILL.md +23 -0
  76. package/skills/limr-use/agents/openai.yaml +4 -0
  77. package/skills/limr-use/references/integration.md +41 -0
  78. package/skills/limr-use/references/syntax.md +17 -0
  79. package/dist/chunk-65V5OZ4G.js.map +0 -1
  80. package/dist/chunk-ETHLPBKQ.js.map +0 -1
@@ -0,0 +1,352 @@
1
+ # Default syntax
2
+
3
+ > Reading note: this page uses LiMR syntax and interactive examples. Some content cannot be fully displayed by ordinary Markdown viewers such as GitHub; visit the [GitHub Pages documentation](https://linloir.github.io/LiMR/#/docs/en/syntax) for the best reading experience.
4
+
5
+ [Documentation](README.md) · [简体中文](../zh-CN/syntax.md)
6
+
7
+ **Modules** are configuration objects that add capabilities such as formulas, videos, or citations. A factory is called in application code to return an object; the module name is its `name` property, used for replacement and removal; tags and directives are the syntax written in Markdown. See [built-in modules](modules.md) for concepts and configuration.
8
+
9
+ The ten modules below ship with `@linloir/limr`. `Reader`, standalone `Markdown`, and `DocumentProvider` enable all of them through `standard()` by default; core-only `createDocument()` starts with CommonMark. The following sections include source and rendered examples, using LiMR itself.
10
+
11
+ ## Module catalog
12
+
13
+ | Factory (application code) | Module name (name) | Capability | Registered tags / directives |
14
+ | --- | --- | --- | --- |
15
+ | `gfm()` | `gfm` | Tables, strikethrough, tasks, autolinks, standard footnotes | None |
16
+ | `math()` | `math` | Inline and display math | `$…$`, `$$…$$` |
17
+ | `codeHighlight()` | `code-highlight` | Shiki fenced-code highlighting | Standard code fences |
18
+ | `definition()` | `definition` | Definitions | Tags: definition, title, content; directive: definition |
19
+ | `question()` | `question` | Exercises and answers | question and child tags below; directive: question |
20
+ | `extras()` | `extras` | Further reading | Tags: extras, extra; directive: extras |
21
+ | `video()` | `video` | Native video, YouTube, Bilibili | Tags: video, md-video; directive: video |
22
+ | `figures()` | `figures` | Figure groups and captions | Tags: figures, figure, figcaption, caption, img; directives: figures, figure, figcaption |
23
+ | `citation()` | `citation` | Reference definitions and markers | Tags: citation, ref; no directives |
24
+ | `translations()` | `translations` | Original, translated, and parallel text | Tags and directives: translations, origin, translation |
25
+
26
+ These are registered static tags in Markdown, not an arbitrary MDX/HTML execution environment. Use string attributes such as `multi="true"` and `answer="[0,2]"`. Do not use `answer={[0,2]}`, event functions, or spread attributes. Unregistered HTML is displayed as text; expressions are not executed and may produce diagnostics. Keep blank lines between block tags and their Markdown content.
27
+
28
+ ## CommonMark and GFM
29
+
30
+ ````markdown
31
+ # Heading
32
+
33
+ **Bold**, *italic*, ~~deleted~~, [link](https://example.com), `inline code`.
34
+
35
+ > A blockquote, labelled Note by the default renderer.
36
+
37
+ - A list item
38
+ - [x] Complete
39
+ - [ ] Pending
40
+
41
+ | Name | Description |
42
+ | --- | --- |
43
+ | LiMR | Markdown renderer |
44
+
45
+ ```typescript
46
+ const value = 42;
47
+ ```
48
+
49
+ A standard footnote[^note].
50
+
51
+ [^note]: Content at the end of the document.
52
+ ````
53
+
54
+ Rendered result (interactive where applicable):
55
+
56
+ #### Example heading
57
+
58
+ **Bold**, *italic*, ~~deleted~~, [link](https://example.com), `inline code`.
59
+
60
+ > A blockquote, labelled Note by the default renderer.
61
+
62
+ - A list item
63
+ - [x] Complete
64
+ - [ ] Pending
65
+
66
+ | Name | Description |
67
+ | --- | --- |
68
+ | LiMR | Markdown renderer |
69
+
70
+ ```typescript
71
+ const value = 42;
72
+ ```
73
+
74
+ A standard footnote[^syntax-note].
75
+
76
+ [^syntax-note]: Content at the end of the document.
77
+
78
+ Standard `[^note]` footnotes appear at the end; `<ref>` opens an annotation card. Ordinary Markdown supports `![Description](/image.png)`. Raw HTML is not passed through to the DOM. Register an extension or override `components` to customize rendering.
79
+
80
+ ## Math and code
81
+
82
+ ```markdown
83
+ Inline: $E = mc^2$.
84
+
85
+ $$
86
+ \int_0^1 x^2\,dx = \frac{1}{3}
87
+ $$
88
+ ```
89
+
90
+ Rendered result (interactive where applicable):
91
+
92
+ Inline: $E = mc^2$.
93
+
94
+ $$
95
+ \int_0^1 x^2\,dx = \frac{1}{3}
96
+ $$
97
+
98
+ Import `@linloir/limr/math.css`. Configure formulas with `math({ macros, strict })`. Fenced language names select Shiki highlighting. Highlighting loads near the viewport; streaming code waits for a 180ms pause. Code over the default 100,000-character limit, unsupported languages, and languages outside the configured list retain readable source. Configure `codeHighlight({ languages, lightTheme, darkTheme, eager, maxLength })`.
99
+
100
+ ## Definitions
101
+
102
+ ```markdown
103
+ <definition title="Entropy">
104
+
105
+ A measure of uncertainty: $H(X)$.
106
+
107
+ </definition>
108
+ ```
109
+
110
+ Rendered result (interactive where applicable):
111
+
112
+ <definition title="Entropy">
113
+
114
+ A measure of uncertainty: $H(X)$.
115
+
116
+ </definition>
117
+
118
+ Use child tags for rich titles and an explicit body:
119
+
120
+ ```markdown
121
+ <definition>
122
+
123
+ <title>**Entropy** / 熵</title>
124
+
125
+ <content>
126
+
127
+ The body supports Markdown.
128
+
129
+ </content>
130
+
131
+ </definition>
132
+ ```
133
+
134
+ The `title` attribute is text. Child tags support rich content. The directive form is `:::definition{title="Entropy"}`, closed by `:::`.
135
+
136
+ ## Exercises
137
+
138
+ ```markdown
139
+ <question title="Which numbers are even?">
140
+
141
+ <question-content>Select all correct options.</question-content>
142
+
143
+ <question-sel-grp multi="true" answer="[0,2]">
144
+
145
+ <question-sel>2</question-sel>
146
+
147
+ <question-sel>3</question-sel>
148
+
149
+ <question-sel>4</question-sel>
150
+
151
+ </question-sel-grp>
152
+
153
+ <question-hint>Consider divisibility by 2.</question-hint>
154
+
155
+ <question-answer>2 and 4 are even.</question-answer>
156
+
157
+ </question>
158
+ ```
159
+
160
+ Rendered result (interactive where applicable):
161
+
162
+ <question title="Which numbers are even?">
163
+
164
+ <question-content>Select all correct options.</question-content>
165
+
166
+ <question-sel-grp multi="true" answer="[0,2]">
167
+
168
+ <question-sel>2</question-sel>
169
+
170
+ <question-sel>3</question-sel>
171
+
172
+ <question-sel>4</question-sel>
173
+
174
+ </question-sel-grp>
175
+
176
+ <question-hint>Consider divisibility by 2.</question-hint>
177
+
178
+ <question-answer>2 and 4 are even.</question-answer>
179
+
180
+ </question>
181
+
182
+ Answer indices are **zero-based**. `multi` is off by default. `answer` is a string containing a JSON array or a single index. Attributes on the selection group take precedence over question attributes. Hints and answers expand independently; configured answers enable submission, scoring, and retry. This module neither connects to AI nor creates question annotations.
183
+
184
+ ## Further reading
185
+
186
+ ```markdown
187
+ <extras>
188
+
189
+ <extra title="Read more" url="https://example.com/article" desc="Background material." />
190
+
191
+ </extras>
192
+ ```
193
+
194
+ Rendered result (interactive where applicable):
195
+
196
+ <extras>
197
+
198
+ <extra title="Built-in modules" url="https://linloir.github.io/LiMR/#/docs/en/modules" desc="Background material." />
199
+
200
+ </extras>
201
+
202
+ `extra` uses `title`, `url`, and `desc`. Links pass through the built-in URL filter.
203
+
204
+ ## Citation cards
205
+
206
+ ```markdown
207
+ One source<ref id="a" />, or several<ref ids='["a","b"]' />.
208
+
209
+ <ref id="a">Referenced **text**</ref>
210
+
211
+ <citation id="a" title="Source A" url="https://example.com/a" description="Full **Markdown** description." summary="Short collapsed summary." />
212
+
213
+ <citation cite-id="b" title="Source B" url="https://example.com/b" desc="Legacy attribute name." />
214
+ ```
215
+
216
+ Rendered result (interactive where applicable):
217
+
218
+ One source<ref id="a" />, or several<ref ids='["a","b"]' />.
219
+
220
+ <ref id="a">Referenced **text**</ref>
221
+
222
+ <citation id="a" title="Source A" url="https://example.com/a" description="Full **Markdown** description." summary="Short collapsed summary." />
223
+
224
+ <citation cite-id="b" title="Source B" url="https://example.com/b" desc="Legacy attribute name." />
225
+
226
+ Citation IDs use `cite-id`, then `id`. Descriptions use `desc`, then `description`. References use `cite-from-ids`, `ids`, then `id`, accepting JSON arrays or comma-separated strings. Definitions do not occupy body space, and multiple markers can reference one definition.
227
+
228
+ Citations do not expand into large cards by default; clicking pins the preview. Collapsed summaries fall back through `summary → description → safe URL → title`, with Markdown stripped. Card content uses description, then summary. Hovering or activating a reference temporarily highlights its nearest text block (paragraph, heading, list item, or table cell), without saving a highlight. External range annotations use their bound range. See [annotations and selection](annotations.md).
229
+
230
+ ## Images, figures, and captions
231
+
232
+ ```markdown
233
+ <figures columns="2" min-width="220" max-width="560" max-height="480">
234
+
235
+ <figure src="/figures/a.png" alt="Experiment A" caption="(a) Experiment A" />
236
+
237
+ <figure id="experiment-b">
238
+
239
+ ![Experiment B](/figures/b.png)
240
+
241
+ <figcaption>**(b)** A Markdown caption.</figcaption>
242
+
243
+ </figure>
244
+
245
+ <figcaption>Figure 1 · Two experiments.</figcaption>
246
+
247
+ </figures>
248
+ ```
249
+
250
+ Rendered result (interactive where applicable):
251
+
252
+ <figures columns="2" min-width="220" max-width="560" max-height="480">
253
+
254
+ <figure src="../assets/source.svg" alt="Experiment A" caption="(a) Experiment A" />
255
+
256
+ <figure id="experiment-b">
257
+
258
+ ![Experiment B](../assets/rendered.svg)
259
+
260
+ <figcaption>**(b)** A Markdown caption.</figcaption>
261
+
262
+ </figure>
263
+
264
+ <figcaption>Figure 1 · Two experiments.</figcaption>
265
+
266
+ </figures>
267
+
268
+ A figure can stand alone. Supply an image through `src` / `url`, nested Markdown, or `<img src="…" alt="…" />`. Use one image per figure and figures for groups. Captions can use an attribute or figcaption / caption child tags; use children for rich text. `id` provides an in-page link target.
269
+
270
+ | Attribute | Default | Meaning |
271
+ | --- | --- | --- |
272
+ | `min-width` / `min-height` | 220 / 120 | Determines when another column fits; narrow containers take priority |
273
+ | `max-width` / `max-height` | 560 / 480 | Image bounds preserving aspect ratio; none / false removes a bound |
274
+ | `columns` / `cols` | Automatic | Requested columns, capped at 24 |
275
+ | `rows` | Automatic | Derives columns from image count when columns are omitted |
276
+ | `responsive` | true | Reduces explicit columns when space is insufficient; false keeps them |
277
+ | `gap` | 16 | Group gap in pixels |
278
+
279
+ Dimensions accept nonnegative numbers or px. Figures inherit group limits and can override them. Factory options use camelCase, such as `figures({ maxHeight: 360, maxWidth: false })`. Images retain their aspect ratio, and captions are not cropped. A single figure copies the image URL; a group copies Markdown source. Neither copies image bytes.
280
+
281
+ Directive example:
282
+
283
+ ```markdown
284
+ :::figures{columns="2"}
285
+ ::figure{src="/a.png" caption="A"}
286
+ ::figure{src="/b.png" caption="B"}
287
+ :::
288
+ ```
289
+
290
+ ## Video
291
+
292
+ ```markdown
293
+ <video src="/demo.mp4" provider="native" title="Demo" />
294
+
295
+ <md-video url="https://www.youtube.com/watch?v=dQw4w9WgXcQ" loading="click" />
296
+
297
+ <video url="https://www.bilibili.com/video/BV1xx411c7mD/?p=2" />
298
+ ```
299
+
300
+ `url` takes precedence over `src`. `provider` defaults to auto and also accepts native, youtube, and bilibili. YouTube supports watch, short, embed, shorts, and live URLs with start times. Bilibili supports BV/av IDs and parts. Other attributes are title and loading.
301
+
302
+ **The default is `loading="visible"`**: the player mounts within 200px of the viewport without autoplay. click waits for a click; eager mounts immediately. Set a module default with `video({ loading: 'click' })`. Actual playback depends on the platform, network, and embedding permissions; local iframe tests do not guarantee remote playback. Use `video({ resolveUrl })` for a custom provider.
303
+
304
+ Click-to-load example (no player is created before clicking):
305
+
306
+ <video url="https://www.youtube.com/watch?v=dQw4w9WgXcQ" loading="click" title="Video example" />
307
+
308
+ ## Translations
309
+
310
+ ```markdown
311
+ <translations default="both">
312
+
313
+ <origin>
314
+
315
+ Original **Markdown**.
316
+
317
+ </origin>
318
+
319
+ <translation>
320
+
321
+ 翻译后的 **Markdown**。
322
+
323
+ </translation>
324
+
325
+ </translations>
326
+ ```
327
+
328
+ Rendered result (interactive where applicable):
329
+
330
+ <translations default="both">
331
+
332
+ <origin>
333
+
334
+ Original **Markdown**.
335
+
336
+ </origin>
337
+
338
+ <translation>
339
+
340
+ 翻译后的 **Markdown**。
341
+
342
+ </translation>
343
+
344
+ </translations>
345
+
346
+ `default` accepts origin, translation, or both, defaulting to origin unless overridden by the factory's defaultMode. The marker cycles through these modes. Parallel mode shows the translation first. During streaming, an available side is shown while the other is missing. This module does not translate content automatically.
347
+
348
+ Global `parameters.translationMode` overrides individual blocks. Pass onTranslationModeChange to accept marker requests; without a callback, a global mode is locked. Setting it to undefined restores local choices. See [application integration](integration.md).
349
+
350
+ ## Selection and replacement
351
+
352
+ Persistent highlights are annotations; there is no built-in `==highlight==` syntax. Register plugins for custom tags. Not every child tag has a corresponding directive. See [extension development](extensions.md) to select or replace default modules.