@diplodoc/notes-extension 0.0.0-stage → 0.1.0-transform5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +89 -2
  3. package/build/cjs/browser/index.d.ts +23 -0
  4. package/build/cjs/browser.js +317 -0
  5. package/build/cjs/browser.js.map +7 -0
  6. package/build/cjs/index.js +356 -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/index.d.ts +18 -0
  12. package/build/cjs/plugin/plugin.d.ts +8 -0
  13. package/build/cjs/plugin/pure.d.ts +4 -0
  14. package/build/cjs/plugin/resources.d.ts +9 -0
  15. package/build/cjs/plugin/transform.d.ts +17 -0
  16. package/build/cjs/plugin/types.d.ts +35 -0
  17. package/build/cjs/plugin.js +265 -0
  18. package/build/cjs/plugin.js.map +7 -0
  19. package/build/cjs/runtime/index.d.ts +1 -0
  20. package/build/esm/browser/index.d.ts +23 -0
  21. package/build/esm/browser.js +289 -0
  22. package/build/esm/browser.js.map +7 -0
  23. package/build/esm/index.js +328 -0
  24. package/build/esm/index.js.map +7 -0
  25. package/build/esm/package.json +1 -0
  26. package/build/esm/plugin/close.d.ts +7 -0
  27. package/build/esm/plugin/const.d.ts +19 -0
  28. package/build/esm/plugin/index.d.ts +18 -0
  29. package/build/esm/plugin/plugin.d.ts +8 -0
  30. package/build/esm/plugin/pure.d.ts +4 -0
  31. package/build/esm/plugin/resources.d.ts +9 -0
  32. package/build/esm/plugin/transform.d.ts +17 -0
  33. package/build/esm/plugin/types.d.ts +35 -0
  34. package/build/esm/plugin.js +235 -0
  35. package/build/esm/plugin.js.map +7 -0
  36. package/build/esm/runtime/index.d.ts +1 -0
  37. package/build/runtime/index.cjs +1 -0
  38. package/build/runtime/index.css +55 -0
  39. package/build/runtime/index.d.ts +1 -0
  40. package/build/runtime/index.mjs +1 -0
  41. package/build/scss/_notes.scss +87 -0
  42. package/build/types/browser/index.d.ts +23 -0
  43. package/build/types/plugin/close.d.ts +7 -0
  44. package/build/types/plugin/const.d.ts +19 -0
  45. package/build/types/plugin/index.d.ts +18 -0
  46. package/build/types/plugin/plugin.d.ts +8 -0
  47. package/build/types/plugin/pure.d.ts +4 -0
  48. package/build/types/plugin/resources.d.ts +9 -0
  49. package/build/types/plugin/transform.d.ts +17 -0
  50. package/build/types/plugin/types.d.ts +35 -0
  51. package/build/types/runtime/index.d.ts +1 -0
  52. package/package.json +88 -4
