@diplodoc/notes-extension 0.0.0-stage → 0.1.0-transform5.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.
Files changed (58) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +105 -2
  3. package/build/cjs/browser/index.d.ts +29 -0
  4. package/build/cjs/browser.js +415 -0
  5. package/build/cjs/browser.js.map +7 -0
  6. package/build/cjs/index.js +457 -0
  7. package/build/cjs/index.js.map +7 -0
  8. package/build/cjs/package.json +1 -0
  9. package/build/cjs/plugin/close.d.ts +7 -0
  10. package/build/cjs/plugin/const.d.ts +19 -0
  11. package/build/cjs/plugin/directive.d.ts +12 -0
  12. package/build/cjs/plugin/index.d.ts +18 -0
  13. package/build/cjs/plugin/plugin.d.ts +15 -0
  14. package/build/cjs/plugin/pure.d.ts +6 -0
  15. package/build/cjs/plugin/recognize.d.ts +26 -0
  16. package/build/cjs/plugin/resources.d.ts +9 -0
  17. package/build/cjs/plugin/transform.d.ts +28 -0
  18. package/build/cjs/plugin/types.d.ts +45 -0
  19. package/build/cjs/plugin.js +380 -0
  20. package/build/cjs/plugin.js.map +7 -0
  21. package/build/cjs/runtime/index.d.ts +1 -0
  22. package/build/esm/browser/index.d.ts +29 -0
  23. package/build/esm/browser.js +391 -0
  24. package/build/esm/browser.js.map +7 -0
  25. package/build/esm/index.js +433 -0
  26. package/build/esm/index.js.map +7 -0
  27. package/build/esm/package.json +1 -0
  28. package/build/esm/plugin/close.d.ts +7 -0
  29. package/build/esm/plugin/const.d.ts +19 -0
  30. package/build/esm/plugin/directive.d.ts +12 -0
  31. package/build/esm/plugin/index.d.ts +18 -0
  32. package/build/esm/plugin/plugin.d.ts +15 -0
  33. package/build/esm/plugin/pure.d.ts +6 -0
  34. package/build/esm/plugin/recognize.d.ts +26 -0
  35. package/build/esm/plugin/resources.d.ts +9 -0
  36. package/build/esm/plugin/transform.d.ts +28 -0
  37. package/build/esm/plugin/types.d.ts +45 -0
  38. package/build/esm/plugin.js +353 -0
  39. package/build/esm/plugin.js.map +7 -0
  40. package/build/esm/runtime/index.d.ts +1 -0
  41. package/build/runtime/index.cjs +1 -0
  42. package/build/runtime/index.css +55 -0
  43. package/build/runtime/index.d.ts +1 -0
  44. package/build/runtime/index.mjs +1 -0
  45. package/build/scss/_notes.scss +87 -0
  46. package/build/types/browser/index.d.ts +29 -0
  47. package/build/types/plugin/close.d.ts +7 -0
  48. package/build/types/plugin/const.d.ts +19 -0
  49. package/build/types/plugin/directive.d.ts +12 -0
  50. package/build/types/plugin/index.d.ts +18 -0
  51. package/build/types/plugin/plugin.d.ts +15 -0
  52. package/build/types/plugin/pure.d.ts +6 -0
  53. package/build/types/plugin/recognize.d.ts +26 -0
  54. package/build/types/plugin/resources.d.ts +9 -0
  55. package/build/types/plugin/transform.d.ts +28 -0
  56. package/build/types/plugin/types.d.ts +45 -0
  57. package/build/types/runtime/index.d.ts +1 -0
  58. package/package.json +96 -4
