@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,28 @@
1
+ import type { BlockContentState, DirectiveBlockState, DirectiveInlineState, DirectiveParserHost } from '@diplodoc/directive';
2
+ import type { NoteParser, NoteToken, NotesFactoryOptions, NotesOptions } from './types.js';
3
+ import type { RuntimeOption } from './resources.js';
4
+ export type TransformOptions = NotesOptions & NotesFactoryOptions & {
5
+ runtime?: RuntimeOption;
6
+ bundle?: boolean;
7
+ };
8
+ export type PluginOptions = NotesOptions & {
9
+ output?: string;
10
+ };
11
+ export type CollectOptions = NotesOptions & {
12
+ destRoot?: string;
13
+ };
14
+ export interface NotesTransformPlugin {
15
+ <Token extends NoteToken>(md: NoteParser<Token>, settings?: PluginOptions): void;
16
+ collect(input: string, options?: CollectOptions): void;
17
+ }
18
+ export interface NotesDirectiveTransformPlugin {
19
+ <Token extends NoteToken, Block extends DirectiveBlockState & BlockContentState<Block>, Inline extends DirectiveInlineState>(md: NoteParser<Token> & DirectiveParserHost<Block, Inline>, settings?: PluginOptions): void;
20
+ collect(input: string, options?: CollectOptions): void;
21
+ }
22
+ export declare function transform(options?: TransformOptions & {
23
+ directiveSyntax?: 'disabled';
24
+ }): NotesTransformPlugin;
25
+ export declare function transform(options: TransformOptions & {
26
+ directiveSyntax: 'enabled' | 'only';
27
+ }): NotesDirectiveTransformPlugin;
28
+ export declare function transform(options: TransformOptions): NotesTransformPlugin | NotesDirectiveTransformPlugin;
@@ -0,0 +1,45 @@
1
+ import type { BlockContentState, DirectiveBlockState, DirectiveInlineState, DirectiveParserHost } from '@diplodoc/directive';
2
+ export interface NoteToken {
3
+ type: string;
4
+ content: string;
5
+ map: [number, number] | null;
6
+ block: boolean;
7
+ attrSet(name: string, value: string): void;
8
+ }
9
+ export interface NoteState<Token extends NoteToken> {
10
+ tokens: Token[];
11
+ env: Record<string, unknown>;
12
+ Token: new (type: string, tag: string, nesting: -1 | 0 | 1) => Token;
13
+ md: {
14
+ parseInline(source: string, env: Record<string, unknown>): Token[];
15
+ };
16
+ }
17
+ export interface NoteParser<Token extends NoteToken> {
18
+ core: {
19
+ ruler: {
20
+ before(beforeName: string, name: string, rule: (state: NoteState<Token>) => void): void;
21
+ push(name: string, rule: (state: NoteState<Token>) => void): void;
22
+ };
23
+ };
24
+ }
25
+ export type NotesOptions = {
26
+ lang?: string;
27
+ notesAutotitle?: boolean;
28
+ path?: string;
29
+ log?: NotesLogger;
30
+ };
31
+ export interface NotesLogger {
32
+ warn(message: string): void;
33
+ error(message: string): void;
34
+ }
35
+ export type NotesPlugin = <Token extends NoteToken>(md: NoteParser<Token>, options?: NotesOptions) => void;
36
+ export type NotesDirectivePlugin = <Token extends NoteToken, Block extends DirectiveBlockState & BlockContentState<Block>, Inline extends DirectiveInlineState>(md: NoteParser<Token> & DirectiveParserHost<Block, Inline>, options?: NotesOptions) => void;
37
+ export type NotesDirectiveDiagnostic = {
38
+ line: number;
39
+ reason: string;
40
+ };
41
+ export type NotesFactoryOptions = {
42
+ directiveSyntax?: 'disabled' | 'enabled' | 'only';
43
+ onDiagnostic?: (diagnostic: NotesDirectiveDiagnostic) => void;
44
+ };
45
+ export type MatchTokenFunction = (tokens: NoteToken[], index: number) => boolean | RegExpMatchArray | null;
@@ -0,0 +1,353 @@
1
+ // src/plugin/close.ts
2
+ function createNestedCloseTokenIdxFactory(formatPath) {
3
+ const nestedCloseTokenIdxFactory = (tokenName, matchOpenToken2, matchCloseToken2) => (tokens, idx, path, log) => {
4
+ let level = 0;
5
+ let i = idx;
6
+ while (i < tokens.length) {
7
+ if (matchOpenToken2(tokens, i)) {
8
+ level++;
9
+ } else if (matchCloseToken2(tokens, i)) {
10
+ if (level === 0) {
11
+ return i;
12
+ }
13
+ level--;
14
+ }
15
+ i++;
16
+ }
17
+ log.error(`${tokenName} must be closed${path ? ` in ${formatPath(path)}` : ""}`);
18
+ return null;
19
+ };
20
+ return nestedCloseTokenIdxFactory;
21
+ }
22
+
23
+ // src/plugin/const.ts
24
+ var DEFAULT_LANG = "ru";
25
+ var TITLES = {
26
+ ru: {
27
+ info: "\u041F\u0440\u0438\u043C\u0435\u0447\u0430\u043D\u0438\u0435",
28
+ tip: "\u0421\u043E\u0432\u0435\u0442",
29
+ alert: "\u0412\u043D\u0438\u043C\u0430\u043D\u0438\u0435",
30
+ warning: "\u0412\u0430\u0436\u043D\u043E"
31
+ },
32
+ en: {
33
+ info: "Note",
34
+ tip: "Tip",
35
+ alert: "Alert",
36
+ warning: "Warning"
37
+ },
38
+ ar: {
39
+ info: "\u0645\u0644\u0627\u062D\u0638\u0629",
40
+ tip: "\u0646\u0635\u064A\u062D\u0629",
41
+ alert: "\u0627\u0646\u062A\u0628\u0627\u0647",
42
+ warning: "\u0647\u0627\u0645"
43
+ },
44
+ cs: {
45
+ info: "Pozn\xE1mka",
46
+ tip: "Tip",
47
+ alert: "Upozorn\u011Bn\xED",
48
+ warning: "Varov\xE1n\xED"
49
+ },
50
+ fr: {
51
+ info: "Remarque",
52
+ tip: "Astuce",
53
+ alert: "Alerte",
54
+ warning: "Avertissement"
55
+ },
56
+ es: {
57
+ info: "Nota",
58
+ tip: "Consejo",
59
+ alert: "Alerta",
60
+ warning: "Aviso"
61
+ },
62
+ he: {
63
+ info: "\u05DE\u05D9\u05D3\u05E2",
64
+ tip: "\u05D8\u05D9\u05E4",
65
+ alert: "\u05D4\u05EA\u05E8\u05D0\u05D4",
66
+ warning: "\u05D0\u05D6\u05D4\u05E8\u05D4"
67
+ },
68
+ bg: {
69
+ info: "\u0417\u0430\u0431\u0435\u043B\u0435\u0436\u043A\u0430",
70
+ tip: "\u0421\u044A\u0432\u0435\u0442",
71
+ alert: "\u0412\u043D\u0438\u043C\u0430\u043D\u0438\u0435",
72
+ warning: "\u0412\u0430\u0436\u043D\u043E"
73
+ },
74
+ et: {
75
+ info: "M\xE4rkus",
76
+ tip: "N\xF5uanne",
77
+ alert: "T\xE4helepanu",
78
+ warning: "T\xE4htis"
79
+ },
80
+ el: {
81
+ info: "\u03A3\u03B7\u03BC\u03B5\u03AF\u03C9\u03C3\u03B7",
82
+ tip: "\u03A3\u03C5\u03BC\u03B2\u03BF\u03C5\u03BB\u03AE",
83
+ alert: "\u03A0\u03C1\u03BF\u03C3\u03BF\u03C7\u03AE",
84
+ warning: "\u03A3\u03B7\u03BC\u03B1\u03BD\u03C4\u03B9\u03BA\u03CC"
85
+ },
86
+ pt: {
87
+ info: "Observa\xE7\xE3o",
88
+ tip: "Sugest\xE3o",
89
+ alert: "Aten\xE7\xE3o",
90
+ warning: "Importante"
91
+ },
92
+ zh: {
93
+ info: "\u5907\u6CE8",
94
+ tip: "\u63D0\u793A",
95
+ alert: "\u6CE8\u610F",
96
+ warning: "\u91CD\u8981"
97
+ },
98
+ "zh-tw": {
99
+ info: "\u5099\u6CE8",
100
+ tip: "\u63D0\u793A",
101
+ alert: "\u6CE8\u610F",
102
+ warning: "\u91CD\u8981"
103
+ },
104
+ kk: {
105
+ info: "\u0415\u0441\u043A\u0435\u0440\u0442\u0443",
106
+ tip: "\u041A\u0435\u04A3\u0435\u0441",
107
+ alert: "\u041D\u0430\u0437\u0430\u0440 \u0430\u0443\u0434\u0430\u0440\u044B\u04A3\u044B\u0437",
108
+ warning: "\u041C\u0430\u04A3\u044B\u0437\u0434\u044B"
109
+ },
110
+ tr: {
111
+ info: "Not",
112
+ tip: "\xD6neri",
113
+ alert: "Dikkat",
114
+ warning: "\xD6nemli"
115
+ },
116
+ uz: {
117
+ info: "Sharh",
118
+ tip: "Maslahat",
119
+ alert: "Diqqat",
120
+ warning: "Bu muhim"
121
+ }
122
+ };
123
+ var TokenType = {
124
+ Note: "yfm-note",
125
+ NoteOpen: "yfm_note_open",
126
+ NoteClose: "yfm_note_close",
127
+ NoteTitleOpen: "yfm_note_title_open",
128
+ NoteTitleClose: "yfm_note_title_close",
129
+ NoteContentOpen: "yfm_note_content_open",
130
+ NoteContentClose: "yfm_note_content_close"
131
+ };
132
+
133
+ // src/plugin/directive.ts
134
+ import {
135
+ directiveParser,
136
+ registerContainerDirective,
137
+ tokenizeBlockContent
138
+ } from "@diplodoc/directive";
139
+ function invalidReason(params, state) {
140
+ if (params.dests) {
141
+ const suffix = params.inlineContent ? state.src.slice(params.inlineContent.endPos + 1, state.eMarks[params.startLine]).trimStart() : "";
142
+ if (!params.inlineContent || suffix.startsWith("(") || suffix.startsWith("[")) {
143
+ return "Destinations are not supported for note directives";
144
+ }
145
+ }
146
+ if (params.contentTitle) return "Invalid note directive parameters";
147
+ const attrs = params.attrs ?? {};
148
+ for (const name of Object.keys(attrs)) {
149
+ if (name !== "type") return `Unknown note attribute: ${name}`;
150
+ }
151
+ if (Array.isArray(attrs.type)) return "Repeated note attribute: type";
152
+ if (!attrs.type || !["info", "tip", "warning", "alert"].includes(attrs.type)) {
153
+ return "Note type must be info, tip, warning or alert";
154
+ }
155
+ return void 0;
156
+ }
157
+ function installNoteDirective(md, markers, onDiagnostic) {
158
+ directiveParser()(md);
159
+ registerContainerDirective(
160
+ md,
161
+ "note",
162
+ (state, params) => {
163
+ const reason = invalidReason(params, state);
164
+ if (reason) {
165
+ onDiagnostic?.({ line: params.startLine + 1, reason });
166
+ return false;
167
+ }
168
+ const type = params.attrs?.type;
169
+ if (typeof type !== "string") throw new Error("Invalid validated note type");
170
+ const open = state.push("yfm_note_directive_open", "", 0);
171
+ open.map = [params.startLine, params.endLine];
172
+ tokenizeBlockContent(state, params.content, "note-directive");
173
+ const close = state.push("yfm_note_directive_close", "", 0);
174
+ close.map = [params.endLine - 1, params.endLine];
175
+ markers.set(open, {
176
+ kind: "open",
177
+ end: close,
178
+ type,
179
+ title: params.inlineContent?.raw,
180
+ contentMap: [params.content.startLine, params.content.endLine]
181
+ });
182
+ markers.set(close, { kind: "close" });
183
+ return true;
184
+ },
185
+ { onConflict: "error" }
186
+ );
187
+ }
188
+
189
+ // src/plugin/recognize.ts
190
+ var ALERT_RE = /^{% note (alert|info|tip|warning)\s*(?:"(.*?)")? %}$/;
191
+ var WRONG_NOTES = /^{% note (.*)%}/;
192
+ function matchCloseToken(tokens, i) {
193
+ return tokens[i].type === "paragraph_open" && tokens[i + 1].type === "inline" && tokens[i + 1].content.trim() === "{% endnote %}";
194
+ }
195
+ function matchOpenToken(tokens, i) {
196
+ return tokens[i].type === "paragraph_open" && tokens[i + 1].type === "inline" && tokens[i + 1].content.match(ALERT_RE);
197
+ }
198
+ function matchWrongNotes(tokens, i) {
199
+ return tokens[i].type === "paragraph_open" && tokens[i + 1].type === "inline" && tokens[i + 1].content.match(WRONG_NOTES);
200
+ }
201
+ function recognizeNoteBoundary(tokens, i) {
202
+ if (!tokens[i] || !tokens[i + 1]) return void 0;
203
+ const match = matchOpenToken(tokens, i);
204
+ const close = !match && matchCloseToken(tokens, i);
205
+ const wrong = !match && !close && matchWrongNotes(tokens, i);
206
+ if (!match && !close && !wrong) return void 0;
207
+ const map = tokens[i].map;
208
+ const common = { map: map ? [map[0], map[1]] : null, raw: tokens[i + 1].content };
209
+ if (match) {
210
+ const type = ["info", "tip", "warning", "alert"].find(
211
+ (item) => item === match[1].toLowerCase()
212
+ );
213
+ if (!type) throw new Error("Invalid recognized note type");
214
+ return {
215
+ kind: "open",
216
+ ...common,
217
+ type,
218
+ title: match[2] === void 0 ? { present: false } : { present: true, raw: match[2] }
219
+ };
220
+ }
221
+ return { kind: close ? "close" : "unsupported", ...common };
222
+ }
223
+
224
+ // src/plugin/plugin.ts
225
+ var quietLogger = { warn: (_message) => {
226
+ }, error: (_message) => {
227
+ } };
228
+ var titleDictionaries = new Map(Object.entries(TITLES));
229
+ function getTitle(type, lang) {
230
+ return (titleDictionaries.get(lang) ?? TITLES.ru)[type];
231
+ }
232
+ function emitNote(state, note) {
233
+ const { tokens, env } = state;
234
+ const open = new state.Token("yfm_note_open", "div", 1);
235
+ open.attrSet("class", `yfm-note yfm-accent-${note.type}`);
236
+ open.attrSet("note-type", note.type);
237
+ open.map = tokens[note.start].map;
238
+ const closeMap = tokens[note.close].map;
239
+ if (closeMap && open.map) open.map[1] = closeMap[1];
240
+ const close = new state.Token("yfm_note_close", "div", -1);
241
+ close.map = closeMap;
242
+ const titleOpen = new state.Token("yfm_note_title_open", "p", 1);
243
+ titleOpen.attrSet("class", "yfm-note-title");
244
+ const titleInline = state.md.parseInline(note.title, env)[0];
245
+ titleInline.map = null;
246
+ const titleClose = new state.Token("yfm_note_title_close", "p", -1);
247
+ titleOpen.block = true;
248
+ titleClose.block = true;
249
+ const contentOpen = new state.Token("yfm_note_content_open", "div", 1);
250
+ contentOpen.attrSet("class", "yfm-note-content");
251
+ const contentClose = new state.Token("yfm_note_content_close", "div", -1);
252
+ if (open.map) contentOpen.map = note.contentMap ?? [open.map[0] + 2, open.map[1] - 2];
253
+ const inside = [open];
254
+ if (titleInline.content) inside.push(titleOpen, titleInline, titleClose);
255
+ inside.push(contentOpen, ...tokens.slice(note.bodyStart, note.close), contentClose, close);
256
+ tokens.splice(note.start, note.removeCount, ...inside);
257
+ }
258
+ function validateMarkers(tokens, markers) {
259
+ const expected = [];
260
+ for (const token of tokens) {
261
+ const marker = markers.get(token);
262
+ if (!marker && (token.type === "yfm_note_directive_open" || token.type === "yfm_note_directive_close")) {
263
+ throw new Error("Unowned note directive marker");
264
+ }
265
+ if (marker?.kind === "open") expected.push(marker.end);
266
+ else if (marker?.kind === "close" && expected.pop() !== token) {
267
+ throw new Error("Note directive opening marker is missing or crossed");
268
+ }
269
+ }
270
+ if (expected.length) throw new Error("Note directive closing marker is missing");
271
+ }
272
+ function createNotesPlugin(formatPath = (path) => path, onNote, factory = {}) {
273
+ const findCloseTokenIdx = createNestedCloseTokenIdxFactory(formatPath)(
274
+ "Note",
275
+ matchOpenToken,
276
+ matchCloseToken
277
+ );
278
+ const installCore = (md, { lang = DEFAULT_LANG, notesAutotitle, path: optPath, log = quietLogger } = {}, markers, legacy, directiveEnabled) => {
279
+ notesAutotitle = typeof notesAutotitle === "boolean" ? notesAutotitle : true;
280
+ const processNote = (state, start, marker, match, path) => {
281
+ const { tokens, env } = state;
282
+ const closeTokenIdx = marker ? tokens.findIndex((token, index) => index > start && token === marker.end) : findCloseTokenIdx(tokens, start + 2, path, log);
283
+ if (marker && (closeTokenIdx === null || closeTokenIdx < 0)) {
284
+ throw new Error("Note directive closing marker is missing");
285
+ }
286
+ if (!closeTokenIdx) return start + 3;
287
+ const type = marker ? marker.type : match && match[1].toLowerCase();
288
+ if (!type) throw new Error("Note type is missing");
289
+ let authoredTitle;
290
+ if (marker) authoredTitle = marker.title;
291
+ else if (match) authoredTitle = match[2];
292
+ let title = authoredTitle;
293
+ if (title === void 0) title = notesAutotitle ? getTitle(type, lang) : "";
294
+ emitNote(state, {
295
+ start,
296
+ close: closeTokenIdx,
297
+ bodyStart: start + (marker ? 1 : 3),
298
+ removeCount: closeTokenIdx - start + (marker ? 1 : 3),
299
+ type,
300
+ title,
301
+ contentMap: marker?.contentMap
302
+ });
303
+ onNote?.(env);
304
+ return start + 1;
305
+ };
306
+ const plugin = (state) => {
307
+ const { tokens, env } = state;
308
+ if (directiveEnabled) validateMarkers(tokens, markers);
309
+ const path = typeof env.path === "string" && env.path ? env.path : optPath ?? "";
310
+ let i = 0;
311
+ while (i < tokens.length) {
312
+ const marker = markers.get(tokens[i]);
313
+ if (marker?.kind === "close") {
314
+ throw new Error("Note directive opening marker is missing");
315
+ }
316
+ const match = legacy && matchOpenToken(tokens, i);
317
+ if (marker || match) {
318
+ i = processNote(state, i, marker, match, path);
319
+ } else if (legacy && matchWrongNotes(tokens, i) && tokens[i + 1].content !== "{% endnote %}") {
320
+ log.warn(
321
+ `Incorrect syntax for notes${path ? `, file ${formatPath(path)}` : ""}`
322
+ );
323
+ i += 3;
324
+ } else {
325
+ i++;
326
+ }
327
+ }
328
+ };
329
+ try {
330
+ md.core.ruler.before("curly_attributes", "notes", plugin);
331
+ } catch {
332
+ md.core.ruler.push("notes", plugin);
333
+ }
334
+ };
335
+ if (!factory.directiveSyntax || factory.directiveSyntax === "disabled") {
336
+ const legacyPlugin = (md, options) => installCore(md, options, /* @__PURE__ */ new WeakMap(), true, false);
337
+ return legacyPlugin;
338
+ }
339
+ const directivePlugin = (md, options) => {
340
+ const markers = /* @__PURE__ */ new WeakMap();
341
+ installNoteDirective(md, markers, factory.onDiagnostic);
342
+ installCore(md, options, markers, factory.directiveSyntax === "enabled", true);
343
+ };
344
+ return directivePlugin;
345
+ }
346
+ export {
347
+ DEFAULT_LANG,
348
+ TITLES,
349
+ TokenType,
350
+ createNotesPlugin,
351
+ recognizeNoteBoundary
352
+ };
353
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/plugin/close.ts", "../../src/plugin/const.ts", "../../src/plugin/directive.ts", "../../src/plugin/recognize.ts", "../../src/plugin/plugin.ts"],
4
+ "sourcesContent": ["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"],
5
+ "mappings": ";AAOO,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,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AAO;AACH;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ;AAEA,QAAI;AACA,SAAG,KAAK,MAAM,OAAO,oBAAoB,SAAS,MAAM;AAAA,IAC5D,QAAQ;AACJ,SAAG,KAAK,MAAM,KAAK,SAAS,MAAM;AAAA,IACtC;AAAA,EACJ;AAEA,MAAI,CAAC,QAAQ,mBAAmB,QAAQ,oBAAoB,YAAY;AACpE,UAAM,eAA4B,CAAC,IAAI,YACnC,YAAY,IAAI,SAAS,oBAAI,QAAQ,GAAG,MAAM,KAAK;AACvD,WAAO;AAAA,EACX;AACA,QAAM,kBAAwC,CAAC,IAAI,YAAY;AAC3D,UAAM,UAAU,oBAAI,QAA4B;AAChD,yBAAqB,IAAI,SAAS,QAAQ,YAAY;AACtD,gBAAY,IAAI,SAAS,SAAS,QAAQ,oBAAoB,WAAW,IAAI;AAAA,EACjF;AACA,SAAO;AACX;",
6
+ "names": ["matchOpenToken", "matchCloseToken"]
7
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,55 @@
1
+ .yfm .yfm-note {
2
+ max-width: 1296px;
3
+ margin: 20px 0;
4
+ padding: 20px 20px 20px 64px;
5
+ border-radius: 10px;
6
+ }
7
+ .yfm .yfm-note .yfm-note-title {
8
+ font-weight: 700;
9
+ }
10
+ .yfm .yfm-note > * {
11
+ margin: 0 0 10px;
12
+ }
13
+ .yfm .yfm-note > *:first-child::before {
14
+ box-sizing: content-box;
15
+ display: block;
16
+ width: 24px;
17
+ height: 24px;
18
+ margin-top: -2px;
19
+ margin-left: -44px;
20
+ padding-right: 20px;
21
+ float: left;
22
+ }
23
+ .yfm .yfm-note > *:last-child {
24
+ margin-bottom: 0;
25
+ }
26
+ .yfm .yfm-note.yfm-accent-info > :first-child::before {
27
+ content: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 16 16"%3E%3Ccircle cx="8" cy="8" r="8" fill="rgb(2,123,243)"/%3E%3Crect width="1" height="5" x="7.5" y="6.5" stroke="%23fff" rx=".5"/%3E%3Ccircle cx="8" cy="4" r="1" fill="%23fff"/%3E%3C/svg%3E');
28
+ }
29
+ .yfm .yfm-note.yfm-accent-tip > :first-child::before {
30
+ content: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 16 16"%3E%3Ccircle cx="8" cy="8" r="8" fill="rgb(86,189,103)"/%3E%3Crect width="1" height="5" x="7.5" y="6.5" stroke="%23fff" rx=".5"/%3E%3Ccircle cx="8" cy="4" r="1" fill="%23fff"/%3E%3C/svg%3E');
31
+ }
32
+ .yfm .yfm-note.yfm-accent-warning > :first-child::before {
33
+ content: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 16 16"%3E%3Ccircle cx="8" cy="8" r="8" fill="rgb(241,149,24)"/%3E%3Crect width="1" height="5" x="7.5" y="6.5" stroke="%23fff" rx=".5"/%3E%3Ccircle cx="8" cy="4" r="1" fill="%23fff"/%3E%3C/svg%3E');
34
+ }
35
+ .yfm .yfm-note.yfm-accent-alert > :first-child::before {
36
+ content: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 16 16"%3E%3Ccircle cx="8" cy="8" r="8" fill="rgb(255,70,69)"/%3E%3Crect width="1" height="5" x="7.5" y="6.5" stroke="%23fff" rx=".5"/%3E%3Ccircle cx="8" cy="4" r="1" fill="%23fff"/%3E%3C/svg%3E');
37
+ }
38
+ .yfm .yfm-note.yfm-accent-info {
39
+ background: var(--yfm-color-note-info-background, var(--yfm-color-note-info-background-private));
40
+ }
41
+ .yfm .yfm-note.yfm-accent-tip {
42
+ background: var(--yfm-color-note-tip-background, var(--yfm-color-note-tip-background-private));
43
+ }
44
+ .yfm .yfm-note.yfm-accent-alert {
45
+ background: var(--yfm-color-note-important-background, var(--yfm-color-note-important-background-private));
46
+ }
47
+ .yfm .yfm-note.yfm-accent-warning {
48
+ background: var(--yfm-color-note-warning-background, var(--yfm-color-note-warning-background-private));
49
+ }
50
+
51
+ @media print {
52
+ .yfm .yfm-note {
53
+ page-break-inside: avoid;
54
+ }
55
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,87 @@
1
+ @use 'sass:color';
2
+
3
+ @mixin notes-body {
4
+ max-width: 1296px;
5
+ margin: 20px 0;
6
+ padding: 20px 20px 20px 64px;
7
+ border-radius: 10px;
8
+
9
+ .yfm-note-title {
10
+ font-weight: 700;
11
+ }
12
+
13
+ & > * {
14
+ margin: 0 0 10px;
15
+
16
+ &:first-child {
17
+ &::before {
18
+ box-sizing: content-box;
19
+ display: block;
20
+ width: 24px;
21
+ height: 24px;
22
+ margin-top: -2px;
23
+ margin-left: -44px;
24
+ padding-right: 20px;
25
+ float: left;
26
+ }
27
+ }
28
+
29
+ &:last-child {
30
+ margin-bottom: 0;
31
+ }
32
+ }
33
+
34
+ // @todo replace with variables
35
+
36
+ $colors: (
37
+ yfm-accent-info: #027bf3,
38
+ yfm-accent-tip: #56bd67,
39
+ yfm-accent-warning: #f19518,
40
+ yfm-accent-alert: #ff4645,
41
+ );
42
+
43
+ @each $type, $color in $colors {
44
+ &.#{$type} > :first-child::before {
45
+ $r: color.channel($color, 'red', $space: rgb);
46
+ $g: color.channel($color, 'green', $space: rgb);
47
+ $b: color.channel($color, 'blue', $space: rgb);
48
+ $rgbColor: 'rgb(' + $r + ',' + $g + ',' + $b + ')';
49
+ content: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 16 16"%3E%3Ccircle cx="8" cy="8" r="8" fill="' + $rgbColor + '"/%3E%3Crect width="1" height="5" x="7.5" y="6.5" stroke="%23fff" rx=".5"/%3E%3Ccircle cx="8" cy="4" r="1" fill="%23fff"/%3E%3C/svg%3E');
50
+ }
51
+ }
52
+
53
+ $backgroundColors: (
54
+ yfm-accent-info: var(
55
+ --yfm-color-note-info-background,
56
+ var(--yfm-color-note-info-background-private)
57
+ ),
58
+ yfm-accent-tip: var(
59
+ --yfm-color-note-tip-background,
60
+ var(--yfm-color-note-tip-background-private)
61
+ ),
62
+ yfm-accent-alert: var(
63
+ --yfm-color-note-important-background,
64
+ var(--yfm-color-note-important-background-private)
65
+ ),
66
+ yfm-accent-warning: var(
67
+ --yfm-color-note-warning-background,
68
+ var(--yfm-color-note-warning-background-private)
69
+ ),
70
+ );
71
+
72
+ @each $type, $color in $backgroundColors {
73
+ &.#{$type} {
74
+ background: $color;
75
+ }
76
+ }
77
+ }
78
+
79
+ @mixin notes-print {
80
+ @media print {
81
+ .yfm {
82
+ .yfm-note {
83
+ page-break-inside: avoid;
84
+ }
85
+ }
86
+ }
87
+ }