@diplodoc/notes-extension 0.1.0-transform5.0 → 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.
- package/README.md +17 -1
- package/build/cjs/browser/index.d.ts +10 -4
- package/build/cjs/browser.js +161 -63
- package/build/cjs/browser.js.map +3 -3
- package/build/cjs/index.js +179 -78
- package/build/cjs/index.js.map +3 -3
- package/build/cjs/plugin/directive.d.ts +12 -0
- package/build/cjs/plugin/index.d.ts +2 -2
- package/build/cjs/plugin/plugin.d.ts +8 -1
- package/build/cjs/plugin/pure.d.ts +3 -1
- package/build/cjs/plugin/recognize.d.ts +26 -0
- package/build/cjs/plugin/transform.d.ts +14 -3
- package/build/cjs/plugin/types.d.ts +10 -0
- package/build/cjs/plugin.js +176 -61
- package/build/cjs/plugin.js.map +3 -3
- package/build/esm/browser/index.d.ts +10 -4
- package/build/esm/browser.js +165 -63
- package/build/esm/browser.js.map +3 -3
- package/build/esm/index.js +183 -78
- package/build/esm/index.js.map +3 -3
- package/build/esm/plugin/directive.d.ts +12 -0
- package/build/esm/plugin/index.d.ts +2 -2
- package/build/esm/plugin/plugin.d.ts +8 -1
- package/build/esm/plugin/pure.d.ts +3 -1
- package/build/esm/plugin/recognize.d.ts +26 -0
- package/build/esm/plugin/transform.d.ts +14 -3
- package/build/esm/plugin/types.d.ts +10 -0
- package/build/esm/plugin.js +178 -60
- package/build/esm/plugin.js.map +3 -3
- package/build/types/browser/index.d.ts +10 -4
- package/build/types/plugin/directive.d.ts +12 -0
- package/build/types/plugin/index.d.ts +2 -2
- package/build/types/plugin/plugin.d.ts +8 -1
- package/build/types/plugin/pure.d.ts +3 -1
- package/build/types/plugin/recognize.d.ts +26 -0
- package/build/types/plugin/transform.d.ts +14 -3
- package/build/types/plugin/types.d.ts +10 -0
- package/package.json +16 -8
package/README.md
CHANGED
|
@@ -28,7 +28,17 @@ The root exports named `transform` and `TokenType`, and a default namespace cont
|
|
|
28
28
|
|
|
29
29
|
`lang`, `notesAutotitle`, `path` and `log` may be supplied as factory defaults or through the real `md.use(plugin, settings)` call. Defined callback settings override factory defaults. Language defaults to Russian, matching the accepted Transform notes behavior. Supported languages are ru, en, ar, cs, fr, es, he, bg, et, el, pt, zh, zh-tw, kk, tr and uz; unknown/empty values fall back to Russian.
|
|
30
30
|
|
|
31
|
-
Automatic titles remain enabled by default. `notesAutotitle: false` disables only the automatic title; explicit titles, inline title markup and explicit empty `""` titles retain their meaning. Supported kinds are info, tip, alert and warning.
|
|
31
|
+
Automatic titles remain enabled by default. `notesAutotitle: false` disables only the automatic title; explicit titles, inline title markup and explicit empty `""` titles retain their meaning. Supported kinds are info, tip, alert and warning.
|
|
32
|
+
|
|
33
|
+
Directive syntax is opt-in at factory time: `transform({directiveSyntax: 'enabled'})` accepts both forms, while `'only'` accepts directive notes alone. The default `'disabled'` preserves the legacy-only standalone behavior. The pure factory accepts the same setting as its third argument, for example `createNotesPlugin(undefined, undefined, {directiveSyntax: 'enabled'})`; changing `md.use` settings does not change this mode. Enabled modes require a host with the Directive parser capabilities as well as the Notes core capabilities.
|
|
34
|
+
|
|
35
|
+
```markdown
|
|
36
|
+
:::note [Optional *title*] {type=info}
|
|
37
|
+
Body
|
|
38
|
+
:::
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
`type` is required and must be `info`, `tip`, `warning` or `alert`. An omitted title uses the localized automatic title when enabled; `[]` suppresses it. Other attributes and destinations are unsupported. An optional factory `onDiagnostic({line, reason})` reports recognized invalid parameters; invalid blocks fall back to ordinary Markdown, which may still parse an independently valid nested directive. Syntax the upstream parser does not recognize may not reach this callback.
|
|
32
42
|
|
|
33
43
|
A supplied logger must implement both `warn` and `error`. Incorrect syntax is a warning; an unclosed note is an error. Messages and path precedence match the accepted implementation. Omitting the logger is explicitly quiet; it does not create a global logger.
|
|
34
44
|
|
|
@@ -46,6 +56,12 @@ Render HTML inside a `.yfm` container. The browser entry does not import Node mo
|
|
|
46
56
|
|
|
47
57
|
`@diplodoc/notes-extension/plugin` exposes the pure `createNotesPlugin(formatPath?, onNote?)` factory, `TokenType`, the canonical `TITLES` dictionary, `DEFAULT_LANG`, and finite public types including `Lang`. The dictionary exports let retained Transform constants paths delegate to this single source. It emits no assets. Transform's built-in bridge can bind its existing diagnostic formatter and reuse its own bundled styles. No private MarkdownIt State imports or Transform dependency are required.
|
|
48
58
|
|
|
59
|
+
## Recognizing legacy note boundaries
|
|
60
|
+
|
|
61
|
+
`recognizeNoteBoundary(tokens, index)` is exported from `@diplodoc/notes-extension/plugin` for tools that inspect the original MarkdownIt block tokens **before** the Notes core rule transforms them. It classifies the paragraph at `index` as a legacy `open`, `close`, or `unsupported` boundary, or returns `undefined`. An open result includes the note type and an authored `title`: `{present: false}` means no title was supplied, while `{present: true, raw: ''}` is an explicit empty title.
|
|
62
|
+
|
|
63
|
+
The result contains a copied, readonly zero-based, half-open `map` of normalized source lines (or `null`) and the inline token's `raw` content, which may span multiple lines. It does not modify tokens, pair boundaries, validate a whole document, or calculate UTF-16 offsets into the original source. Callers must map normalized positions back to the original input and handle missing or ambiguous ranges conservatively.
|
|
64
|
+
|
|
49
65
|
## Resources and styles
|
|
50
66
|
|
|
51
67
|
- Default standalone resource: `_assets/notes-extension.css`. Notes have no active client JavaScript behavior; no script is emitted by default.
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
import type { NotesOptions, NotesPlugin } from '../plugin/types.js';
|
|
1
|
+
import type { NotesDirectivePlugin, NotesFactoryOptions, NotesOptions, NotesPlugin } from '../plugin/types.js';
|
|
2
2
|
import type { RuntimeOption } from '../plugin/resources.js';
|
|
3
3
|
import { TokenType } from '../plugin/const.js';
|
|
4
|
-
export type TransformOptions = NotesOptions & {
|
|
4
|
+
export type TransformOptions = NotesOptions & NotesFactoryOptions & {
|
|
5
5
|
runtime?: RuntimeOption;
|
|
6
6
|
bundle?: false;
|
|
7
7
|
};
|
|
8
|
-
export declare function transform(options?: TransformOptions
|
|
8
|
+
export declare function transform(options?: TransformOptions & {
|
|
9
|
+
directiveSyntax?: 'disabled';
|
|
10
|
+
}): NotesPlugin;
|
|
11
|
+
export declare function transform(options: TransformOptions & {
|
|
12
|
+
directiveSyntax: 'enabled' | 'only';
|
|
13
|
+
}): NotesDirectivePlugin;
|
|
14
|
+
export declare function transform(options: TransformOptions): NotesPlugin | NotesDirectivePlugin;
|
|
9
15
|
export { TokenType };
|
|
10
|
-
export type { NotesOptions, NotesLogger } from '../plugin/types.js';
|
|
16
|
+
export type { NotesOptions, NotesLogger, NotesDirectiveDiagnostic, NotesFactoryOptions, NotesDirectivePlugin, } from '../plugin/types.js';
|
|
11
17
|
declare const _default: {
|
|
12
18
|
transform: typeof transform;
|
|
13
19
|
TokenType: {
|
package/build/cjs/browser.js
CHANGED
|
@@ -158,18 +158,63 @@ var TokenType = {
|
|
|
158
158
|
NoteContentClose: "yfm_note_content_close"
|
|
159
159
|
};
|
|
160
160
|
|
|
161
|
-
// src/plugin/
|
|
162
|
-
var
|
|
163
|
-
|
|
164
|
-
|
|
161
|
+
// src/plugin/directive.ts
|
|
162
|
+
var import_directive = require("@diplodoc/directive");
|
|
163
|
+
function invalidReason(params, state) {
|
|
164
|
+
if (params.dests) {
|
|
165
|
+
const suffix = params.inlineContent ? state.src.slice(params.inlineContent.endPos + 1, state.eMarks[params.startLine]).trimStart() : "";
|
|
166
|
+
if (!params.inlineContent || suffix.startsWith("(") || suffix.startsWith("[")) {
|
|
167
|
+
return "Destinations are not supported for note directives";
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (params.contentTitle) return "Invalid note directive parameters";
|
|
171
|
+
const attrs = params.attrs ?? {};
|
|
172
|
+
for (const name of Object.keys(attrs)) {
|
|
173
|
+
if (name !== "type") return `Unknown note attribute: ${name}`;
|
|
174
|
+
}
|
|
175
|
+
if (Array.isArray(attrs.type)) return "Repeated note attribute: type";
|
|
176
|
+
if (!attrs.type || !["info", "tip", "warning", "alert"].includes(attrs.type)) {
|
|
177
|
+
return "Note type must be info, tip, warning or alert";
|
|
178
|
+
}
|
|
179
|
+
return void 0;
|
|
180
|
+
}
|
|
181
|
+
function installNoteDirective(md, markers, onDiagnostic) {
|
|
182
|
+
(0, import_directive.directiveParser)()(md);
|
|
183
|
+
(0, import_directive.registerContainerDirective)(
|
|
184
|
+
md,
|
|
185
|
+
"note",
|
|
186
|
+
(state, params) => {
|
|
187
|
+
const reason = invalidReason(params, state);
|
|
188
|
+
if (reason) {
|
|
189
|
+
onDiagnostic?.({ line: params.startLine + 1, reason });
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
const type = params.attrs?.type;
|
|
193
|
+
if (typeof type !== "string") throw new Error("Invalid validated note type");
|
|
194
|
+
const open = state.push("yfm_note_directive_open", "", 0);
|
|
195
|
+
open.map = [params.startLine, params.endLine];
|
|
196
|
+
(0, import_directive.tokenizeBlockContent)(state, params.content, "note-directive");
|
|
197
|
+
const close = state.push("yfm_note_directive_close", "", 0);
|
|
198
|
+
close.map = [params.endLine - 1, params.endLine];
|
|
199
|
+
markers.set(open, {
|
|
200
|
+
kind: "open",
|
|
201
|
+
end: close,
|
|
202
|
+
type,
|
|
203
|
+
title: params.inlineContent?.raw,
|
|
204
|
+
contentMap: [params.content.startLine, params.content.endLine]
|
|
205
|
+
});
|
|
206
|
+
markers.set(close, { kind: "close" });
|
|
207
|
+
return true;
|
|
208
|
+
},
|
|
209
|
+
{ onConflict: "error" }
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// src/plugin/recognize.ts
|
|
165
214
|
var ALERT_RE = /^{% note (alert|info|tip|warning)\s*(?:"(.*?)")? %}$/;
|
|
166
215
|
var WRONG_NOTES = /^{% note (.*)%}/;
|
|
167
|
-
|
|
216
|
+
function matchCloseToken(tokens, i) {
|
|
168
217
|
return tokens[i].type === "paragraph_open" && tokens[i + 1].type === "inline" && tokens[i + 1].content.trim() === "{% endnote %}";
|
|
169
|
-
};
|
|
170
|
-
var titleDictionaries = new Map(Object.entries(TITLES));
|
|
171
|
-
function getTitle(type, lang) {
|
|
172
|
-
return (titleDictionaries.get(lang) ?? TITLES.ru)[type];
|
|
173
218
|
}
|
|
174
219
|
function matchOpenToken(tokens, i) {
|
|
175
220
|
return tokens[i].type === "paragraph_open" && tokens[i + 1].type === "inline" && tokens[i + 1].content.match(ALERT_RE);
|
|
@@ -177,66 +222,103 @@ function matchOpenToken(tokens, i) {
|
|
|
177
222
|
function matchWrongNotes(tokens, i) {
|
|
178
223
|
return tokens[i].type === "paragraph_open" && tokens[i + 1].type === "inline" && tokens[i + 1].content.match(WRONG_NOTES);
|
|
179
224
|
}
|
|
180
|
-
|
|
225
|
+
|
|
226
|
+
// src/plugin/plugin.ts
|
|
227
|
+
var quietLogger = { warn: (_message) => {
|
|
228
|
+
}, error: (_message) => {
|
|
229
|
+
} };
|
|
230
|
+
var titleDictionaries = new Map(Object.entries(TITLES));
|
|
231
|
+
function getTitle(type, lang) {
|
|
232
|
+
return (titleDictionaries.get(lang) ?? TITLES.ru)[type];
|
|
233
|
+
}
|
|
234
|
+
function emitNote(state, note) {
|
|
235
|
+
const { tokens, env } = state;
|
|
236
|
+
const open = new state.Token("yfm_note_open", "div", 1);
|
|
237
|
+
open.attrSet("class", `yfm-note yfm-accent-${note.type}`);
|
|
238
|
+
open.attrSet("note-type", note.type);
|
|
239
|
+
open.map = tokens[note.start].map;
|
|
240
|
+
const closeMap = tokens[note.close].map;
|
|
241
|
+
if (closeMap && open.map) open.map[1] = closeMap[1];
|
|
242
|
+
const close = new state.Token("yfm_note_close", "div", -1);
|
|
243
|
+
close.map = closeMap;
|
|
244
|
+
const titleOpen = new state.Token("yfm_note_title_open", "p", 1);
|
|
245
|
+
titleOpen.attrSet("class", "yfm-note-title");
|
|
246
|
+
const titleInline = state.md.parseInline(note.title, env)[0];
|
|
247
|
+
titleInline.map = null;
|
|
248
|
+
const titleClose = new state.Token("yfm_note_title_close", "p", -1);
|
|
249
|
+
titleOpen.block = true;
|
|
250
|
+
titleClose.block = true;
|
|
251
|
+
const contentOpen = new state.Token("yfm_note_content_open", "div", 1);
|
|
252
|
+
contentOpen.attrSet("class", "yfm-note-content");
|
|
253
|
+
const contentClose = new state.Token("yfm_note_content_close", "div", -1);
|
|
254
|
+
if (open.map) contentOpen.map = note.contentMap ?? [open.map[0] + 2, open.map[1] - 2];
|
|
255
|
+
const inside = [open];
|
|
256
|
+
if (titleInline.content) inside.push(titleOpen, titleInline, titleClose);
|
|
257
|
+
inside.push(contentOpen, ...tokens.slice(note.bodyStart, note.close), contentClose, close);
|
|
258
|
+
tokens.splice(note.start, note.removeCount, ...inside);
|
|
259
|
+
}
|
|
260
|
+
function validateMarkers(tokens, markers) {
|
|
261
|
+
const expected = [];
|
|
262
|
+
for (const token of tokens) {
|
|
263
|
+
const marker = markers.get(token);
|
|
264
|
+
if (!marker && (token.type === "yfm_note_directive_open" || token.type === "yfm_note_directive_close")) {
|
|
265
|
+
throw new Error("Unowned note directive marker");
|
|
266
|
+
}
|
|
267
|
+
if (marker?.kind === "open") expected.push(marker.end);
|
|
268
|
+
else if (marker?.kind === "close" && expected.pop() !== token) {
|
|
269
|
+
throw new Error("Note directive opening marker is missing or crossed");
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
if (expected.length) throw new Error("Note directive closing marker is missing");
|
|
273
|
+
}
|
|
274
|
+
function createNotesPlugin(formatPath = (path) => path, onNote, factory = {}) {
|
|
181
275
|
const findCloseTokenIdx = createNestedCloseTokenIdxFactory(formatPath)(
|
|
182
276
|
"Note",
|
|
183
277
|
matchOpenToken,
|
|
184
278
|
matchCloseToken
|
|
185
279
|
);
|
|
186
|
-
const
|
|
280
|
+
const installCore = (md, { lang = DEFAULT_LANG, notesAutotitle, path: optPath, log = quietLogger } = {}, markers, legacy, directiveEnabled) => {
|
|
187
281
|
notesAutotitle = typeof notesAutotitle === "boolean" ? notesAutotitle : true;
|
|
282
|
+
const processNote = (state, start, marker, match, path) => {
|
|
283
|
+
const { tokens, env } = state;
|
|
284
|
+
const closeTokenIdx = marker ? tokens.findIndex((token, index) => index > start && token === marker.end) : findCloseTokenIdx(tokens, start + 2, path, log);
|
|
285
|
+
if (marker && (closeTokenIdx === null || closeTokenIdx < 0)) {
|
|
286
|
+
throw new Error("Note directive closing marker is missing");
|
|
287
|
+
}
|
|
288
|
+
if (!closeTokenIdx) return start + 3;
|
|
289
|
+
const type = marker ? marker.type : match && match[1].toLowerCase();
|
|
290
|
+
if (!type) throw new Error("Note type is missing");
|
|
291
|
+
let authoredTitle;
|
|
292
|
+
if (marker) authoredTitle = marker.title;
|
|
293
|
+
else if (match) authoredTitle = match[2];
|
|
294
|
+
let title = authoredTitle;
|
|
295
|
+
if (title === void 0) title = notesAutotitle ? getTitle(type, lang) : "";
|
|
296
|
+
emitNote(state, {
|
|
297
|
+
start,
|
|
298
|
+
close: closeTokenIdx,
|
|
299
|
+
bodyStart: start + (marker ? 1 : 3),
|
|
300
|
+
removeCount: closeTokenIdx - start + (marker ? 1 : 3),
|
|
301
|
+
type,
|
|
302
|
+
title,
|
|
303
|
+
contentMap: marker?.contentMap
|
|
304
|
+
});
|
|
305
|
+
onNote?.(env);
|
|
306
|
+
return start + 1;
|
|
307
|
+
};
|
|
188
308
|
const plugin = (state) => {
|
|
189
309
|
const { tokens, env } = state;
|
|
310
|
+
if (directiveEnabled) validateMarkers(tokens, markers);
|
|
190
311
|
const path = typeof env.path === "string" && env.path ? env.path : optPath ?? "";
|
|
191
312
|
let i = 0;
|
|
192
313
|
while (i < tokens.length) {
|
|
193
|
-
const
|
|
194
|
-
if (
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
const newOpenToken = new state.Token("yfm_note_open", "div", 1);
|
|
202
|
-
newOpenToken.attrSet("class", `yfm-note yfm-accent-${type}`);
|
|
203
|
-
newOpenToken.attrSet("note-type", type);
|
|
204
|
-
newOpenToken.map = tokens[i].map;
|
|
205
|
-
const closeTokenMap = tokens[closeTokenIdx].map;
|
|
206
|
-
if (closeTokenMap && newOpenToken.map) {
|
|
207
|
-
newOpenToken.map[1] = closeTokenMap[1];
|
|
208
|
-
}
|
|
209
|
-
const newCloseToken = new state.Token("yfm_note_close", "div", -1);
|
|
210
|
-
newCloseToken.map = tokens[closeTokenIdx].map;
|
|
211
|
-
const titleOpen = new state.Token("yfm_note_title_open", "p", 1);
|
|
212
|
-
titleOpen.attrSet("class", "yfm-note-title");
|
|
213
|
-
const autotitle = notesAutotitle ? getTitle(type, lang) : "";
|
|
214
|
-
const titleContent = match[2] === void 0 ? autotitle : match[2];
|
|
215
|
-
const titleInline = state.md.parseInline(titleContent, state.env)[0];
|
|
216
|
-
titleInline.map = null;
|
|
217
|
-
const titleClose = new state.Token("yfm_note_title_close", "p", -1);
|
|
218
|
-
titleOpen.block = true;
|
|
219
|
-
titleClose.block = true;
|
|
220
|
-
const contentOpen = new state.Token("yfm_note_content_open", "div", 1);
|
|
221
|
-
contentOpen.attrSet("class", "yfm-note-content");
|
|
222
|
-
const contentClose = new state.Token("yfm_note_content_close", "div", -1);
|
|
223
|
-
if (newOpenToken.map) {
|
|
224
|
-
contentOpen.map = [newOpenToken.map[0] + 2, newOpenToken.map[1] - 2];
|
|
225
|
-
}
|
|
226
|
-
const insideTokens = [newOpenToken];
|
|
227
|
-
if (titleInline.content) {
|
|
228
|
-
insideTokens.push(titleOpen, titleInline, titleClose);
|
|
229
|
-
}
|
|
230
|
-
insideTokens.push(
|
|
231
|
-
contentOpen,
|
|
232
|
-
...tokens.slice(i + 3, closeTokenIdx),
|
|
233
|
-
contentClose,
|
|
234
|
-
newCloseToken
|
|
235
|
-
);
|
|
236
|
-
tokens.splice(i, closeTokenIdx - i + 3, ...insideTokens);
|
|
237
|
-
onNote?.(env);
|
|
238
|
-
i++;
|
|
239
|
-
} else if (matchWrongNotes(tokens, i) && tokens[i + 1].content !== "{% endnote %}") {
|
|
314
|
+
const marker = markers.get(tokens[i]);
|
|
315
|
+
if (marker?.kind === "close") {
|
|
316
|
+
throw new Error("Note directive opening marker is missing");
|
|
317
|
+
}
|
|
318
|
+
const match = legacy && matchOpenToken(tokens, i);
|
|
319
|
+
if (marker || match) {
|
|
320
|
+
i = processNote(state, i, marker, match, path);
|
|
321
|
+
} else if (legacy && matchWrongNotes(tokens, i) && tokens[i + 1].content !== "{% endnote %}") {
|
|
240
322
|
log.warn(
|
|
241
323
|
`Incorrect syntax for notes${path ? `, file ${formatPath(path)}` : ""}`
|
|
242
324
|
);
|
|
@@ -252,7 +334,16 @@ function createNotesPlugin(formatPath = (path) => path, onNote) {
|
|
|
252
334
|
md.core.ruler.push("notes", plugin);
|
|
253
335
|
}
|
|
254
336
|
};
|
|
255
|
-
|
|
337
|
+
if (!factory.directiveSyntax || factory.directiveSyntax === "disabled") {
|
|
338
|
+
const legacyPlugin = (md, options) => installCore(md, options, /* @__PURE__ */ new WeakMap(), true, false);
|
|
339
|
+
return legacyPlugin;
|
|
340
|
+
}
|
|
341
|
+
const directivePlugin = (md, options) => {
|
|
342
|
+
const markers = /* @__PURE__ */ new WeakMap();
|
|
343
|
+
installNoteDirective(md, markers, factory.onDiagnostic);
|
|
344
|
+
installCore(md, options, markers, factory.directiveSyntax === "enabled", true);
|
|
345
|
+
};
|
|
346
|
+
return directivePlugin;
|
|
256
347
|
}
|
|
257
348
|
|
|
258
349
|
// src/plugin/resources.ts
|
|
@@ -301,11 +392,18 @@ function transform(options = {}) {
|
|
|
301
392
|
throw new TypeError("Browser notes extension cannot copy runtime files.");
|
|
302
393
|
}
|
|
303
394
|
const runtime = normalizeRuntime(options.runtime);
|
|
395
|
+
const onNote = runtime ? (env) => addResources(env, runtime) : void 0;
|
|
396
|
+
const mode = options.directiveSyntax;
|
|
397
|
+
if (mode === "enabled" || mode === "only") {
|
|
398
|
+
const directive = createNotesPlugin(void 0, onNote, {
|
|
399
|
+
directiveSyntax: mode,
|
|
400
|
+
onDiagnostic: options.onDiagnostic
|
|
401
|
+
});
|
|
402
|
+
const plugin = (md, settings = {}) => directive(md, semanticOptions(options, settings));
|
|
403
|
+
return plugin;
|
|
404
|
+
}
|
|
304
405
|
return function plugin(md, settings = {}) {
|
|
305
|
-
createNotesPlugin(void 0,
|
|
306
|
-
md,
|
|
307
|
-
semanticOptions(options, settings)
|
|
308
|
-
);
|
|
406
|
+
createNotesPlugin(void 0, onNote)(md, semanticOptions(options, settings));
|
|
309
407
|
};
|
|
310
408
|
}
|
|
311
409
|
var browser_default = { transform, TokenType };
|
package/build/cjs/browser.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/browser/index.ts", "../../src/plugin/close.ts", "../../src/plugin/const.ts", "../../src/plugin/plugin.ts", "../../src/plugin/resources.ts"],
|
|
4
|
-
"sourcesContent": ["import type {NoteParser, NoteToken, NotesOptions, NotesPlugin} from '../plugin/types.js';\nimport type {RuntimeOption} from '../plugin/resources.js';\n\nimport {createNotesPlugin} from '../plugin/plugin.js';\nimport {addResources, normalizeRuntime, semanticOptions} from '../plugin/resources.js';\nimport {TokenType} from '../plugin/const.js';\n\nexport type TransformOptions = NotesOptions & {runtime?: RuntimeOption; bundle?: false};\nexport function transform(options: TransformOptions = {}): NotesPlugin {\n if (options.bundle !== undefined && options.bundle !== false) {\n throw new TypeError('Browser notes extension cannot copy runtime files.');\n }\n const runtime = normalizeRuntime(options.runtime);\n return function plugin<Token extends NoteToken>(\n md: NoteParser<Token>,\n settings: NotesOptions = {},\n ): void {\n createNotesPlugin(undefined, runtime ? (env) => addResources(env, runtime) : undefined)(\n md,\n semanticOptions(options, settings),\n );\n };\n}\nexport {TokenType};\nexport type {NotesOptions, NotesLogger} from '../plugin/types.js';\nexport default {transform, TokenType};\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 MatchTokenFunction,\n NoteParser,\n NoteState,\n NoteToken,\n NotesOptions,\n NotesPlugin,\n} from './types.js';\n\nimport {createNestedCloseTokenIdxFactory} from './close.js';\nimport {DEFAULT_LANG, TITLES} from './const.js';\n\nconst quietLogger = {warn: (_message: string) => {}, error: (_message: string) => {}};\n\nconst ALERT_RE = /^{% note (alert|info|tip|warning)\\s*(?:\"(.*?)\")? %}$/;\nconst WRONG_NOTES = /^{% note (.*)%}/;\n\nconst matchCloseToken: MatchTokenFunction = (tokens, i) => {\n return (\n tokens[i].type === 'paragraph_open' &&\n tokens[i + 1].type === 'inline' &&\n tokens[i + 1].content.trim() === '{% endnote %}'\n );\n};\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\nfunction matchOpenToken(tokens: 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\nfunction matchWrongNotes(tokens: 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\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 = (path) => path,\n onNote?: (env: Record<string, unknown>) => void,\n): NotesPlugin {\n const findCloseTokenIdx = createNestedCloseTokenIdxFactory(formatPath)(\n 'Note',\n matchOpenToken,\n matchCloseToken,\n );\n\n const index: NotesPlugin = <Token extends NoteToken>(\n md: NoteParser<Token>,\n {lang = DEFAULT_LANG, notesAutotitle, path: optPath, log = quietLogger}: NotesOptions = {},\n ) => {\n notesAutotitle = typeof notesAutotitle === 'boolean' ? notesAutotitle : true;\n\n const plugin = (state: NoteState<Token>) => {\n const {tokens, env} = state;\n const path = typeof env.path === 'string' && env.path ? env.path : (optPath ?? '');\n let i = 0;\n\n while (i < tokens.length) {\n const match = matchOpenToken(tokens, i);\n\n if (match) {\n // Skip paragraph_close for open token (+1) and paragraph_open for close token (+1)\n // This is minimal useless content length\n const closeTokenIdx = findCloseTokenIdx(tokens, i + 2, path, log);\n\n if (!closeTokenIdx) {\n i += 3;\n continue;\n }\n\n const type = match[1].toLowerCase();\n const newOpenToken = new state.Token('yfm_note_open', 'div', 1);\n newOpenToken.attrSet('class', `yfm-note yfm-accent-${type}`);\n newOpenToken.attrSet('note-type', type);\n newOpenToken.map = tokens[i].map;\n const closeTokenMap = tokens[closeTokenIdx].map;\n\n if (closeTokenMap && newOpenToken.map) {\n newOpenToken.map[1] = closeTokenMap[1];\n }\n\n const newCloseToken = new state.Token('yfm_note_close', 'div', -1);\n newCloseToken.map = tokens[closeTokenIdx].map;\n\n // Add extra paragraph\n const titleOpen = new state.Token('yfm_note_title_open', 'p', 1);\n titleOpen.attrSet('class', 'yfm-note-title');\n const autotitle = notesAutotitle ? getTitle(type, lang) : '';\n const titleContent = match[2] === undefined ? autotitle : match[2];\n const titleInline = state.md.parseInline(titleContent, state.env)[0];\n titleInline.map = null;\n const titleClose = new state.Token('yfm_note_title_close', 'p', -1);\n\n titleOpen.block = true;\n titleClose.block = true;\n\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\n if (newOpenToken.map) {\n contentOpen.map = [newOpenToken.map[0] + 2, newOpenToken.map[1] - 2];\n }\n\n const insideTokens = [newOpenToken];\n if (titleInline.content) {\n insideTokens.push(titleOpen, titleInline, titleClose);\n }\n\n insideTokens.push(\n contentOpen,\n ...tokens.slice(i + 3, closeTokenIdx),\n contentClose,\n newCloseToken,\n );\n\n tokens.splice(i, closeTokenIdx - i + 3, ...insideTokens);\n\n onNote?.(env);\n i++;\n } else if (\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\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 return index;\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;;;ACOO,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;A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AM,YAAY;AAAA,EACrB,MAAM;AAAA,EACN,UAAU;AAAA,EACV,WAAW;AAAA,EACX,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,EACjB,kBAAkB;AACtB;;;
|
|
3
|
+
"sources": ["../../src/browser/index.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 type {\n NoteParser,\n NoteToken,\n NotesDirectivePlugin,\n NotesFactoryOptions,\n NotesOptions,\n NotesPlugin,\n} from '../plugin/types.js';\nimport type {RuntimeOption} from '../plugin/resources.js';\n\nimport {createNotesPlugin} from '../plugin/plugin.js';\nimport {addResources, normalizeRuntime, semanticOptions} from '../plugin/resources.js';\nimport {TokenType} from '../plugin/const.js';\n\nexport type TransformOptions = NotesOptions &\n NotesFactoryOptions & {runtime?: RuntimeOption; bundle?: false};\nexport function transform(options?: TransformOptions & {directiveSyntax?: 'disabled'}): NotesPlugin;\nexport function transform(\n options: TransformOptions & {directiveSyntax: 'enabled' | 'only'},\n): NotesDirectivePlugin;\nexport function transform(options: TransformOptions): NotesPlugin | NotesDirectivePlugin;\nexport function transform(options: TransformOptions = {}): NotesPlugin | NotesDirectivePlugin {\n if (options.bundle !== undefined && options.bundle !== false) {\n throw new TypeError('Browser notes extension cannot copy runtime files.');\n }\n const runtime = normalizeRuntime(options.runtime);\n const onNote = runtime\n ? (env: Record<string, unknown>) => addResources(env, runtime)\n : undefined;\n const mode = options.directiveSyntax;\n if (mode === 'enabled' || mode === 'only') {\n const directive = createNotesPlugin(undefined, onNote, {\n directiveSyntax: mode,\n onDiagnostic: options.onDiagnostic,\n });\n const plugin: NotesDirectivePlugin = (md, settings = {}) =>\n directive(md, semanticOptions(options, settings));\n return plugin;\n }\n return function plugin<Token extends NoteToken>(\n md: NoteParser<Token>,\n settings: NotesOptions = {},\n ): void {\n createNotesPlugin(undefined, onNote)(md, semanticOptions(options, settings));\n };\n}\nexport {TokenType};\nexport type {\n NotesOptions,\n NotesLogger,\n NotesDirectiveDiagnostic,\n NotesFactoryOptions,\n NotesDirectivePlugin,\n} from '../plugin/types.js';\nexport default {transform, TokenType};\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;;;ACOO,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,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