@@ -0,0 +1,457 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/plugin/index.ts
21
+ var plugin_exports = {};
22
+ __export(plugin_exports, {
23
+ TokenType: () => TokenType,
24
+ default: () => plugin_default,
25
+ transform: () => transform
26
+ });
27
+ module.exports = __toCommonJS(plugin_exports);
28
+
29
+ // src/plugin/transform.ts
30
+ var import_node_module = require("node:module");
31
+ var import_node_url = require("node:url");
32
+ var import_node_fs = require("node:fs");
33
+ var import_node_path = require("node:path");
34
+
35
+ // src/plugin/close.ts
36
+ function createNestedCloseTokenIdxFactory(formatPath) {
37
+ const nestedCloseTokenIdxFactory = (tokenName, matchOpenToken2, matchCloseToken2) => (tokens, idx, path, log) => {
38
+ let level = 0;
39
+ let i = idx;
40
+ while (i < tokens.length) {
41
+ if (matchOpenToken2(tokens, i)) {
42
+ level++;
43
+ } else if (matchCloseToken2(tokens, i)) {
44
+ if (level === 0) {
45
+ return i;
46
+ }
47
+ level--;
48
+ }
49
+ i++;
50
+ }
51
+ log.error(`${tokenName} must be closed${path ? ` in ${formatPath(path)}` : ""}`);
52
+ return null;
53
+ };
54
+ return nestedCloseTokenIdxFactory;
55
+ }
56
+
57
+ // src/plugin/const.ts
58
+ var DEFAULT_LANG = "ru";
59
+ var TITLES = {
60
+ ru: {
61
+ info: "\u041F\u0440\u0438\u043C\u0435\u0447\u0430\u043D\u0438\u0435",
62
+ tip: "\u0421\u043E\u0432\u0435\u0442",
63
+ alert: "\u0412\u043D\u0438\u043C\u0430\u043D\u0438\u0435",
64
+ warning: "\u0412\u0430\u0436\u043D\u043E"
65
+ },
66
+ en: {
67
+ info: "Note",
68
+ tip: "Tip",
69
+ alert: "Alert",
70
+ warning: "Warning"
71
+ },
72
+ ar: {
73
+ info: "\u0645\u0644\u0627\u062D\u0638\u0629",
74
+ tip: "\u0646\u0635\u064A\u062D\u0629",
75
+ alert: "\u0627\u0646\u062A\u0628\u0627\u0647",
76
+ warning: "\u0647\u0627\u0645"
77
+ },
78
+ cs: {
79
+ info: "Pozn\xE1mka",
80
+ tip: "Tip",
81
+ alert: "Upozorn\u011Bn\xED",
82
+ warning: "Varov\xE1n\xED"
83
+ },
84
+ fr: {
85
+ info: "Remarque",
86
+ tip: "Astuce",
87
+ alert: "Alerte",
88
+ warning: "Avertissement"
89
+ },
90
+ es: {
91
+ info: "Nota",
92
+ tip: "Consejo",
93
+ alert: "Alerta",
94
+ warning: "Aviso"
95
+ },
96
+ he: {
97
+ info: "\u05DE\u05D9\u05D3\u05E2",
98
+ tip: "\u05D8\u05D9\u05E4",
99
+ alert: "\u05D4\u05EA\u05E8\u05D0\u05D4",
100
+ warning: "\u05D0\u05D6\u05D4\u05E8\u05D4"
101
+ },
102
+ bg: {
103
+ info: "\u0417\u0430\u0431\u0435\u043B\u0435\u0436\u043A\u0430",
104
+ tip: "\u0421\u044A\u0432\u0435\u0442",
105
+ alert: "\u0412\u043D\u0438\u043C\u0430\u043D\u0438\u0435",
106
+ warning: "\u0412\u0430\u0436\u043D\u043E"
107
+ },
108
+ et: {
109
+ info: "M\xE4rkus",
110
+ tip: "N\xF5uanne",
111
+ alert: "T\xE4helepanu",
112
+ warning: "T\xE4htis"
113
+ },
114
+ el: {
115
+ info: "\u03A3\u03B7\u03BC\u03B5\u03AF\u03C9\u03C3\u03B7",
116
+ tip: "\u03A3\u03C5\u03BC\u03B2\u03BF\u03C5\u03BB\u03AE",
117
+ alert: "\u03A0\u03C1\u03BF\u03C3\u03BF\u03C7\u03AE",
118
+ warning: "\u03A3\u03B7\u03BC\u03B1\u03BD\u03C4\u03B9\u03BA\u03CC"
119
+ },
120
+ pt: {
121
+ info: "Observa\xE7\xE3o",
122
+ tip: "Sugest\xE3o",
123
+ alert: "Aten\xE7\xE3o",
124
+ warning: "Importante"
125
+ },
126
+ zh: {
127
+ info: "\u5907\u6CE8",
128
+ tip: "\u63D0\u793A",
129
+ alert: "\u6CE8\u610F",
130
+ warning: "\u91CD\u8981"
131
+ },
132
+ "zh-tw": {
133
+ info: "\u5099\u6CE8",
134
+ tip: "\u63D0\u793A",
135
+ alert: "\u6CE8\u610F",
136
+ warning: "\u91CD\u8981"
137
+ },
138
+ kk: {
139
+ info: "\u0415\u0441\u043A\u0435\u0440\u0442\u0443",
140
+ tip: "\u041A\u0435\u04A3\u0435\u0441",
141
+ alert: "\u041D\u0430\u0437\u0430\u0440 \u0430\u0443\u0434\u0430\u0440\u044B\u04A3\u044B\u0437",
142
+ warning: "\u041C\u0430\u04A3\u044B\u0437\u0434\u044B"
143
+ },
144
+ tr: {
145
+ info: "Not",
146
+ tip: "\xD6neri",
147
+ alert: "Dikkat",
148
+ warning: "\xD6nemli"
149
+ },
150
+ uz: {
151
+ info: "Sharh",
152
+ tip: "Maslahat",
153
+ alert: "Diqqat",
154
+ warning: "Bu muhim"
155
+ }
156
+ };
157
+ var TokenType = {
158
+ Note: "yfm-note",
159
+ NoteOpen: "yfm_note_open",
160
+ NoteClose: "yfm_note_close",
161
+ NoteTitleOpen: "yfm_note_title_open",
162
+ NoteTitleClose: "yfm_note_title_close",
163
+ NoteContentOpen: "yfm_note_content_open",
164
+ NoteContentClose: "yfm_note_content_close"
165
+ };
166
+
167
+ // src/plugin/directive.ts
168
+ var import_directive = require("@diplodoc/directive");
169
+ function invalidReason(params, state) {
170
+ if (params.dests) {
171
+ const suffix = params.inlineContent ? state.src.slice(params.inlineContent.endPos + 1, state.eMarks[params.startLine]).trimStart() : "";
172
+ if (!params.inlineContent || suffix.startsWith("(") || suffix.startsWith("[")) {
173
+ return "Destinations are not supported for note directives";
174
+ }
175
+ }
176
+ if (params.contentTitle) return "Invalid note directive parameters";
177
+ const attrs = params.attrs ?? {};
178
+ for (const name of Object.keys(attrs)) {
179
+ if (name !== "type") return `Unknown note attribute: ${name}`;
180
+ }
181
+ if (Array.isArray(attrs.type)) return "Repeated note attribute: type";
182
+ if (!attrs.type || !["info", "tip", "warning", "alert"].includes(attrs.type)) {
183
+ return "Note type must be info, tip, warning or alert";
184
+ }
185
+ return void 0;
186
+ }
187
+ function installNoteDirective(md, markers, onDiagnostic) {
188
+ (0, import_directive.directiveParser)()(md);
189
+ (0, import_directive.registerContainerDirective)(
190
+ md,
191
+ "note",
192
+ (state, params) => {
193
+ const reason = invalidReason(params, state);
194
+ if (reason) {
195
+ onDiagnostic?.({ line: params.startLine + 1, reason });
196
+ return false;
197
+ }
198
+ const type = params.attrs?.type;
199
+ if (typeof type !== "string") throw new Error("Invalid validated note type");
200
+ const open = state.push("yfm_note_directive_open", "", 0);
201
+ open.map = [params.startLine, params.endLine];
202
+ (0, import_directive.tokenizeBlockContent)(state, params.content, "note-directive");
203
+ const close = state.push("yfm_note_directive_close", "", 0);
204
+ close.map = [params.endLine - 1, params.endLine];
205
+ markers.set(open, {
206
+ kind: "open",
207
+ end: close,
208
+ type,
209
+ title: params.inlineContent?.raw,
210
+ contentMap: [params.content.startLine, params.content.endLine]
211
+ });
212
+ markers.set(close, { kind: "close" });
213
+ return true;
214
+ },
215
+ { onConflict: "error" }
216
+ );
217
+ }
218
+
219
+ // src/plugin/recognize.ts
220
+ var ALERT_RE = /^{% note (alert|info|tip|warning)\s*(?:"(.*?)")? %}$/;
221
+ var WRONG_NOTES = /^{% note (.*)%}/;
222
+ function matchCloseToken(tokens, i) {
223
+ return tokens[i].type === "paragraph_open" && tokens[i + 1].type === "inline" && tokens[i + 1].content.trim() === "{% endnote %}";
224
+ }
225
+ function matchOpenToken(tokens, i) {
226
+ return tokens[i].type === "paragraph_open" && tokens[i + 1].type === "inline" && tokens[i + 1].content.match(ALERT_RE);
227
+ }
228
+ function matchWrongNotes(tokens, i) {
229
+ return tokens[i].type === "paragraph_open" && tokens[i + 1].type === "inline" && tokens[i + 1].content.match(WRONG_NOTES);
230
+ }
231
+
232
+ // src/plugin/plugin.ts
233
+ var quietLogger = { warn: (_message) => {
234
+ }, error: (_message) => {
235
+ } };
236
+ var titleDictionaries = new Map(Object.entries(TITLES));
237
+ function getTitle(type, lang) {
238
+ return (titleDictionaries.get(lang) ?? TITLES.ru)[type];
239
+ }
240
+ function emitNote(state, note) {
241
+ const { tokens, env } = state;
242
+ const open = new state.Token("yfm_note_open", "div", 1);
243
+ open.attrSet("class", `yfm-note yfm-accent-${note.type}`);
244
+ open.attrSet("note-type", note.type);
245
+ open.map = tokens[note.start].map;
246
+ const closeMap = tokens[note.close].map;
247
+ if (closeMap && open.map) open.map[1] = closeMap[1];
248
+ const close = new state.Token("yfm_note_close", "div", -1);
249
+ close.map = closeMap;
250
+ const titleOpen = new state.Token("yfm_note_title_open", "p", 1);
251
+ titleOpen.attrSet("class", "yfm-note-title");
252
+ const titleInline = state.md.parseInline(note.title, env)[0];
253
+ titleInline.map = null;
254
+ const titleClose = new state.Token("yfm_note_title_close", "p", -1);
255
+ titleOpen.block = true;
256
+ titleClose.block = true;
257
+ const contentOpen = new state.Token("yfm_note_content_open", "div", 1);
258
+ contentOpen.attrSet("class", "yfm-note-content");
259
+ const contentClose = new state.Token("yfm_note_content_close", "div", -1);
260
+ if (open.map) contentOpen.map = note.contentMap ?? [open.map[0] + 2, open.map[1] - 2];
261
+ const inside = [open];
262
+ if (titleInline.content) inside.push(titleOpen, titleInline, titleClose);
263
+ inside.push(contentOpen, ...tokens.slice(note.bodyStart, note.close), contentClose, close);
264
+ tokens.splice(note.start, note.removeCount, ...inside);
265
+ }
266
+ function validateMarkers(tokens, markers) {
267
+ const expected = [];
268
+ for (const token of tokens) {
269
+ const marker = markers.get(token);
270
+ if (!marker && (token.type === "yfm_note_directive_open" || token.type === "yfm_note_directive_close")) {
271
+ throw new Error("Unowned note directive marker");
272
+ }
273
+ if (marker?.kind === "open") expected.push(marker.end);
274
+ else if (marker?.kind === "close" && expected.pop() !== token) {
275
+ throw new Error("Note directive opening marker is missing or crossed");
276
+ }
277
+ }
278
+ if (expected.length) throw new Error("Note directive closing marker is missing");
279
+ }
280
+ function createNotesPlugin(formatPath = (path) => path, onNote, factory = {}) {
281
+ const findCloseTokenIdx = createNestedCloseTokenIdxFactory(formatPath)(
282
+ "Note",
283
+ matchOpenToken,
284
+ matchCloseToken
285
+ );
286
+ const installCore = (md, { lang = DEFAULT_LANG, notesAutotitle, path: optPath, log = quietLogger } = {}, markers, legacy, directiveEnabled) => {
287
+ notesAutotitle = typeof notesAutotitle === "boolean" ? notesAutotitle : true;
288
+ const processNote = (state, start, marker, match, path) => {
289
+ const { tokens, env } = state;
290
+ const closeTokenIdx = marker ? tokens.findIndex((token, index) => index > start && token === marker.end) : findCloseTokenIdx(tokens, start + 2, path, log);
291
+ if (marker && (closeTokenIdx === null || closeTokenIdx < 0)) {
292
+ throw new Error("Note directive closing marker is missing");
293
+ }
294
+ if (!closeTokenIdx) return start + 3;
295
+ const type = marker ? marker.type : match && match[1].toLowerCase();
296
+ if (!type) throw new Error("Note type is missing");
297
+ let authoredTitle;
298
+ if (marker) authoredTitle = marker.title;
299
+ else if (match) authoredTitle = match[2];
300
+ let title = authoredTitle;
301
+ if (title === void 0) title = notesAutotitle ? getTitle(type, lang) : "";
302
+ emitNote(state, {
303
+ start,
304
+ close: closeTokenIdx,
305
+ bodyStart: start + (marker ? 1 : 3),
306
+ removeCount: closeTokenIdx - start + (marker ? 1 : 3),
307
+ type,
308
+ title,
309
+ contentMap: marker?.contentMap
310
+ });
311
+ onNote?.(env);
312
+ return start + 1;
313
+ };
314
+ const plugin = (state) => {
315
+ const { tokens, env } = state;
316
+ if (directiveEnabled) validateMarkers(tokens, markers);
317
+ const path = typeof env.path === "string" && env.path ? env.path : optPath ?? "";
318
+ let i = 0;
319
+ while (i < tokens.length) {
320
+ const marker = markers.get(tokens[i]);
321
+ if (marker?.kind === "close") {
322
+ throw new Error("Note directive opening marker is missing");
323
+ }
324
+ const match = legacy && matchOpenToken(tokens, i);
325
+ if (marker || match) {
326
+ i = processNote(state, i, marker, match, path);
327
+ } else if (legacy && matchWrongNotes(tokens, i) && tokens[i + 1].content !== "{% endnote %}") {
328
+ log.warn(
329
+ `Incorrect syntax for notes${path ? `, file ${formatPath(path)}` : ""}`
330
+ );
331
+ i += 3;
332
+ } else {
333
+ i++;
334
+ }
335
+ }
336
+ };
337
+ try {
338
+ md.core.ruler.before("curly_attributes", "notes", plugin);
339
+ } catch {
340
+ md.core.ruler.push("notes", plugin);
341
+ }
342
+ };
343
+ if (!factory.directiveSyntax || factory.directiveSyntax === "disabled") {
344
+ const legacyPlugin = (md, options) => installCore(md, options, /* @__PURE__ */ new WeakMap(), true, false);
345
+ return legacyPlugin;
346
+ }
347
+ const directivePlugin = (md, options) => {
348
+ const markers = /* @__PURE__ */ new WeakMap();
349
+ installNoteDirective(md, markers, factory.onDiagnostic);
350
+ installCore(md, options, markers, factory.directiveSyntax === "enabled", true);
351
+ };
352
+ return directivePlugin;
353
+ }
354
+
355
+ // src/plugin/resources.ts
356
+ function normalizeRuntime(runtime, bundle = false) {
357
+ if (runtime === false) return false;
358
+ if (typeof runtime === "string") {
359
+ if (bundle)
360
+ throw new TypeError("Option `runtime` should be record when `bundle` is enabled.");
361
+ return { script: runtime, style: runtime };
362
+ }
363
+ return runtime ?? { style: "_assets/notes-extension.css" };
364
+ }
365
+ function semanticOptions(defaults, settings) {
366
+ return {
367
+ lang: settings.lang === void 0 ? defaults.lang : settings.lang,
368
+ notesAutotitle: settings.notesAutotitle === void 0 ? defaults.notesAutotitle : settings.notesAutotitle,
369
+ path: settings.path === void 0 ? defaults.path : settings.path,
370
+ log: settings.log === void 0 ? defaults.log : settings.log
371
+ };
372
+ }
373
+ function isRecord(value) {
374
+ return value !== null && typeof value === "object" && !Array.isArray(value);
375
+ }
376
+ function addResources(env, runtime) {
377
+ const previous = env.meta;
378
+ if (previous !== void 0 && !isRecord(previous)) {
379
+ throw new TypeError("Notes resource metadata must be an object.");
380
+ }
381
+ const meta = { ...previous };
382
+ for (const key of ["style", "script"]) {
383
+ const resource = runtime[key];
384
+ if (!resource) continue;
385
+ const existing = meta[key];
386
+ let values = [];
387
+ if (Array.isArray(existing)) values = [...existing];
388
+ else if (existing !== void 0) values = [existing];
389
+ if (!values.includes(resource)) values.push(resource);
390
+ meta[key] = values;
391
+ }
392
+ env.meta = meta;
393
+ }
394
+
395
+ // src/plugin/transform.ts
396
+ function copyRuntime(runtime, output, copied) {
397
+ const moduleUrl = __filename.startsWith("file:") ? new URL(__filename) : (0, import_node_url.pathToFileURL)(__filename);
398
+ const runtimeDirectory = (0, import_node_url.fileURLToPath)(new URL("../runtime/", moduleUrl));
399
+ for (const [name, target] of [
400
+ ["index.css", runtime.style],
401
+ ["index.cjs", runtime.script]
402
+ ]) {
403
+ if (!target) continue;
404
+ const destination = (0, import_node_path.resolve)((0, import_node_path.join)(output, target));
405
+ if (copied.has(destination)) continue;
406
+ (0, import_node_fs.mkdirSync)((0, import_node_path.dirname)(destination), { recursive: true });
407
+ (0, import_node_fs.copyFileSync)((0, import_node_path.join)(runtimeDirectory, name), destination);
408
+ copied.add(destination);
409
+ }
410
+ }
411
+ function transform(options = {}) {
412
+ const { bundle = true } = options;
413
+ const runtime = normalizeRuntime(options.runtime, bundle);
414
+ const copiedByDocument = /* @__PURE__ */ new WeakMap();
415
+ const onNote = (settings) => runtime ? (env) => {
416
+ addResources(env, runtime);
417
+ if (bundle) {
418
+ let copied = copiedByDocument.get(env);
419
+ if (!copied) {
420
+ copied = /* @__PURE__ */ new Set();
421
+ copiedByDocument.set(env, copied);
422
+ }
423
+ copyRuntime(runtime, settings.output ?? ".", copied);
424
+ }
425
+ } : void 0;
426
+ function legacyPlugin(md, settings = {}) {
427
+ createNotesPlugin(void 0, onNote(settings))(md, semanticOptions(options, settings));
428
+ }
429
+ const mode = options.directiveSyntax;
430
+ function directivePlugin(md, settings = {}) {
431
+ if (mode !== "enabled" && mode !== "only") throw new Error("Directive mode is disabled");
432
+ createNotesPlugin(void 0, onNote(settings), {
433
+ directiveSyntax: mode,
434
+ onDiagnostic: options.onDiagnostic
435
+ })(md, semanticOptions(options, settings));
436
+ }
437
+ const collector = {
438
+ collect(input, { destRoot = ".", ...settings } = {}) {
439
+ const MarkdownIt = (0, import_node_module.createRequire)(__filename)("markdown-it");
440
+ const md = new MarkdownIt();
441
+ if (mode === "enabled" || mode === "only")
442
+ md.use(directivePlugin, { ...settings, output: destRoot });
443
+ else md.use(legacyPlugin, { ...settings, output: destRoot });
444
+ md.parse(input, {});
445
+ }
446
+ };
447
+ return mode === "enabled" || mode === "only" ? Object.assign(directivePlugin, collector) : Object.assign(legacyPlugin, collector);
448
+ }
449
+
450
+ // src/plugin/index.ts
451
+ var plugin_default = { transform, TokenType };
452
+ // Annotate the CommonJS export names for ESM import in node:
453
+ 0 && (module.exports = {
454
+ TokenType,
455
+ transform
456
+ });
457
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/plugin/index.ts", "../../src/plugin/transform.ts", "../../src/plugin/close.ts", "../../src/plugin/const.ts", "../../src/plugin/directive.ts", "../../src/plugin/recognize.ts", "../../src/plugin/plugin.ts", "../../src/plugin/resources.ts"],
4
+ "sourcesContent": ["import {transform} from './transform.js';\nimport {TokenType} from './const.js';\n\nexport {transform, TokenType};\nexport type {\n TransformOptions,\n NotesTransformPlugin,\n NotesDirectiveTransformPlugin,\n PluginOptions,\n CollectOptions,\n} from './transform.js';\nexport type {\n NotesOptions,\n NotesLogger,\n NotesDirectiveDiagnostic,\n NotesFactoryOptions,\n NotesDirectivePlugin,\n} from './types.js';\nexport default {transform, TokenType};\n", "import type MarkdownItConstructor from 'markdown-it' with {'resolution-mode': 'import'};\nimport type {\n BlockContentState,\n DirectiveBlockState,\n DirectiveInlineState,\n DirectiveParserHost,\n} from '@diplodoc/directive';\nimport type {NoteParser, NoteToken, NotesFactoryOptions, NotesOptions} from './types.js';\nimport type {Runtime, RuntimeOption} from './resources.js';\n\nimport {createRequire} from 'node:module';\nimport {fileURLToPath, pathToFileURL} from 'node:url';\nimport {copyFileSync, mkdirSync} from 'node:fs';\nimport {dirname, join, resolve} from 'node:path';\n\nimport {createNotesPlugin} from './plugin.js';\nimport {addResources, normalizeRuntime, semanticOptions} from './resources.js';\n\ndeclare const __MODULE_PATH__: string;\n\nexport type TransformOptions = NotesOptions &\n NotesFactoryOptions & {runtime?: RuntimeOption; bundle?: boolean};\nexport type PluginOptions = NotesOptions & {output?: string};\nexport type CollectOptions = NotesOptions & {destRoot?: string};\nexport interface NotesTransformPlugin {\n <Token extends NoteToken>(md: NoteParser<Token>, settings?: PluginOptions): void;\n collect(input: string, options?: CollectOptions): void;\n}\nexport interface NotesDirectiveTransformPlugin {\n <\n Token extends NoteToken,\n Block extends DirectiveBlockState & BlockContentState<Block>,\n Inline extends DirectiveInlineState,\n >(\n md: NoteParser<Token> & DirectiveParserHost<Block, Inline>,\n settings?: PluginOptions,\n ): void;\n collect(input: string, options?: CollectOptions): void;\n}\n\nfunction copyRuntime(runtime: Runtime, output: string, copied: Set<string>): void {\n const moduleUrl = __MODULE_PATH__.startsWith('file:')\n ? new URL(__MODULE_PATH__)\n : pathToFileURL(__MODULE_PATH__);\n const runtimeDirectory = fileURLToPath(new URL('../runtime/', moduleUrl));\n for (const [name, target] of [\n ['index.css', runtime.style],\n ['index.cjs', runtime.script],\n ] as const) {\n if (!target) continue;\n const destination = resolve(join(output, target));\n if (copied.has(destination)) continue;\n mkdirSync(dirname(destination), {recursive: true});\n copyFileSync(join(runtimeDirectory, name), destination);\n copied.add(destination);\n }\n}\n\nexport function transform(\n options?: TransformOptions & {directiveSyntax?: 'disabled'},\n): NotesTransformPlugin;\nexport function transform(\n options: TransformOptions & {directiveSyntax: 'enabled' | 'only'},\n): NotesDirectiveTransformPlugin;\nexport function transform(\n options: TransformOptions,\n): NotesTransformPlugin | NotesDirectiveTransformPlugin;\nexport function transform(\n options: TransformOptions = {},\n): NotesTransformPlugin | NotesDirectiveTransformPlugin {\n const {bundle = true} = options;\n const runtime = normalizeRuntime(options.runtime, bundle);\n const copiedByDocument = new WeakMap<Record<string, unknown>, Set<string>>();\n const onNote = (settings: PluginOptions) =>\n runtime\n ? (env: Record<string, unknown>) => {\n addResources(env, runtime);\n if (bundle) {\n let copied = copiedByDocument.get(env);\n if (!copied) {\n copied = new Set<string>();\n copiedByDocument.set(env, copied);\n }\n copyRuntime(runtime, settings.output ?? '.', copied);\n }\n }\n : undefined;\n function legacyPlugin<Token extends NoteToken>(\n md: NoteParser<Token>,\n settings: PluginOptions = {},\n ): void {\n createNotesPlugin(undefined, onNote(settings))(md, semanticOptions(options, settings));\n }\n const mode = options.directiveSyntax;\n function directivePlugin<\n Token extends NoteToken,\n Block extends DirectiveBlockState & BlockContentState<Block>,\n Inline extends DirectiveInlineState,\n >(\n md: NoteParser<Token> & DirectiveParserHost<Block, Inline>,\n settings: PluginOptions = {},\n ): void {\n if (mode !== 'enabled' && mode !== 'only') throw new Error('Directive mode is disabled');\n createNotesPlugin(undefined, onNote(settings), {\n directiveSyntax: mode,\n onDiagnostic: options.onDiagnostic,\n })(md, semanticOptions(options, settings));\n }\n const collector = {\n collect(input: string, {destRoot = '.', ...settings}: CollectOptions = {}): void {\n const MarkdownIt: typeof MarkdownItConstructor =\n createRequire(__MODULE_PATH__)('markdown-it');\n const md = new MarkdownIt();\n if (mode === 'enabled' || mode === 'only')\n md.use(directivePlugin, {...settings, output: destRoot});\n else md.use(legacyPlugin, {...settings, output: destRoot});\n md.parse(input, {});\n },\n };\n return mode === 'enabled' || mode === 'only'\n ? Object.assign(directivePlugin, collector)\n : Object.assign(legacyPlugin, collector);\n}\n", "import type {MatchTokenFunction, NoteToken, NotesLogger} from './types.js';\n\n/**\n * Bind the existing close-token search to the host's path formatter.\n * @param formatPath - Plain browser or original terminal path formatting.\n * @returns The existing finite token-search factory.\n */\nexport function createNestedCloseTokenIdxFactory(formatPath: (path: string) => string) {\n const nestedCloseTokenIdxFactory =\n (\n tokenName: string,\n matchOpenToken: MatchTokenFunction,\n matchCloseToken: MatchTokenFunction,\n ) =>\n (tokens: NoteToken[], idx: number, path: string, log: NotesLogger) => {\n let level = 0;\n let i = idx;\n while (i < tokens.length) {\n if (matchOpenToken(tokens, i)) {\n level++;\n } else if (matchCloseToken(tokens, i)) {\n if (level === 0) {\n return i;\n }\n level--;\n }\n\n i++;\n }\n\n log.error(`${tokenName} must be closed${path ? ` in ${formatPath(path)}` : ''}`);\n\n return null;\n };\n\n return nestedCloseTokenIdxFactory;\n}\n", "export const ENV_FLAG_NAME = 'has-yfm-notes';\nexport const DEFAULT_LANG = 'ru';\n\nexport type Lang =\n | 'ru'\n | 'en'\n | 'ar'\n | 'cs'\n | 'fr'\n | 'es'\n | 'he'\n | 'bg'\n | 'et'\n | 'el'\n | 'pt'\n | 'zh'\n | 'zh-tw'\n | 'kk'\n | 'tr'\n | 'uz';\n\nexport const TITLES: Record<Lang, Record<string, string>> = {\n ru: {\n info: '\u041F\u0440\u0438\u043C\u0435\u0447\u0430\u043D\u0438\u0435',\n tip: '\u0421\u043E\u0432\u0435\u0442',\n alert: '\u0412\u043D\u0438\u043C\u0430\u043D\u0438\u0435',\n warning: '\u0412\u0430\u0436\u043D\u043E',\n },\n en: {\n info: 'Note',\n tip: 'Tip',\n alert: 'Alert',\n warning: 'Warning',\n },\n ar: {\n info: '\u0645\u0644\u0627\u062D\u0638\u0629',\n tip: '\u0646\u0635\u064A\u062D\u0629',\n alert: '\u0627\u0646\u062A\u0628\u0627\u0647',\n warning: '\u0647\u0627\u0645',\n },\n cs: {\n info: 'Pozn\u00E1mka',\n tip: 'Tip',\n alert: 'Upozorn\u011Bn\u00ED',\n warning: 'Varov\u00E1n\u00ED',\n },\n fr: {\n info: 'Remarque',\n tip: 'Astuce',\n alert: 'Alerte',\n warning: 'Avertissement',\n },\n es: {\n info: 'Nota',\n tip: 'Consejo',\n alert: 'Alerta',\n warning: 'Aviso',\n },\n he: {\n info: '\u05DE\u05D9\u05D3\u05E2',\n tip: '\u05D8\u05D9\u05E4',\n alert: '\u05D4\u05EA\u05E8\u05D0\u05D4',\n warning: '\u05D0\u05D6\u05D4\u05E8\u05D4',\n },\n bg: {\n info: '\u0417\u0430\u0431\u0435\u043B\u0435\u0436\u043A\u0430',\n tip: '\u0421\u044A\u0432\u0435\u0442',\n alert: '\u0412\u043D\u0438\u043C\u0430\u043D\u0438\u0435',\n warning: '\u0412\u0430\u0436\u043D\u043E',\n },\n et: {\n info: 'M\u00E4rkus',\n tip: 'N\u00F5uanne',\n alert: 'T\u00E4helepanu',\n warning: 'T\u00E4htis',\n },\n el: {\n info: '\u03A3\u03B7\u03BC\u03B5\u03AF\u03C9\u03C3\u03B7',\n tip: '\u03A3\u03C5\u03BC\u03B2\u03BF\u03C5\u03BB\u03AE',\n alert: '\u03A0\u03C1\u03BF\u03C3\u03BF\u03C7\u03AE',\n warning: '\u03A3\u03B7\u03BC\u03B1\u03BD\u03C4\u03B9\u03BA\u03CC',\n },\n pt: {\n info: 'Observa\u00E7\u00E3o',\n tip: 'Sugest\u00E3o',\n alert: 'Aten\u00E7\u00E3o',\n warning: 'Importante',\n },\n zh: {\n info: '\u5907\u6CE8',\n tip: '\u63D0\u793A',\n alert: '\u6CE8\u610F',\n warning: '\u91CD\u8981',\n },\n 'zh-tw': {\n info: '\u5099\u6CE8',\n tip: '\u63D0\u793A',\n alert: '\u6CE8\u610F',\n warning: '\u91CD\u8981',\n },\n kk: {\n info: '\u0415\u0441\u043A\u0435\u0440\u0442\u0443',\n tip: '\u041A\u0435\u04A3\u0435\u0441',\n alert: '\u041D\u0430\u0437\u0430\u0440 \u0430\u0443\u0434\u0430\u0440\u044B\u04A3\u044B\u0437',\n warning: '\u041C\u0430\u04A3\u044B\u0437\u0434\u044B',\n },\n tr: {\n info: 'Not',\n tip: '\u00D6neri',\n alert: 'Dikkat',\n warning: '\u00D6nemli',\n },\n uz: {\n info: 'Sharh',\n tip: 'Maslahat',\n alert: 'Diqqat',\n warning: 'Bu muhim',\n },\n};\n\nexport const TokenType = {\n Note: 'yfm-note',\n NoteOpen: 'yfm_note_open',\n NoteClose: 'yfm_note_close',\n NoteTitleOpen: 'yfm_note_title_open',\n NoteTitleClose: 'yfm_note_title_close',\n NoteContentOpen: 'yfm_note_content_open',\n NoteContentClose: 'yfm_note_content_close',\n} as const;\n\nexport const ClassNames = {\n Note: 'yfm-note',\n Accent: 'yfm-accent',\n Title: 'yfm-note-title',\n Content: 'yfm-note-content',\n} as const;\n", "import type {\n BlockContentState,\n ContainerDirectiveParams,\n DirectiveBlockState,\n DirectiveInlineState,\n DirectiveParserHost,\n} from '@diplodoc/directive';\nimport type {NotesDirectiveDiagnostic} from './types.js';\n\nimport {\n directiveParser,\n registerContainerDirective,\n tokenizeBlockContent,\n} from '@diplodoc/directive';\n\nexport type NoteMarker =\n | {\n kind: 'open';\n end: object;\n type: string;\n title: string | undefined;\n contentMap: [number, number];\n }\n | {kind: 'close'};\n\nfunction invalidReason(\n params: ContainerDirectiveParams,\n state: DirectiveBlockState,\n): string | undefined {\n if (params.dests) {\n const suffix = params.inlineContent\n ? state.src\n .slice(params.inlineContent.endPos + 1, state.eMarks[params.startLine])\n .trimStart()\n : '';\n if (!params.inlineContent || suffix.startsWith('(') || suffix.startsWith('[')) {\n return 'Destinations are not supported for note directives';\n }\n }\n if (params.contentTitle) return 'Invalid note directive parameters';\n const attrs = params.attrs ?? {};\n for (const name of Object.keys(attrs)) {\n if (name !== 'type') return `Unknown note attribute: ${name}`;\n }\n if (Array.isArray(attrs.type)) return 'Repeated note attribute: type';\n if (!attrs.type || !['info', 'tip', 'warning', 'alert'].includes(attrs.type)) {\n return 'Note type must be info, tip, warning or alert';\n }\n return undefined;\n}\n\nexport function installNoteDirective<\n B extends DirectiveBlockState & BlockContentState<B>,\n I extends DirectiveInlineState,\n>(\n md: DirectiveParserHost<B, I>,\n markers: WeakMap<object, NoteMarker>,\n onDiagnostic?: (diagnostic: NotesDirectiveDiagnostic) => void,\n): void {\n directiveParser()(md);\n registerContainerDirective(\n md,\n 'note',\n (state, params) => {\n const reason = invalidReason(params, state);\n if (reason) {\n onDiagnostic?.({line: params.startLine + 1, reason});\n return false;\n }\n // The checked scalar value is the only accepted attribute.\n const type = params.attrs?.type;\n if (typeof type !== 'string') throw new Error('Invalid validated note type');\n const open = state.push('yfm_note_directive_open', '', 0);\n open.map = [params.startLine, params.endLine];\n tokenizeBlockContent(state, params.content, 'note-directive');\n const close = state.push('yfm_note_directive_close', '', 0);\n close.map = [params.endLine - 1, params.endLine];\n markers.set(open, {\n kind: 'open',\n end: close,\n type,\n title: params.inlineContent?.raw,\n contentMap: [params.content.startLine, params.content.endLine],\n });\n markers.set(close, {kind: 'close'});\n return true;\n },\n {onConflict: 'error'},\n );\n}\n", "import type {NoteToken} from './types.js';\n\nconst ALERT_RE = /^{% note (alert|info|tip|warning)\\s*(?:\"(.*?)\")? %}$/;\nconst WRONG_NOTES = /^{% note (.*)%}/;\n\nexport function matchCloseToken(tokens: readonly NoteToken[], i: number) {\n return (\n tokens[i].type === 'paragraph_open' &&\n tokens[i + 1].type === 'inline' &&\n tokens[i + 1].content.trim() === '{% endnote %}'\n );\n}\n\nexport function matchOpenToken(tokens: readonly NoteToken[], i: number) {\n return (\n tokens[i].type === 'paragraph_open' &&\n tokens[i + 1].type === 'inline' &&\n tokens[i + 1].content.match(ALERT_RE)\n );\n}\n\nexport function matchWrongNotes(tokens: readonly NoteToken[], i: number) {\n return (\n tokens[i].type === 'paragraph_open' &&\n tokens[i + 1].type === 'inline' &&\n tokens[i + 1].content.match(WRONG_NOTES)\n );\n}\n\nexport type NoteBoundary = {\n readonly map: readonly [number, number] | null;\n readonly raw: string;\n} & (\n | {\n readonly kind: 'open';\n readonly type: 'info' | 'tip' | 'warning' | 'alert';\n readonly title:\n | {readonly present: false}\n | {readonly present: true; readonly raw: string};\n }\n | {readonly kind: 'close' | 'unsupported'}\n);\n\n/**\n * Classify an original core paragraph without modifying it.\n * @param tokens - The original block token array.\n * @param i - The candidate paragraph token index.\n * @returns A copied boundary observation when recognized.\n */\nexport function recognizeNoteBoundary(\n tokens: readonly NoteToken[],\n i: number,\n): NoteBoundary | undefined {\n if (!tokens[i] || !tokens[i + 1]) return undefined;\n const match = matchOpenToken(tokens, i);\n const close = !match && matchCloseToken(tokens, i);\n const wrong = !match && !close && matchWrongNotes(tokens, i);\n if (!match && !close && !wrong) return undefined;\n const map = tokens[i].map;\n const common = {map: map ? ([map[0], map[1]] as const) : null, raw: tokens[i + 1].content};\n if (match) {\n const type = (['info', 'tip', 'warning', 'alert'] as const).find(\n (item) => item === match[1].toLowerCase(),\n );\n if (!type) throw new Error('Invalid recognized note type');\n return {\n kind: 'open',\n ...common,\n type,\n title: match[2] === undefined ? {present: false} : {present: true, raw: match[2]},\n };\n }\n return {kind: close ? 'close' : 'unsupported', ...common};\n}\n", "import type {\n NoteParser,\n NoteState,\n NoteToken,\n NotesDirectivePlugin,\n NotesFactoryOptions,\n NotesOptions,\n NotesPlugin,\n} from './types.js';\nimport type {NoteMarker} from './directive.js';\n\nimport {createNestedCloseTokenIdxFactory} from './close.js';\nimport {DEFAULT_LANG, TITLES} from './const.js';\nimport {installNoteDirective} from './directive.js';\nimport {matchCloseToken, matchOpenToken, matchWrongNotes} from './recognize.js';\n\nconst quietLogger = {warn: (_message: string) => {}, error: (_message: string) => {}};\n\nconst titleDictionaries = new Map(Object.entries(TITLES));\n\nfunction getTitle(type: string, lang: string) {\n return (titleDictionaries.get(lang) ?? TITLES.ru)[type];\n}\n\ntype NoteEmission = {\n start: number;\n close: number;\n bodyStart: number;\n removeCount: number;\n type: string;\n title: string;\n contentMap?: [number, number];\n};\n\nfunction emitNote<Token extends NoteToken>(state: NoteState<Token>, note: NoteEmission): void {\n const {tokens, env} = state;\n const open = new state.Token('yfm_note_open', 'div', 1);\n open.attrSet('class', `yfm-note yfm-accent-${note.type}`);\n open.attrSet('note-type', note.type);\n open.map = tokens[note.start].map;\n const closeMap = tokens[note.close].map;\n if (closeMap && open.map) open.map[1] = closeMap[1];\n const close = new state.Token('yfm_note_close', 'div', -1);\n close.map = closeMap;\n const titleOpen = new state.Token('yfm_note_title_open', 'p', 1);\n titleOpen.attrSet('class', 'yfm-note-title');\n const titleInline = state.md.parseInline(note.title, env)[0];\n titleInline.map = null;\n const titleClose = new state.Token('yfm_note_title_close', 'p', -1);\n titleOpen.block = true;\n titleClose.block = true;\n const contentOpen = new state.Token('yfm_note_content_open', 'div', 1);\n contentOpen.attrSet('class', 'yfm-note-content');\n const contentClose = new state.Token('yfm_note_content_close', 'div', -1);\n if (open.map) contentOpen.map = note.contentMap ?? [open.map[0] + 2, open.map[1] - 2];\n const inside = [open];\n if (titleInline.content) inside.push(titleOpen, titleInline, titleClose);\n inside.push(contentOpen, ...tokens.slice(note.bodyStart, note.close), contentClose, close);\n tokens.splice(note.start, note.removeCount, ...inside);\n}\n\nfunction validateMarkers(tokens: NoteToken[], markers: WeakMap<object, NoteMarker>): void {\n const expected: object[] = [];\n for (const token of tokens) {\n const marker = markers.get(token);\n if (\n !marker &&\n (token.type === 'yfm_note_directive_open' || token.type === 'yfm_note_directive_close')\n ) {\n throw new Error('Unowned note directive marker');\n }\n if (marker?.kind === 'open') expected.push(marker.end);\n else if (marker?.kind === 'close' && expected.pop() !== token) {\n throw new Error('Note directive opening marker is missing or crossed');\n }\n }\n if (expected.length) throw new Error('Note directive closing marker is missing');\n}\n\n/**\n * Bind existing feature diagnostics to an execution-host path formatter.\n * @param formatPath - Original terminal or plain browser formatting.\n * @param onNote - Optional host resource notification after a real note is created.\n * @returns The unchanged feature callback.\n */\nexport function createNotesPlugin(\n formatPath?: (path: string) => string,\n onNote?: (env: Record<string, unknown>) => void,\n): NotesPlugin;\nexport function createNotesPlugin(\n formatPath: ((path: string) => string) | undefined,\n onNote: ((env: Record<string, unknown>) => void) | undefined,\n factory: NotesFactoryOptions & {directiveSyntax: 'disabled'},\n): NotesPlugin;\nexport function createNotesPlugin(\n formatPath: ((path: string) => string) | undefined,\n onNote: ((env: Record<string, unknown>) => void) | undefined,\n factory: NotesFactoryOptions & {directiveSyntax: 'enabled' | 'only'},\n): NotesDirectivePlugin;\nexport function createNotesPlugin(\n formatPath: ((path: string) => string) | undefined,\n onNote: ((env: Record<string, unknown>) => void) | undefined,\n factory: NotesFactoryOptions,\n): NotesPlugin | NotesDirectivePlugin;\nexport function createNotesPlugin(\n formatPath: (path: string) => string = (path) => path,\n onNote?: (env: Record<string, unknown>) => void,\n factory: NotesFactoryOptions = {},\n): NotesPlugin | NotesDirectivePlugin {\n const findCloseTokenIdx = createNestedCloseTokenIdxFactory(formatPath)(\n 'Note',\n matchOpenToken,\n matchCloseToken,\n );\n\n const installCore = <Token extends NoteToken>(\n md: NoteParser<Token>,\n {lang = DEFAULT_LANG, notesAutotitle, path: optPath, log = quietLogger}: NotesOptions = {},\n markers: WeakMap<object, NoteMarker>,\n legacy: boolean,\n directiveEnabled: boolean,\n ): void => {\n notesAutotitle = typeof notesAutotitle === 'boolean' ? notesAutotitle : true;\n\n const processNote = (\n state: NoteState<Token>,\n start: number,\n marker: Extract<NoteMarker, {kind: 'open'}> | undefined,\n match: ReturnType<typeof matchOpenToken>,\n path: string,\n ): number => {\n const {tokens, env} = state;\n const closeTokenIdx = marker\n ? tokens.findIndex((token, index) => index > start && token === marker.end)\n : findCloseTokenIdx(tokens, start + 2, path, log);\n if (marker && (closeTokenIdx === null || closeTokenIdx < 0)) {\n throw new Error('Note directive closing marker is missing');\n }\n if (!closeTokenIdx) return start + 3;\n const type = marker ? marker.type : match && match[1].toLowerCase();\n if (!type) throw new Error('Note type is missing');\n let authoredTitle: string | undefined;\n if (marker) authoredTitle = marker.title;\n else if (match) authoredTitle = match[2];\n let title = authoredTitle;\n if (title === undefined) title = notesAutotitle ? getTitle(type, lang) : '';\n emitNote(state, {\n start,\n close: closeTokenIdx,\n bodyStart: start + (marker ? 1 : 3),\n removeCount: closeTokenIdx - start + (marker ? 1 : 3),\n type,\n title,\n contentMap: marker?.contentMap,\n });\n onNote?.(env);\n return start + 1;\n };\n\n const plugin = (state: NoteState<Token>) => {\n const {tokens, env} = state;\n if (directiveEnabled) validateMarkers(tokens, markers);\n const path = typeof env.path === 'string' && env.path ? env.path : (optPath ?? '');\n let i = 0;\n while (i < tokens.length) {\n const marker = markers.get(tokens[i]);\n if (marker?.kind === 'close') {\n throw new Error('Note directive opening marker is missing');\n }\n const match = legacy && matchOpenToken(tokens, i);\n if (marker || match) {\n i = processNote(state, i, marker, match, path);\n } else if (\n legacy &&\n matchWrongNotes(tokens, i) &&\n tokens[i + 1].content !== '{% endnote %}'\n ) {\n log.warn(\n `Incorrect syntax for notes${path ? `, file ${formatPath(path)}` : ''}`,\n );\n i += 3;\n } else {\n i++;\n }\n }\n };\n\n try {\n md.core.ruler.before('curly_attributes', 'notes', plugin);\n } catch {\n md.core.ruler.push('notes', plugin);\n }\n };\n\n if (!factory.directiveSyntax || factory.directiveSyntax === 'disabled') {\n const legacyPlugin: NotesPlugin = (md, options) =>\n installCore(md, options, new WeakMap(), true, false);\n return legacyPlugin;\n }\n const directivePlugin: NotesDirectivePlugin = (md, options) => {\n const markers = new WeakMap<object, NoteMarker>();\n installNoteDirective(md, markers, factory.onDiagnostic);\n installCore(md, options, markers, factory.directiveSyntax === 'enabled', true);\n };\n return directivePlugin;\n}\n", "import type {NotesOptions} from './types.js';\n\nexport type Runtime = {style: string; script?: string};\nexport type RuntimeOption = false | string | Runtime;\n\nexport function normalizeRuntime(runtime?: RuntimeOption, bundle = false): Runtime | false {\n if (runtime === false) return false;\n if (typeof runtime === 'string') {\n if (bundle)\n throw new TypeError('Option `runtime` should be record when `bundle` is enabled.');\n return {script: runtime, style: runtime};\n }\n return runtime ?? {style: '_assets/notes-extension.css'};\n}\n\nexport function semanticOptions(defaults: NotesOptions, settings: NotesOptions): NotesOptions {\n return {\n lang: settings.lang === undefined ? defaults.lang : settings.lang,\n notesAutotitle:\n settings.notesAutotitle === undefined\n ? defaults.notesAutotitle\n : settings.notesAutotitle,\n path: settings.path === undefined ? defaults.path : settings.path,\n log: settings.log === undefined ? defaults.log : settings.log,\n };\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value);\n}\n\nexport function addResources(env: Record<string, unknown>, runtime: Runtime): void {\n const previous = env.meta;\n if (previous !== undefined && !isRecord(previous)) {\n throw new TypeError('Notes resource metadata must be an object.');\n }\n const meta = {...previous};\n for (const key of ['style', 'script'] as const) {\n const resource = runtime[key];\n if (!resource) continue;\n const existing = meta[key];\n let values: unknown[] = [];\n if (Array.isArray(existing)) values = [...existing];\n else if (existing !== undefined) values = [existing];\n if (!values.includes(resource)) values.push(resource);\n meta[key] = values;\n }\n env.meta = meta;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACUA,yBAA4B;AAC5B,sBAA2C;AAC3C,qBAAsC;AACtC,uBAAqC;;;ACN9B,SAAS,iCAAiC,YAAsC;AACnF,QAAM,6BACF,CACI,WACAA,iBACAC,qBAEJ,CAAC,QAAqB,KAAa,MAAc,QAAqB;AAClE,QAAI,QAAQ;AACZ,QAAI,IAAI;AACR,WAAO,IAAI,OAAO,QAAQ;AACtB,UAAID,gBAAe,QAAQ,CAAC,GAAG;AAC3B;AAAA,MACJ,WAAWC,iBAAgB,QAAQ,CAAC,GAAG;AACnC,YAAI,UAAU,GAAG;AACb,iBAAO;AAAA,QACX;AACA;AAAA,MACJ;AAEA;AAAA,IACJ;AAEA,QAAI,MAAM,GAAG,SAAS,kBAAkB,OAAO,OAAO,WAAW,IAAI,CAAC,KAAK,EAAE,EAAE;AAE/E,WAAO;AAAA,EACX;AAEJ,SAAO;AACX;;;ACnCO,IAAM,eAAe;AAoBrB,IAAM,SAA+C;AAAA,EACxD,IAAI;AAAA,IACA,MAAM;AAAA,IACN,KAAK;AAAA,IACL,OAAO;AAAA,IACP,SAAS;AAAA,EACb;AAAA,EACA,IAAI;AAAA,IACA,MAAM;AAAA,IACN,KAAK;AAAA,IACL,OAAO;AAAA,IACP,SAAS;AAAA,EACb;AAAA,EACA,IAAI;AAAA,IACA,MAAM;AAAA,IACN,KAAK;AAAA,IACL,OAAO;AAAA,IACP,SAAS;AAAA,EACb;AAAA,EACA,IAAI;AAAA,IACA,MAAM;AAAA,IACN,KAAK;AAAA,IACL,OAAO;AAAA,IACP,SAAS;AAAA,EACb;AAAA,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ACA,kBAAY,SAAS,SAAS,UAAU,KAAK,MAAM;AAAA,IACvD;AAAA,EACJ,IACA;AACV,WAAS,aACL,IACA,WAA0B,CAAC,GACvB;AACJ,sBAAkB,QAAW,OAAO,QAAQ,CAAC,EAAE,IAAI,gBAAgB,SAAS,QAAQ,CAAC;AAAA,EACzF;AACA,QAAM,OAAO,QAAQ;AACrB,WAAS,gBAKL,IACA,WAA0B,CAAC,GACvB;AACJ,QAAI,SAAS,aAAa,SAAS,OAAQ,OAAM,IAAI,MAAM,4BAA4B;AACvF,sBAAkB,QAAW,OAAO,QAAQ,GAAG;AAAA,MAC3C,iBAAiB;AAAA,MACjB,cAAc,QAAQ;AAAA,IAC1B,CAAC,EAAE,IAAI,gBAAgB,SAAS,QAAQ,CAAC;AAAA,EAC7C;AACA,QAAM,YAAY;AAAA,IACd,QAAQ,OAAe,EAAC,WAAW,KAAK,GAAG,SAAQ,IAAoB,CAAC,GAAS;AAC7E,YAAM,iBACF,kCAAc,UAAe,EAAE,aAAa;AAChD,YAAM,KAAK,IAAI,WAAW;AAC1B,UAAI,SAAS,aAAa,SAAS;AAC/B,WAAG,IAAI,iBAAiB,EAAC,GAAG,UAAU,QAAQ,SAAQ,CAAC;AAAA,UACtD,IAAG,IAAI,cAAc,EAAC,GAAG,UAAU,QAAQ,SAAQ,CAAC;AACzD,SAAG,MAAM,OAAO,CAAC,CAAC;AAAA,IACtB;AAAA,EACJ;AACA,SAAO,SAAS,aAAa,SAAS,SAChC,OAAO,OAAO,iBAAiB,SAAS,IACxC,OAAO,OAAO,cAAc,SAAS;AAC/C;;;ADxGA,IAAO,iBAAQ,EAAC,WAAW,UAAS;",
6
+ "names": ["matchOpenToken", "matchCloseToken"]
7
+ }
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -0,0 +1,7 @@
1
+ import type { MatchTokenFunction, NoteToken, NotesLogger } from './types.js';
2
+ /**
3
+ * Bind the existing close-token search to the host's path formatter.
4
+ * @param formatPath - Plain browser or original terminal path formatting.
5
+ * @returns The existing finite token-search factory.
6
+ */
7
+ export declare function createNestedCloseTokenIdxFactory(formatPath: (path: string) => string): (tokenName: string, matchOpenToken: MatchTokenFunction, matchCloseToken: MatchTokenFunction) => (tokens: NoteToken[], idx: number, path: string, log: NotesLogger) => number | null;
@@ -0,0 +1,19 @@
1
+ export declare const ENV_FLAG_NAME = "has-yfm-notes";
2
+ export declare const DEFAULT_LANG = "ru";
3
+ export type Lang = 'ru' | 'en' | 'ar' | 'cs' | 'fr' | 'es' | 'he' | 'bg' | 'et' | 'el' | 'pt' | 'zh' | 'zh-tw' | 'kk' | 'tr' | 'uz';
4
+ export declare const TITLES: Record<Lang, Record<string, string>>;
5
+ export declare const TokenType: {
6
+ readonly Note: "yfm-note";
7
+ readonly NoteOpen: "yfm_note_open";
8
+ readonly NoteClose: "yfm_note_close";
9
+ readonly NoteTitleOpen: "yfm_note_title_open";
10
+ readonly NoteTitleClose: "yfm_note_title_close";
11
+ readonly NoteContentOpen: "yfm_note_content_open";
12
+ readonly NoteContentClose: "yfm_note_content_close";
13
+ };
14
+ export declare const ClassNames: {
15
+ readonly Note: "yfm-note";
16
+ readonly Accent: "yfm-accent";
17
+ readonly Title: "yfm-note-title";
18
+ readonly Content: "yfm-note-content";
19
+ };
@@ -0,0 +1,12 @@
1
+ import type { BlockContentState, DirectiveBlockState, DirectiveInlineState, DirectiveParserHost } from '@diplodoc/directive';
2
+ import type { NotesDirectiveDiagnostic } from './types.js';
3
+ export type NoteMarker = {
4
+ kind: 'open';
5
+ end: object;
6
+ type: string;
7
+ title: string | undefined;
8
+ contentMap: [number, number];
9
+ } | {
10
+ kind: 'close';
11
+ };
12
+ export declare function installNoteDirective<B extends DirectiveBlockState & BlockContentState<B>, I extends DirectiveInlineState>(md: DirectiveParserHost<B, I>, markers: WeakMap<object, NoteMarker>, onDiagnostic?: (diagnostic: NotesDirectiveDiagnostic) => void): void;
@@ -0,0 +1,18 @@
1
+ import { transform } from './transform.js';
2
+ import { TokenType } from './const.js';
3
+ export { transform, TokenType };
4
+ export type { TransformOptions, NotesTransformPlugin, NotesDirectiveTransformPlugin, PluginOptions, CollectOptions, } from './transform.js';
5
+ export type { NotesOptions, NotesLogger, NotesDirectiveDiagnostic, NotesFactoryOptions, NotesDirectivePlugin, } from './types.js';
6
+ declare const _default: {
7
+ transform: typeof transform;
8
+ TokenType: {
9
+ readonly Note: "yfm-note";
10
+ readonly NoteOpen: "yfm_note_open";
11
+ readonly NoteClose: "yfm_note_close";
12
+ readonly NoteTitleOpen: "yfm_note_title_open";
13
+ readonly NoteTitleClose: "yfm_note_title_close";
14
+ readonly NoteContentOpen: "yfm_note_content_open";
15
+ readonly NoteContentClose: "yfm_note_content_close";
16
+ };
17
+ };
18
+ export default _default;
@@ -0,0 +1,15 @@
1
+ import type { NotesDirectivePlugin, NotesFactoryOptions, NotesPlugin } from './types.js';
2
+ /**
3
+ * Bind existing feature diagnostics to an execution-host path formatter.
4
+ * @param formatPath - Original terminal or plain browser formatting.
5
+ * @param onNote - Optional host resource notification after a real note is created.
6
+ * @returns The unchanged feature callback.
7
+ */
8
+ export declare function createNotesPlugin(formatPath?: (path: string) => string, onNote?: (env: Record<string, unknown>) => void): NotesPlugin;
9
+ export declare function createNotesPlugin(formatPath: ((path: string) => string) | undefined, onNote: ((env: Record<string, unknown>) => void) | undefined, factory: NotesFactoryOptions & {
10
+ directiveSyntax: 'disabled';
11
+ }): NotesPlugin;
12
+ export declare function createNotesPlugin(formatPath: ((path: string) => string) | undefined, onNote: ((env: Record<string, unknown>) => void) | undefined, factory: NotesFactoryOptions & {
13
+ directiveSyntax: 'enabled' | 'only';
14
+ }): NotesDirectivePlugin;
15
+ export declare function createNotesPlugin(formatPath: ((path: string) => string) | undefined, onNote: ((env: Record<string, unknown>) => void) | undefined, factory: NotesFactoryOptions): NotesPlugin | NotesDirectivePlugin;
@@ -0,0 +1,6 @@
1
+ export { createNotesPlugin } from './plugin.js';
2
+ export { TokenType, TITLES, DEFAULT_LANG } from './const.js';
3
+ export type { Lang } from './const.js';
4
+ export type { NoteParser, NoteState, NoteToken, NotesLogger, NotesOptions, NotesPlugin, NotesDirectivePlugin, NotesDirectiveDiagnostic, NotesFactoryOptions, } from './types.js';
5
+ export { recognizeNoteBoundary } from './recognize.js';
6
+ export type { NoteBoundary } from './recognize.js';