@diplodoc/client 3.4.3 → 3.4.5

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.
@@ -14774,6 +14774,26 @@ function TabsRuntime(props = {}) {
14774
14774
  mod
14775
14775
  ));
14776
14776
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
14777
+ var __async = (__this, __arguments, generator) => {
14778
+ return new Promise((resolve, reject) => {
14779
+ var fulfilled = (value) => {
14780
+ try {
14781
+ step(generator.next(value));
14782
+ } catch (e) {
14783
+ reject(e);
14784
+ }
14785
+ };
14786
+ var rejected = (value) => {
14787
+ try {
14788
+ step(generator.throw(value));
14789
+ } catch (e) {
14790
+ reject(e);
14791
+ }
14792
+ };
14793
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
14794
+ step((generator = generator.apply(__this, __arguments)).next());
14795
+ });
14796
+ };
14777
14797
 
14778
14798
  // node_modules/get-root-node-polyfill/index.js
14779
14799
  var require_get_root_node_polyfill = __commonJS({
@@ -15169,12 +15189,9 @@ function TabsRuntime(props = {}) {
15169
15189
  const target = getEventTarget(event);
15170
15190
  return !target || !target.matches;
15171
15191
  };
15172
-
15173
- // src/js/code.ts
15174
- var BUTTON_SELECTOR = ".yfm-clipboard-button";
15175
- function copyToClipboard(text) {
15192
+ var copyToClipboard = (text) => __async(void 0, null, function* () {
15176
15193
  if (!text) {
15177
- return Promise.resolve();
15194
+ return;
15178
15195
  }
15179
15196
  if (navigator.clipboard && typeof navigator.clipboard.writeText) {
15180
15197
  return navigator.clipboard.writeText(text);
@@ -15186,8 +15203,10 @@ function TabsRuntime(props = {}) {
15186
15203
  textarea.select();
15187
15204
  document.execCommand("copy");
15188
15205
  document.body.removeChild(textarea);
15189
- return Promise.resolve();
15190
- }
15206
+ });
15207
+
15208
+ // src/js/code.ts
15209
+ var BUTTON_SELECTOR = ".yfm-clipboard-button";
15191
15210
  function notifySuccess(svgButton) {
15192
15211
  if (!svgButton) {
15193
15212
  return;
@@ -15213,12 +15232,32 @@ function TabsRuntime(props = {}) {
15213
15232
  if (!code) {
15214
15233
  return;
15215
15234
  }
15216
- copyToClipboard(code.innerText).then(() => {
15235
+ const textContent = Array.from(code.childNodes).filter((node) => {
15236
+ if (node instanceof HTMLElement && node.classList.contains("yfm-line-number")) {
15237
+ return false;
15238
+ }
15239
+ return true;
15240
+ }).map((node) => node.textContent).join("");
15241
+ copyToClipboard(textContent).then(() => {
15217
15242
  notifySuccess(parent.querySelector(".yfm-clipboard-icon"));
15218
15243
  });
15219
15244
  });
15220
15245
  }
15221
15246
 
15247
+ // src/js/anchor.ts
15248
+ var ANCHOR_BUTTON_SELECTOR = ".yfm-clipboard-anchor";
15249
+ if (typeof document !== "undefined") {
15250
+ document.addEventListener("click", (event) => {
15251
+ const target = getEventTarget(event);
15252
+ if (isCustom(event) || !target.matches(ANCHOR_BUTTON_SELECTOR)) {
15253
+ return;
15254
+ }
15255
+ const href = target.getAttribute("data-href") || "";
15256
+ const link = new URL(href, window.location.href).toString();
15257
+ copyToClipboard(link);
15258
+ });
15259
+ }
15260
+
15222
15261
  // src/js/term/utils.ts
15223
15262
  var Selector = {
15224
15263
  TITLE: ".yfm .yfm-term_title",
@@ -15227,17 +15266,6 @@ function TabsRuntime(props = {}) {
15227
15266
  var openClass = "open";
15228
15267
  var openDefinitionClass = Selector.CONTENT.replace(/\./g, "") + " " + openClass;
15229
15268
  var isListenerNeeded = true;
15230
- function createDefinitionElement(termElement) {
15231
- var _a;
15232
- const termKey = termElement.getAttribute("term-key");
15233
- const definitionTemplate = document.getElementById(
15234
- `${termKey}_template`
15235
- );
15236
- const definitionElement = definitionTemplate == null ? void 0 : definitionTemplate.content.cloneNode(true).firstChild;
15237
- (_a = definitionTemplate == null ? void 0 : definitionTemplate.parentElement) == null ? void 0 : _a.appendChild(definitionElement);
15238
- definitionTemplate.remove();
15239
- return definitionElement;
15240
- }
15241
15269
  function setDefinitionId(definitionElement, termElement) {
15242
15270
  const termId = termElement.getAttribute("id") || Math.random().toString(36).substr(2, 8);
15243
15271
  definitionElement == null ? void 0 : definitionElement.setAttribute("term-id", termId);
@@ -15320,10 +15348,7 @@ function TabsRuntime(props = {}) {
15320
15348
  const openedDefinition = document.getElementsByClassName(openDefinitionClass)[0];
15321
15349
  const termId = target.getAttribute("id");
15322
15350
  const termKey = target.getAttribute("term-key");
15323
- let definitionElement = document.getElementById(termKey + "_element");
15324
- if (termKey && !definitionElement) {
15325
- definitionElement = createDefinitionElement(target);
15326
- }
15351
+ const definitionElement = document.getElementById(termKey + "_element");
15327
15352
  const isSameTerm = openedDefinition && termId === openedDefinition.getAttribute("term-id");
15328
15353
  if (isSameTerm) {
15329
15354
  closeDefinition(openedDefinition);
@@ -15556,6 +15581,18 @@ function TabsRuntime(props = {}) {
15556
15581
  //# sourceMappingURL=yfm.js.map
15557
15582
 
15558
15583
 
15584
+ /***/ }),
15585
+
15586
+ /***/ 55323:
15587
+ /***/ ((__unused_webpack_module, exports) => {
15588
+
15589
+ "use strict";
15590
+
15591
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
15592
+ exports.DEFAULT_LANG = void 0;
15593
+ exports.DEFAULT_LANG = 'ru';
15594
+ //# sourceMappingURL=constants.js.map
15595
+
15559
15596
  /***/ }),
15560
15597
 
15561
15598
  /***/ 97584:
@@ -17097,6 +17134,29 @@ exports["default"] = exports.log;
17097
17134
 
17098
17135
  "use strict";
17099
17136
 
17137
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
17138
+ if (k2 === undefined) k2 = k;
17139
+ var desc = Object.getOwnPropertyDescriptor(m, k);
17140
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17141
+ desc = { enumerable: true, get: function() { return m[k]; } };
17142
+ }
17143
+ Object.defineProperty(o, k2, desc);
17144
+ }) : (function(o, m, k, k2) {
17145
+ if (k2 === undefined) k2 = k;
17146
+ o[k2] = m[k];
17147
+ }));
17148
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17149
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
17150
+ }) : function(o, v) {
17151
+ o["default"] = v;
17152
+ });
17153
+ var __importStar = (this && this.__importStar) || function (mod) {
17154
+ if (mod && mod.__esModule) return mod;
17155
+ var result = {};
17156
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
17157
+ __setModuleDefault(result, mod);
17158
+ return result;
17159
+ };
17100
17160
  var __rest = (this && this.__rest) || function (s, e) {
17101
17161
  var t = {};
17102
17162
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
@@ -17119,8 +17179,9 @@ const log_1 = __webpack_require__(69184);
17119
17179
  const highlight_1 = __importDefault(__webpack_require__(44370));
17120
17180
  const title_1 = __importDefault(__webpack_require__(50440));
17121
17181
  const headings_1 = __importDefault(__webpack_require__(70235));
17122
- const sanitize_1 = __importDefault(__webpack_require__(44891));
17182
+ const sanitize_1 = __importStar(__webpack_require__(44891));
17123
17183
  const ol_attr_conversion_1 = __webpack_require__(37985);
17184
+ const constants_1 = __webpack_require__(55323);
17124
17185
  function initMarkdownIt(options) {
17125
17186
  const { allowHTML = false, linkify = false, breaks = true, highlightLangs = {}, disableRules = [], } = options;
17126
17187
  const highlight = (0, highlight_1.default)(highlightLangs);
@@ -17157,13 +17218,14 @@ function initMarkdownIt(options) {
17157
17218
  return { parse, compile, env };
17158
17219
  }
17159
17220
  function getPluginOptions(options) {
17160
- const { vars = {}, path, extractTitle, conditionsInCode = false, disableLiquid = false } = options, customOptions = __rest(options, ["vars", "path", "extractTitle", "conditionsInCode", "disableLiquid"]);
17221
+ const { vars = {}, path, extractTitle, conditionsInCode = false, disableLiquid = false, lang = constants_1.DEFAULT_LANG } = options, customOptions = __rest(options, ["vars", "path", "extractTitle", "conditionsInCode", "disableLiquid", "lang"]);
17161
17222
  return Object.assign(Object.assign({}, customOptions), { conditionsInCode,
17162
17223
  vars,
17163
17224
  path,
17164
17225
  extractTitle,
17165
17226
  disableLiquid,
17166
- log: log_1.log });
17227
+ log: log_1.log,
17228
+ lang });
17167
17229
  }
17168
17230
  function initPlugins(md, options, pluginOptions) {
17169
17231
  const { linkify = false, linkifyTlds, leftDelimiter = '{', rightDelimiter = '}', plugins = plugins_1.default, enableMarkdownAttrs, } = options;
@@ -17206,18 +17268,31 @@ function initParser(md, options, env, pluginOptions) {
17206
17268
  };
17207
17269
  }
17208
17270
  function initCompiler(md, options, env) {
17209
- const { needToSanitizeHtml = true, renderInline = false, sanitizeOptions } = options;
17271
+ const { needToSanitizeHtml = true, renderInline = false, sanitizeOptions, sanitize } = options;
17210
17272
  return (tokens) => {
17273
+ var _a;
17211
17274
  // Remove inline tokens if inline mode is activated
17212
17275
  if (renderInline) {
17213
17276
  tokens = tokens.filter((token) => token.type === 'inline');
17214
17277
  }
17215
17278
  // Generate HTML
17216
- const html = md.renderer.render(tokens, md.options, env);
17217
- // Sanitize the page
17218
- return needToSanitizeHtml
17219
- ? (0, sanitize_1.default)(html, sanitizeOptions, { cssWhiteList: env.additionalOptionsCssWhiteList })
17220
- : html;
17279
+ let html = md.renderer.render(tokens, md.options, env);
17280
+ if (!needToSanitizeHtml) {
17281
+ return html;
17282
+ }
17283
+ // If a custom sanitizer was used, we need to ensure styles are sanitized
17284
+ // unless explicitly disabled via disableStyleSanitizer option
17285
+ if (sanitize && !((_a = sanitizeOptions === null || sanitizeOptions === void 0 ? void 0 : sanitizeOptions.disableStyleSanitizer) !== null && _a !== void 0 ? _a : false)) {
17286
+ const baseOptions = sanitizeOptions || sanitize_1.defaultOptions;
17287
+ const mergedOptions = Object.assign(Object.assign({}, baseOptions), { cssWhiteList: Object.assign(Object.assign(Object.assign({}, (sanitize_1.defaultOptions.cssWhiteList || {})), (baseOptions.cssWhiteList || {})), (env.additionalOptionsCssWhiteList || {})) });
17288
+ html = (0, sanitize_1.sanitizeStyles)(html, mergedOptions);
17289
+ }
17290
+ const sanitizedHtml = sanitize
17291
+ ? sanitize(html, sanitizeOptions)
17292
+ : (0, sanitize_1.default)(html, sanitizeOptions, {
17293
+ cssWhiteList: env.additionalOptionsCssWhiteList,
17294
+ });
17295
+ return sanitizedHtml;
17221
17296
  };
17222
17297
  }
17223
17298
  module.exports = initMarkdownIt;
@@ -17276,9 +17351,27 @@ module.exports = defaultPlugins;
17276
17351
  "use strict";
17277
17352
 
17278
17353
  Object.defineProperty(exports, "__esModule", ({ value: true }));
17279
- exports.CUSTOM_ID_EXCEPTION = exports.CUSTOM_ID_REGEXP = void 0;
17354
+ exports.ANCHOR_TITLES = exports.CUSTOM_ID_EXCEPTION = exports.CUSTOM_ID_REGEXP = void 0;
17280
17355
  exports.CUSTOM_ID_REGEXP = /\[?{ ?#(\S+) ?}]?/g;
17281
17356
  exports.CUSTOM_ID_EXCEPTION = '[{#T}]';
17357
+ exports.ANCHOR_TITLES = {
17358
+ ru: 'Скопировать ссылку',
17359
+ en: 'Copy link',
17360
+ ar: 'انسخ الرابط',
17361
+ cs: 'Zkopírovat odkaz',
17362
+ fr: 'Copier le lien',
17363
+ es: 'Copiar enlace',
17364
+ he: 'העתק קישור',
17365
+ bg: 'Копиране на връзката',
17366
+ et: 'Kopeeri viide',
17367
+ el: 'Αντιγράψτε τον σύνδεσμο',
17368
+ pt: 'Copiar o link',
17369
+ zh: '复制链接',
17370
+ 'zh-tw': '複製連結',
17371
+ kk: 'Сілтемені көшіру',
17372
+ tr: 'Bağlantıyı kopyala',
17373
+ uz: 'Havolani nusxalash',
17374
+ };
17282
17375
  //# sourceMappingURL=constants.js.map
17283
17376
 
17284
17377
  /***/ }),
@@ -17297,7 +17390,19 @@ const utils_1 = __webpack_require__(49963);
17297
17390
  const slugify_1 = __importDefault(__webpack_require__(12495));
17298
17391
  const utils_2 = __webpack_require__(82811);
17299
17392
  const constants_1 = __webpack_require__(54493);
17300
- function createLinkTokens(state, id, title, setId = false, href) {
17393
+ function createAnchorButtonTokens(state, id, setId = false, href, title) {
17394
+ const open = new state.Token('anchor_open', 'button', 1);
17395
+ const close = new state.Token('anchor_close', 'button', -1);
17396
+ if (setId) {
17397
+ open.attrSet('id', id);
17398
+ }
17399
+ open.attrSet('class', 'yfm-clipboard-anchor');
17400
+ open.attrSet('data-href', href + '#' + id);
17401
+ open.attrSet('aria-label', title);
17402
+ open.attrSet('title', title);
17403
+ return [open, close];
17404
+ }
17405
+ function createAnchorLinkTokens(state, id, setId = false, href, title) {
17301
17406
  const open = new state.Token('link_open', 'a', 1);
17302
17407
  const close = new state.Token('link_close', 'a', -1);
17303
17408
  if (setId) {
@@ -17342,7 +17447,7 @@ const removeCustomIds = (token) => {
17342
17447
  });
17343
17448
  };
17344
17449
  const index = (md, options) => {
17345
- const { extractTitle, path, log, supportGithubAnchors, getPublicPath, disableCommonAnchors } = options;
17450
+ const { extractTitle, path, log, supportGithubAnchors, getPublicPath, disableCommonAnchors, useCommonAnchorButtons, lang, } = options;
17346
17451
  const plugin = (state) => {
17347
17452
  /* Do not use the plugin if it is included in the file */
17348
17453
  if (state.env.includes && state.env.includes.length) {
@@ -17353,6 +17458,9 @@ const index = (md, options) => {
17353
17458
  const tokens = state.tokens;
17354
17459
  let i = 0;
17355
17460
  const slugger = new github_slugger_1.default();
17461
+ const createAnchorTokens = useCommonAnchorButtons
17462
+ ? createAnchorButtonTokens
17463
+ : createAnchorLinkTokens;
17356
17464
  while (i < tokens.length) {
17357
17465
  const token = tokens[i];
17358
17466
  const isHeading = token.type === 'heading_open';
@@ -17391,16 +17499,18 @@ const index = (md, options) => {
17391
17499
  ids[id] = 1;
17392
17500
  }
17393
17501
  const allAnchorIds = customIds ? customIds : [id];
17394
- const anchorTitle = removeCustomId(title).replace(/`/g, '');
17502
+ const anchorTitle = useCommonAnchorButtons
17503
+ ? constants_1.ANCHOR_TITLES[lang]
17504
+ : removeCustomId(title).replace(/`/g, '');
17395
17505
  allAnchorIds.forEach((customId) => {
17396
17506
  var _a, _b;
17397
17507
  const setId = id !== customId;
17398
17508
  if (!disableCommonAnchors) {
17399
- const linkTokens = createLinkTokens(state, customId, anchorTitle, setId, href);
17509
+ const linkTokens = createAnchorTokens(state, customId, setId, href, anchorTitle);
17400
17510
  (_a = inlineToken.children) === null || _a === void 0 ? void 0 : _a.unshift(...linkTokens);
17401
17511
  }
17402
17512
  if (supportGithubAnchors) {
17403
- const ghLinkTokens = createLinkTokens(state, ghId, anchorTitle, true, href);
17513
+ const ghLinkTokens = createAnchorTokens(state, ghId, true, href, anchorTitle);
17404
17514
  (_b = inlineToken.children) === null || _b === void 0 ? void 0 : _b.unshift(...ghLinkTokens);
17405
17515
  }
17406
17516
  });
@@ -17571,10 +17681,35 @@ function termReplace(str, env, escape) {
17571
17681
  const termCode = str.replace(reg, (_match, p1, _p2, p3) => `<i class="yfm yfm-term_title" term-key=":${p3}" id="${(0, utils_1.generateID)()}">${p1}</i>`);
17572
17682
  return termCode || str;
17573
17683
  }
17684
+ function addLineNumbers(code) {
17685
+ const lines = code.split('\n');
17686
+ const lineCount = lines.length;
17687
+ const maxDigits = String(lineCount).length;
17688
+ // Remove trailing empty line if it exists
17689
+ const hasTrailingNewline = code.endsWith('\n');
17690
+ const linesToProcess = hasTrailingNewline ? lines.slice(0, -1) : lines;
17691
+ return (linesToProcess
17692
+ .map((line, index) => {
17693
+ const lineNumber = String(index + 1).padStart(maxDigits, ' ');
17694
+ return `<span class="yfm-line-number">${lineNumber}</span>${line}`;
17695
+ })
17696
+ .join('\n') + (hasTrailingNewline ? '\n' : ''));
17697
+ }
17574
17698
  const code = (md) => {
17575
17699
  const superCodeRenderer = md.renderer.rules.fence;
17576
17700
  md.renderer.rules.fence = function (tokens, idx, options, env, self) {
17577
- const superCode = superCodeRenderer === null || superCodeRenderer === void 0 ? void 0 : superCodeRenderer(tokens, idx, options, env, self);
17701
+ const token = tokens[idx];
17702
+ const showLineNumbers = token.info.includes('showLineNumbers');
17703
+ let superCode = superCodeRenderer === null || superCodeRenderer === void 0 ? void 0 : superCodeRenderer(tokens, idx, options, env, self);
17704
+ if (superCode && showLineNumbers) {
17705
+ // Extract the code content from the pre/code tags
17706
+ const codeMatch = superCode.match(/<pre[^>]*><code[^>]*>([\s\S]*?)<\/code><\/pre>/);
17707
+ if (codeMatch) {
17708
+ const codeContent = codeMatch[1];
17709
+ const codeWithLineNumbers = addLineNumbers(codeContent);
17710
+ superCode = superCode.replace(codeContent, codeWithLineNumbers);
17711
+ }
17712
+ }
17578
17713
  const superCodeWithTerms = superCode && (env === null || env === void 0 ? void 0 : env.terms) ? termReplace(superCode, env, md.utils.escapeRE) : superCode;
17579
17714
  return wrapInClipboard(superCodeWithTerms, idx);
17580
17715
  };
@@ -18197,21 +18332,22 @@ exports.TITLES = {
18197
18332
 
18198
18333
  const chalk_1 = __webpack_require__(55248);
18199
18334
  const utils_1 = __webpack_require__(29108);
18200
- const constants_1 = __webpack_require__(51070);
18335
+ const constants_1 = __webpack_require__(55323);
18336
+ const constants_2 = __webpack_require__(51070);
18201
18337
  const ALERT_RE = /^{% note (alert|info|tip|warning)\s*(?:"(.*?)")? %}$/;
18202
18338
  const WRONG_NOTES = /^{% note (.*)%}/;
18203
- function getTitle(type, originLang) {
18204
- let lang = originLang;
18205
- if (!lang || !Object.keys(constants_1.TITLES).includes(lang)) {
18206
- lang = 'ru';
18207
- }
18208
- return constants_1.TITLES[lang][type];
18209
- }
18210
18339
  const matchCloseToken = (tokens, i) => {
18211
18340
  return (tokens[i].type === 'paragraph_open' &&
18212
18341
  tokens[i + 1].type === 'inline' &&
18213
18342
  tokens[i + 1].content.trim() === '{% endnote %}');
18214
18343
  };
18344
+ function getTitle(type, originLang) {
18345
+ let lang = originLang;
18346
+ if (!lang || !Object.keys(constants_2.TITLES).includes(lang)) {
18347
+ lang = constants_1.DEFAULT_LANG;
18348
+ }
18349
+ return constants_2.TITLES[lang][type];
18350
+ }
18215
18351
  function matchOpenToken(tokens, i) {
18216
18352
  return (tokens[i].type === 'paragraph_open' &&
18217
18353
  tokens[i + 1].type === 'inline' &&
@@ -18223,8 +18359,7 @@ function matchWrongNotes(tokens, i) {
18223
18359
  tokens[i + 1].content.match(WRONG_NOTES));
18224
18360
  }
18225
18361
  const findCloseTokenIdx = (0, utils_1.nestedCloseTokenIdxFactory)('Note', matchOpenToken, matchCloseToken);
18226
- // @ts-ignore
18227
- const index = (md, { lang, notesAutotitle, path: optPath, log }) => {
18362
+ const index = (md, { lang = constants_1.DEFAULT_LANG, notesAutotitle, path: optPath, log }) => {
18228
18363
  notesAutotitle = typeof notesAutotitle === 'boolean' ? notesAutotitle : true;
18229
18364
  const plugin = (state) => {
18230
18365
  const { tokens, env } = state;
@@ -18254,20 +18389,19 @@ const index = (md, { lang, notesAutotitle, path: optPath, log }) => {
18254
18389
  // Add extra paragraph
18255
18390
  const titleOpen = new state.Token('yfm_note_title_open', 'p', 1);
18256
18391
  titleOpen.attrSet('class', 'yfm-note-title');
18257
- const titleInline = new state.Token('inline', '', 0);
18392
+ const autotitle = notesAutotitle ? getTitle(type, lang) : '';
18393
+ const titleContent = match[2] === undefined ? autotitle : match[2];
18394
+ const titleInline = state.md.parseInline(titleContent, state.env)[0];
18395
+ titleInline.map = null;
18258
18396
  const titleClose = new state.Token('yfm_note_title_close', 'p', -1);
18259
18397
  titleOpen.block = true;
18260
18398
  titleClose.block = true;
18261
- const autotitle = notesAutotitle ? getTitle(type, lang) : '';
18262
- titleInline.content = match[2] === undefined ? autotitle : match[2];
18263
- titleInline.children = [];
18264
18399
  const contentOpen = new state.Token('yfm_note_content_open', 'div', 1);
18265
18400
  contentOpen.attrSet('class', 'yfm-note-content');
18266
18401
  const contentClose = new state.Token('yfm_note_content_close', 'div', -1);
18267
18402
  if (newOpenToken.map) {
18268
18403
  contentOpen.map = [newOpenToken.map[0] + 2, newOpenToken.map[1] - 2];
18269
18404
  }
18270
- state.md.inline.parse(titleInline.content, state.md, state.env, titleInline.children);
18271
18405
  const insideTokens = [newOpenToken];
18272
18406
  if (titleInline.content) {
18273
18407
  insideTokens.push(titleOpen, titleInline, titleClose);
@@ -19179,11 +19313,6 @@ function processTermDefinition(md, options, state, currentLine, startLine, endLi
19179
19313
  if (typeof state.env.terms[':' + label] === 'undefined') {
19180
19314
  state.env.terms[':' + label] = title;
19181
19315
  }
19182
- token = new state.Token('template_open', 'template', 1);
19183
- token.map = [startLine, currentLine + 1];
19184
- token.attrSet('id', ':' + label + '_template');
19185
- token.attrSet('label', label);
19186
- state.tokens.push(token);
19187
19316
  token = new state.Token('dfn_open', 'dfn', 1);
19188
19317
  token.attrSet('class', 'yfm yfm-term_dfn');
19189
19318
  token.attrSet('id', ':' + label + '_element');
@@ -19206,8 +19335,6 @@ function processTermDefinition(md, options, state, currentLine, startLine, endLi
19206
19335
  }
19207
19336
  token = new state.Token('dfn_close', 'dfn', -1);
19208
19337
  state.tokens.push(token);
19209
- token = new state.Token('template_close', 'template', -1);
19210
- state.tokens.push(token);
19211
19338
  /** current line links to end of term definition */
19212
19339
  state.line = currentLine + 1;
19213
19340
  return true;
@@ -19467,10 +19594,18 @@ function yandexParser(url) {
19467
19594
  return match ? match[1] : url;
19468
19595
  }
19469
19596
  exports.yandexParser = yandexParser;
19470
- const vkRegex = /^https:\/\/vk\.com\/video_ext\.php\?(oid=[-\d]+&id=[-\d]+)/;
19597
+ const vkRegex = /^https:\/\/vk\.com\/video_ext\.php\?(.*)/;
19471
19598
  function vkParser(url) {
19472
19599
  const match = url.match(vkRegex);
19473
- return match ? match[1] : url;
19600
+ if (match) {
19601
+ const searchParams = new URLSearchParams(match[1]);
19602
+ const encodedUrl = [];
19603
+ searchParams.forEach((value, key) => {
19604
+ encodedUrl.push(`${key}=${encodeURIComponent(value)}`);
19605
+ });
19606
+ return encodedUrl.join('&');
19607
+ }
19608
+ return url;
19474
19609
  }
19475
19610
  exports.vkParser = vkParser;
19476
19611
  const rutubeRegex = /^https:\/\/rutube\.ru\/video\/([a-zA-Z0-9]+)\/?/;
@@ -19714,7 +19849,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
19714
19849
  return (mod && mod.__esModule) ? mod : { "default": mod };
19715
19850
  };
19716
19851
  Object.defineProperty(exports, "__esModule", ({ value: true }));
19717
- exports.sanitize = exports.defaultOptions = exports.defaultParseOptions = void 0;
19852
+ exports.sanitize = exports.sanitizeStyles = exports.defaultOptions = exports.defaultParseOptions = void 0;
19718
19853
  const sanitize_html_1 = __importDefault(__webpack_require__(74728));
19719
19854
  // @ts-ignore
19720
19855
  const cssfilter_1 = __importDefault(__webpack_require__(56018));
@@ -19883,6 +20018,7 @@ const svgTags = [
19883
20018
  'view',
19884
20019
  'vkern',
19885
20020
  'animate',
20021
+ 'use',
19886
20022
  ];
19887
20023
  const htmlAttrs = [
19888
20024
  'accept',
@@ -20197,10 +20333,43 @@ const defaultCssWhitelist = Object.assign(Object.assign({}, cssfilter_1.default.
20197
20333
  const yfmHtmlAttrs = ['note-type', 'term-key'];
20198
20334
  const allowedTags = Array.from(new Set([...htmlTags, ...svgTags, ...sanitize_html_1.default.defaults.allowedTags]));
20199
20335
  const allowedAttributes = Array.from(new Set([...htmlAttrs, ...svgAttrs, ...yfmHtmlAttrs]));
20336
+ // For hrefs within "use" only allow local links to ids that start with "#"
20337
+ const useTagTransformer = (tagName, attribs) => {
20338
+ const cleanHref = (href) => {
20339
+ if (href.startsWith('#')) {
20340
+ return href;
20341
+ }
20342
+ else {
20343
+ return null;
20344
+ }
20345
+ };
20346
+ const cleanAttrs = (attrs) => {
20347
+ const HREF_ATTRIBUTES = ['xlink:href', 'href'];
20348
+ return Object.fromEntries(Object.entries(attrs)
20349
+ .map(([key, value]) => {
20350
+ if (HREF_ATTRIBUTES.includes(key)) {
20351
+ return [key, cleanHref(value)];
20352
+ }
20353
+ return [key, value];
20354
+ })
20355
+ .filter(([_, value]) => value !== null));
20356
+ };
20357
+ return {
20358
+ tagName,
20359
+ attribs: cleanAttrs(attribs),
20360
+ };
20361
+ };
20200
20362
  exports.defaultParseOptions = {
20201
20363
  lowerCaseAttributeNames: false,
20202
20364
  };
20203
- exports.defaultOptions = Object.assign(Object.assign({}, sanitize_html_1.default.defaults), { allowedTags, allowedAttributes: Object.assign(Object.assign({}, sanitize_html_1.default.defaults.allowedAttributes), { '*': allowedAttributes }), allowVulnerableTags: true, parser: exports.defaultParseOptions, cssWhiteList: defaultCssWhitelist });
20365
+ exports.defaultOptions = Object.assign(Object.assign({}, sanitize_html_1.default.defaults), { allowedTags, allowedAttributes: Object.assign(Object.assign({}, sanitize_html_1.default.defaults.allowedAttributes), { '*': allowedAttributes }), allowedSchemesAppliedToAttributes: [
20366
+ ...sanitize_html_1.default.defaults.allowedSchemesAppliedToAttributes,
20367
+ 'xlink:href',
20368
+ 'from',
20369
+ 'to',
20370
+ ], allowVulnerableTags: true, parser: exports.defaultParseOptions, cssWhiteList: defaultCssWhitelist, transformTags: {
20371
+ use: useTagTransformer,
20372
+ } });
20204
20373
  function sanitizeStyleTags(dom, cssWhiteList) {
20205
20374
  const styleTags = dom('style');
20206
20375
  styleTags.each((_index, element) => {
@@ -20260,6 +20429,7 @@ function sanitizeStyles(html, options) {
20260
20429
  const content = $('body').html() || '';
20261
20430
  return styles + content;
20262
20431
  }
20432
+ exports.sanitizeStyles = sanitizeStyles;
20263
20433
  function sanitize(html, options, additionalOptions) {
20264
20434
  var _a;
20265
20435
  const sanitizeOptions = options || exports.defaultOptions;