@@ -0,0 +1,235 @@
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/plugin.ts
134
+ var quietLogger = { warn: (_message) => {
135
+ }, error: (_message) => {
136
+ } };
137
+ var ALERT_RE = /^{% note (alert|info|tip|warning)\s*(?:"(.*?)")? %}$/;
138
+ var WRONG_NOTES = /^{% note (.*)%}/;
139
+ var matchCloseToken = (tokens, i) => {
140
+ return tokens[i].type === "paragraph_open" && tokens[i + 1].type === "inline" && tokens[i + 1].content.trim() === "{% endnote %}";
141
+ };
142
+ var titleDictionaries = new Map(Object.entries(TITLES));
143
+ function getTitle(type, lang) {
144
+ return (titleDictionaries.get(lang) ?? TITLES.ru)[type];
145
+ }
146
+ function matchOpenToken(tokens, i) {
147
+ return tokens[i].type === "paragraph_open" && tokens[i + 1].type === "inline" && tokens[i + 1].content.match(ALERT_RE);
148
+ }
149
+ function matchWrongNotes(tokens, i) {
150
+ return tokens[i].type === "paragraph_open" && tokens[i + 1].type === "inline" && tokens[i + 1].content.match(WRONG_NOTES);
151
+ }
152
+ function createNotesPlugin(formatPath = (path) => path, onNote) {
153
+ const findCloseTokenIdx = createNestedCloseTokenIdxFactory(formatPath)(
154
+ "Note",
155
+ matchOpenToken,
156
+ matchCloseToken
157
+ );
158
+ const index = (md, { lang = DEFAULT_LANG, notesAutotitle, path: optPath, log = quietLogger } = {}) => {
159
+ notesAutotitle = typeof notesAutotitle === "boolean" ? notesAutotitle : true;
160
+ const plugin = (state) => {
161
+ const { tokens, env } = state;
162
+ const path = typeof env.path === "string" && env.path ? env.path : optPath ?? "";
163
+ let i = 0;
164
+ while (i < tokens.length) {
165
+ const match = matchOpenToken(tokens, i);
166
+ if (match) {
167
+ const closeTokenIdx = findCloseTokenIdx(tokens, i + 2, path, log);
168
+ if (!closeTokenIdx) {
169
+ i += 3;
170
+ continue;
171
+ }
172
+ const type = match[1].toLowerCase();
173
+ const newOpenToken = new state.Token("yfm_note_open", "div", 1);
174
+ newOpenToken.attrSet("class", `yfm-note yfm-accent-${type}`);
175
+ newOpenToken.attrSet("note-type", type);
176
+ newOpenToken.map = tokens[i].map;
177
+ const closeTokenMap = tokens[closeTokenIdx].map;
178
+ if (closeTokenMap && newOpenToken.map) {
179
+ newOpenToken.map[1] = closeTokenMap[1];
180
+ }
181
+ const newCloseToken = new state.Token("yfm_note_close", "div", -1);
182
+ newCloseToken.map = tokens[closeTokenIdx].map;
183
+ const titleOpen = new state.Token("yfm_note_title_open", "p", 1);
184
+ titleOpen.attrSet("class", "yfm-note-title");
185
+ const autotitle = notesAutotitle ? getTitle(type, lang) : "";
186
+ const titleContent = match[2] === void 0 ? autotitle : match[2];
187
+ const titleInline = state.md.parseInline(titleContent, state.env)[0];
188
+ titleInline.map = null;
189
+ const titleClose = new state.Token("yfm_note_title_close", "p", -1);
190
+ titleOpen.block = true;
191
+ titleClose.block = true;
192
+ const contentOpen = new state.Token("yfm_note_content_open", "div", 1);
193
+ contentOpen.attrSet("class", "yfm-note-content");
194
+ const contentClose = new state.Token("yfm_note_content_close", "div", -1);
195
+ if (newOpenToken.map) {
196
+ contentOpen.map = [newOpenToken.map[0] + 2, newOpenToken.map[1] - 2];
197
+ }
198
+ const insideTokens = [newOpenToken];
199
+ if (titleInline.content) {
200
+ insideTokens.push(titleOpen, titleInline, titleClose);
201
+ }
202
+ insideTokens.push(
203
+ contentOpen,
204
+ ...tokens.slice(i + 3, closeTokenIdx),
205
+ contentClose,
206
+ newCloseToken
207
+ );
208
+ tokens.splice(i, closeTokenIdx - i + 3, ...insideTokens);
209
+ onNote?.(env);
210
+ i++;
211
+ } else if (matchWrongNotes(tokens, i) && tokens[i + 1].content !== "{% endnote %}") {
212
+ log.warn(
213
+ `Incorrect syntax for notes${path ? `, file ${formatPath(path)}` : ""}`
214
+ );
215
+ i += 3;
216
+ } else {
217
+ i++;
218
+ }
219
+ }
220
+ };
221
+ try {
222
+ md.core.ruler.before("curly_attributes", "notes", plugin);
223
+ } catch {
224
+ md.core.ruler.push("notes", plugin);
225
+ }
226
+ };
227
+ return index;
228
+ }
229
+ export {
230
+ DEFAULT_LANG,
231
+ TITLES,
232
+ TokenType,
233
+ createNotesPlugin
234
+ };
235
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/plugin/close.ts", "../../src/plugin/const.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 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"],
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,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;AAA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
+ 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
+ }
@@ -0,0 +1,23 @@
1
+ import type { NotesOptions, NotesPlugin } from '../plugin/types.js';
2
+ import type { RuntimeOption } from '../plugin/resources.js';
3
+ import { TokenType } from '../plugin/const.js';
4
+ export type TransformOptions = NotesOptions & {
5
+ runtime?: RuntimeOption;
6
+ bundle?: false;
7
+ };
8
+ export declare function transform(options?: TransformOptions): NotesPlugin;
9
+ export { TokenType };
10
+ export type { NotesOptions, NotesLogger } from '../plugin/types.js';
11
+ declare const _default: {
12
+ transform: typeof transform;
13
+ TokenType: {
14
+ readonly Note: "yfm-note";
15
+ readonly NoteOpen: "yfm_note_open";
16
+ readonly NoteClose: "yfm_note_close";
17
+ readonly NoteTitleOpen: "yfm_note_title_open";
18
+ readonly NoteTitleClose: "yfm_note_title_close";
19
+ readonly NoteContentOpen: "yfm_note_content_open";
20
+ readonly NoteContentClose: "yfm_note_content_close";
21
+ };
22
+ };
23
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import type { MatchTokenFunction, NoteToken, NotesLogger } from './types.js';
2
+ /**
3
+ * Bind the existing close-token search to the host's path formatter.
4
+ * @param formatPath - Plain browser or original terminal path formatting.
5
+ * @returns The existing finite token-search factory.
6
+ */
7
+ export declare function createNestedCloseTokenIdxFactory(formatPath: (path: string) => string): (tokenName: string, matchOpenToken: MatchTokenFunction, matchCloseToken: MatchTokenFunction) => (tokens: NoteToken[], idx: number, path: string, log: NotesLogger) => number | null;
@@ -0,0 +1,19 @@
1
+ export declare const ENV_FLAG_NAME = "has-yfm-notes";
2
+ export declare const DEFAULT_LANG = "ru";
3
+ export type Lang = 'ru' | 'en' | 'ar' | 'cs' | 'fr' | 'es' | 'he' | 'bg' | 'et' | 'el' | 'pt' | 'zh' | 'zh-tw' | 'kk' | 'tr' | 'uz';
4
+ export declare const TITLES: Record<Lang, Record<string, string>>;
5
+ export declare const TokenType: {
6
+ readonly Note: "yfm-note";
7
+ readonly NoteOpen: "yfm_note_open";
8
+ readonly NoteClose: "yfm_note_close";
9
+ readonly NoteTitleOpen: "yfm_note_title_open";
10
+ readonly NoteTitleClose: "yfm_note_title_close";
11
+ readonly NoteContentOpen: "yfm_note_content_open";
12
+ readonly NoteContentClose: "yfm_note_content_close";
13
+ };
14
+ export declare const ClassNames: {
15
+ readonly Note: "yfm-note";
16
+ readonly Accent: "yfm-accent";
17
+ readonly Title: "yfm-note-title";
18
+ readonly Content: "yfm-note-content";
19
+ };
@@ -0,0 +1,18 @@
1
+ import { transform } from './transform.js';
2
+ import { TokenType } from './const.js';
3
+ export { transform, TokenType };
4
+ export type { TransformOptions, NotesTransformPlugin, PluginOptions, CollectOptions, } from './transform.js';
5
+ export type { NotesOptions, NotesLogger } from './types.js';
6
+ declare const _default: {
7
+ transform: typeof transform;
8
+ TokenType: {
9
+ readonly Note: "yfm-note";
10
+ readonly NoteOpen: "yfm_note_open";
11
+ readonly NoteClose: "yfm_note_close";
12
+ readonly NoteTitleOpen: "yfm_note_title_open";
13
+ readonly NoteTitleClose: "yfm_note_title_close";
14
+ readonly NoteContentOpen: "yfm_note_content_open";
15
+ readonly NoteContentClose: "yfm_note_content_close";
16
+ };
17
+ };
18
+ export default _default;
@@ -0,0 +1,8 @@
1
+ import type { NotesPlugin } from './types.js';
2
+ /**
3
+ * Bind existing feature diagnostics to an execution-host path formatter.
4
+ * @param formatPath - Original terminal or plain browser formatting.
5
+ * @param onNote - Optional host resource notification after a real note is created.
6
+ * @returns The unchanged feature callback.
7
+ */
8
+ export declare function createNotesPlugin(formatPath?: (path: string) => string, onNote?: (env: Record<string, unknown>) => void): NotesPlugin;
@@ -0,0 +1,4 @@
1
+ export { createNotesPlugin } from './plugin.js';
2
+ export { TokenType, TITLES, DEFAULT_LANG } from './const.js';
3
+ export type { Lang } from './const.js';
4
+ export type { NoteParser, NoteState, NoteToken, NotesLogger, NotesOptions, NotesPlugin, } from './types.js';
@@ -0,0 +1,9 @@
1
+ import type { NotesOptions } from './types.js';
2
+ export type Runtime = {
3
+ style: string;
4
+ script?: string;
5
+ };
6
+ export type RuntimeOption = false | string | Runtime;
7
+ export declare function normalizeRuntime(runtime?: RuntimeOption, bundle?: boolean): Runtime | false;
8
+ export declare function semanticOptions(defaults: NotesOptions, settings: NotesOptions): NotesOptions;
9
+ export declare function addResources(env: Record<string, unknown>, runtime: Runtime): void;
@@ -0,0 +1,17 @@
1
+ import type { NoteParser, NoteToken, NotesOptions } from './types.js';
2
+ import type { RuntimeOption } from './resources.js';
3
+ export type TransformOptions = NotesOptions & {
4
+ runtime?: RuntimeOption;
5
+ bundle?: boolean;
6
+ };
7
+ export type PluginOptions = NotesOptions & {
8
+ output?: string;
9
+ };
10
+ export type CollectOptions = NotesOptions & {
11
+ destRoot?: string;
12
+ };
13
+ export interface NotesTransformPlugin {
14
+ <Token extends NoteToken>(md: NoteParser<Token>, settings?: PluginOptions): void;
15
+ collect(input: string, options?: CollectOptions): void;
16
+ }
17
+ export declare function transform(options?: TransformOptions): NotesTransformPlugin;
@@ -0,0 +1,35 @@
1
+ export interface NoteToken {
2
+ type: string;
3
+ content: string;
4
+ map: [number, number] | null;
5
+ block: boolean;
6
+ attrSet(name: string, value: string): void;
7
+ }
8
+ export interface NoteState<Token extends NoteToken> {
9
+ tokens: Token[];
10
+ env: Record<string, unknown>;
11
+ Token: new (type: string, tag: string, nesting: -1 | 0 | 1) => Token;
12
+ md: {
13
+ parseInline(source: string, env: Record<string, unknown>): Token[];
14
+ };
15
+ }
16
+ export interface NoteParser<Token extends NoteToken> {
17
+ core: {
18
+ ruler: {
19
+ before(beforeName: string, name: string, rule: (state: NoteState<Token>) => void): void;
20
+ push(name: string, rule: (state: NoteState<Token>) => void): void;
21
+ };
22
+ };
23
+ }
24
+ export type NotesOptions = {
25
+ lang?: string;
26
+ notesAutotitle?: boolean;
27
+ path?: string;
28
+ log?: NotesLogger;
29
+ };
30
+ export interface NotesLogger {
31
+ warn(message: string): void;
32
+ error(message: string): void;
33
+ }
34
+ export type NotesPlugin = <Token extends NoteToken>(md: NoteParser<Token>, options?: NotesOptions) => void;
35
+ export type MatchTokenFunction = (tokens: NoteToken[], index: number) => boolean | RegExpMatchArray | null;
@@ -0,0 +1 @@
1
+ export {};