@diplodoc/cli 4.11.0 → 4.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/assets/app.js CHANGED
@@ -1,2 +1,2 @@
1
- (()=>{var e,t={3616:(e,t,n)=>{"use strict";var o=n(7294),r=n(745),i=n(7725),a=n(7537),c=n(7332),l=n(293),s=n(8534),d=n(9609),u=n(4990);const m=(0,o.memo)((({mobileView:e,theme:t,onChangeTheme:n,textSize:r,onChangeTextSize:i,wideFormat:a,onChangeWideFormat:c,showMiniToc:l,onChangeShowMiniToc:m})=>o.createElement(d.C,{controlClassName:"Control",controlSize:s.$D.L,isWideView:e,isMobileView:e},o.createElement(u.Z,{className:"Controls",theme:t,onChangeTheme:n,wideFormat:a,onChangeWideFormat:c,showMiniToc:l,onChangeShowMiniToc:m,textSize:r,onChangeTextSize:i}))));function h(e){return"boolean"==typeof e?e:!!e&&"true"===e}m.displayName="HeaderControls";const f=(0,n(2853).Z)("Layout");function w(){return null}function g(){return null}function p(){return null}const S=e=>{const{children:t,doc:n}=e;let r,i,a;return o.Children.forEach(t,(e=>{switch(e.type){case w:r=e.props.children;break;case g:i=e.props.children;break;case p:a=e.props.children}})),o.createElement("div",{className:f()},r&&o.createElement("div",{className:f("header")},r),o.createElement("div",{className:f("body")},i&&o.createElement("div",{className:f("content")},i),a&&o.createElement("div",{className:f("footer",{doc:n})},a)))};S.displayName="Layout",S.defaultProps={doc:!1},S.Header=w,S.Content=g,S.Footer=p;const v={theme:s.Q2.Light,textSize:s.tF.M,showMiniToc:!0,wideFormat:!0,fullScreen:!1};function y(e){if("undefined"==typeof sessionStorage)return v[e];try{return sessionStorage.getItem(e)||v[e]}catch{return v[e]}}function b(e,t){return n=>{!function(e,t){try{sessionStorage.setItem(e,String(t))}catch{}}(e,n),t(n)}}n(9380),n(8648);var E=n(5289),C=n(9295),T=n(5584);function M(e){const{data:t,...n}=e,r=t.leading?c.IU:l.Z;return o.createElement(S,null,o.createElement(S.Content,null,o.createElement(r,Object.assign({},t,n))))}function F(e){const t={...e};return function(e){return Array.isArray(e.items)}(e)&&(t.items=e.items.map(F)),void 0!==e.url&&(t.url=e.url.replace(/^\/?/,"/")),t}function _(e){const{data:t,router:n,lang:r}=e,{navigation:c}=t.toc,l=function(){const e=function(){const e=y("theme"),t=y("textSize"),n=y("showMiniToc"),o=y("wideFormat"),r=y("fullScreen");return{theme:e,textSize:t,showMiniToc:h(n),wideFormat:h(o),fullScreen:h(r)}}(),[t,n]=(0,o.useState)(e.wideFormat),[r,i]=(0,o.useState)(e.fullScreen),[a,c]=(0,o.useState)(e.showMiniToc),[l,s]=(0,o.useState)(e.theme),[d,u]=(0,o.useState)(e.textSize);return{theme:l,onChangeTheme:b("theme",s),textSize:d,onChangeTextSize:b("textSize",u),wideFormat:t,onChangeWideFormat:b("wideFormat",n),showMiniToc:a,onChangeShowMiniToc:b("showMiniToc",c),fullScreen:r,onChangeFullScreen:b("fullScreen",i)}}(),d=function(){const[e,t]=(0,o.useState)("undefined"!=typeof document&&document.body.clientWidth<769),n=(0,o.useCallback)((()=>{t(document.body.clientWidth<769)}),[]);return(0,o.useEffect)(n,[n]),(0,o.useEffect)((()=>(window.addEventListener("resize",n),()=>window.removeEventListener("resize",n))),[n]),e}(),{theme:u,textSize:f,wideFormat:w,fullScreen:g,showMiniToc:p,onChangeFullScreen:S}=l,v=!g&&Boolean(c),_={headerHeight:v?64:0,data:t,router:n,lang:r,wideFormat:w,showMiniToc:p,theme:u,textSize:f,fullScreen:g,onChangeFullScreen:S};if((0,o.useEffect)((()=>{!function({theme:e,mobileView:t=!1,wideFormat:n=!1,fullHeader:o=!1}){document.body.className=["g-root",t?"mobile":"desktop",n&&"dc-root_wide-format",o&&"dc-root_full-header","light"===e&&"g-root_theme_light","dark"===e&&"g-root_theme_dark"].filter(Boolean).join(" ")}({theme:u,mobileView:d,wideFormat:w,fullHeader:v})}),[u,d,w,v]),!c)return o.createElement("div",{className:"App"},o.createElement(M,Object.assign({},_,l)));const{header:x={},logo:O}=c,{leftItems:z=[],rightItems:k=[]}=x,j=k.some((e=>"controls"===e.type));return o.createElement("div",{className:"App"},o.createElement(i.W,{theme:u},o.createElement(a.C,{custom:{navigation:{controls:()=>o.createElement(m,Object.assign({},l,{mobileView:d}))},blocks:{page:()=>o.createElement(M,Object.assign({},_,j?{}:l))}},content:{blocks:[{type:"page"}]},navigation:v?{header:{withBorder:!0,leftItems:z.map(F),rightItems:k.map(F)},logo:O}:void 0})),o.createElement(T.r,null),o.createElement(C.S,null),o.createElement(E.u,{theme:u===s.Q2.Dark?"dark":"neutral",zoom:{showMenu:!0,bindKeys:!0}}))}const x=document.getElementById("root"),O=window.__DATA__;if(!x)throw new Error("Root element not found!");window.STATIC_CONTENT?(0,r.a)(x,o.createElement(_,O)):(0,r.s)(x).render(o.createElement(_,O))},9380:()=>{"undefined"!=typeof Element&&function(e){const t=e.matches||e.matchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector||e.msMatchesSelector||e.oMatchesSelector;e.matches=e.matchesSelector=t||function(e){const t=this;return Array.prototype.some.call(document.querySelectorAll(e),(e=>e===t))}}(Element.prototype),"undefined"!=typeof document&&document.addEventListener("click",(e=>{const t=e.target.href,n=window.location.origin;if(e.target.matches(".dc-doc-layout__center a")&&t.startsWith(n)){e.preventDefault();const n="index",o=".html";if(t.endsWith("/"))return void(window.location.href=`${t}${n}${o}`);const r=t.split("#");if(r.length>0&&!r[0].endsWith(o))return r[0]+=o,void(window.location.href=r.join("#"));window.location.href=t}}))},3615:(e,t,n)=>{"use strict";function o(){}n.d(t,{Z:()=>o})},4654:()=>{}},n={};function o(e){var r=n[e];if(void 0!==r)return r.exports;var i=n[e]={id:e,loaded:!1,exports:{}};return t[e].call(i.exports,i,i.exports,o),i.loaded=!0,i.exports}o.m=t,o.amdO={},e=[],o.O=(t,n,r,i)=>{if(!n){var a=1/0;for(d=0;d<e.length;d++){for(var[n,r,i]=e[d],c=!0,l=0;l<n.length;l++)(!1&i||a>=i)&&Object.keys(o.O).every((e=>o.O[e](n[l])))?n.splice(l--,1):(c=!1,i<a&&(a=i));if(c){e.splice(d--,1);var s=r();void 0!==s&&(t=s)}}return t}i=i||0;for(var d=e.length;d>0&&e[d-1][2]>i;d--)e[d]=e[d-1];e[d]=[n,r,i]},o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{var e={143:0};o.O.j=t=>0===e[t];var t=(t,n)=>{var r,i,[a,c,l]=n,s=0;if(a.some((t=>0!==e[t]))){for(r in c)o.o(c,r)&&(o.m[r]=c[r]);if(l)var d=l(o)}for(t&&t(n);s<a.length;s++)i=a[s],o.o(e,i)&&e[i]&&e[i][0](),e[i]=0;return o.O(d)},n=self.webpackChunk_diplodoc_client=self.webpackChunk_diplodoc_client||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))})();var r=o.O(void 0,[514,736],(()=>o(3616)));r=o.O(r)})();
1
+ (()=>{var e,t={3616:(e,t,n)=>{"use strict";var o=n(7294),r=n(745),i=n(7725),a=n(7537),c=n(8534),l=n(7332),s=n(293),d=n(9609),m=n(4990);const u=(0,o.memo)((({mobileView:e,theme:t,onChangeTheme:n,textSize:r,onChangeTextSize:i,wideFormat:a,onChangeWideFormat:l,showMiniToc:s,onChangeShowMiniToc:u})=>o.createElement(d.C,{controlClassName:"Control",controlSize:c.$D.L,isWideView:e,isMobileView:e},o.createElement(m.Z,{className:"Controls",theme:t,onChangeTheme:n,wideFormat:a,onChangeWideFormat:l,showMiniToc:s,onChangeShowMiniToc:u,textSize:r,onChangeTextSize:i}))));function h(e){return"boolean"==typeof e?e:!!e&&"true"===e}u.displayName="HeaderControls";const f=(0,n(2853).Z)("Layout");function w(){return null}function g(){return null}function p(){return null}const S=e=>{const{children:t,doc:n}=e;let r,i,a;return o.Children.forEach(t,(e=>{switch(e.type){case w:r=e.props.children;break;case g:i=e.props.children;break;case p:a=e.props.children}})),o.createElement("div",{className:f()},r&&o.createElement("div",{className:f("header")},r),o.createElement("div",{className:f("body")},i&&o.createElement("div",{className:f("content")},i),a&&o.createElement("div",{className:f("footer",{doc:n})},a)))};S.displayName="Layout",S.defaultProps={doc:!1},S.Header=w,S.Content=g,S.Footer=p;const v={theme:c.Q2.Light,textSize:c.tF.M,showMiniToc:!0,wideFormat:!0,fullScreen:!1};function y(e){if("undefined"==typeof sessionStorage)return v[e];try{return sessionStorage.getItem(e)||v[e]}catch{return v[e]}}function b(e,t){return n=>{!function(e,t){try{sessionStorage.setItem(e,String(t))}catch{}}(e,n),t(n)}}n(9380),n(8648);var E=n(5289),C=n(9295),T=n(5584);function M(e){const{theme:t}=e;return o.createElement(o.Fragment,null,o.createElement(T.r,null),o.createElement(C.S,null),o.createElement(E.u,{theme:t===c.Q2.Dark?"dark":"neutral",zoom:{showMenu:!0,bindKeys:!0}}))}function F(e){const{data:t,...n}=e,r=t.leading?l.IU:s.Z;return o.createElement(S,null,o.createElement(S.Content,null,o.createElement(r,Object.assign({},t,n))))}function _(e){const t={...e};return function(e){return Array.isArray(e.items)}(e)&&(t.items=e.items.map(_)),void 0!==e.url&&(t.url=e.url.replace(/^\/?/,"/")),t}function x(e){const{data:t,router:n,lang:r}=e,{navigation:c}=t.toc,l=function(){const e=function(){const e=y("theme"),t=y("textSize"),n=y("showMiniToc"),o=y("wideFormat"),r=y("fullScreen");return{theme:e,textSize:t,showMiniToc:h(n),wideFormat:h(o),fullScreen:h(r)}}(),[t,n]=(0,o.useState)(e.wideFormat),[r,i]=(0,o.useState)(e.fullScreen),[a,c]=(0,o.useState)(e.showMiniToc),[l,s]=(0,o.useState)(e.theme),[d,m]=(0,o.useState)(e.textSize);return{theme:l,onChangeTheme:b("theme",s),textSize:d,onChangeTextSize:b("textSize",m),wideFormat:t,onChangeWideFormat:b("wideFormat",n),showMiniToc:a,onChangeShowMiniToc:b("showMiniToc",c),fullScreen:r,onChangeFullScreen:b("fullScreen",i)}}(),s=function(){const[e,t]=(0,o.useState)("undefined"!=typeof document&&document.body.clientWidth<769),n=(0,o.useCallback)((()=>{t(document.body.clientWidth<769)}),[]);return(0,o.useEffect)(n,[n]),(0,o.useEffect)((()=>(window.addEventListener("resize",n),()=>window.removeEventListener("resize",n))),[n]),e}(),{theme:d,textSize:m,wideFormat:f,fullScreen:w,showMiniToc:g,onChangeFullScreen:p}=l,S=!w&&Boolean(c),v={headerHeight:S?64:0,data:t,router:n,lang:r,wideFormat:f,showMiniToc:g,theme:d,textSize:m,fullScreen:w,onChangeFullScreen:p};if((0,o.useEffect)((()=>{!function({theme:e,mobileView:t=!1,wideFormat:n=!1,fullHeader:o=!1}){document.body.className=["g-root",t?"mobile":"desktop",n&&"dc-root_wide-format",o&&"dc-root_full-header","light"===e&&"g-root_theme_light","dark"===e&&"g-root_theme_dark"].filter(Boolean).join(" ")}({theme:d,mobileView:s,wideFormat:f,fullHeader:S})}),[d,s,f,S]),!c)return o.createElement("div",{className:"App"},o.createElement(F,Object.assign({},v,l)),o.createElement(M,{theme:d}));const{header:E={},logo:C}=c,{leftItems:T=[],rightItems:x=[]}=E,O=x.some((e=>"controls"===e.type));return o.createElement("div",{className:"App"},o.createElement(i.W,{theme:d},o.createElement(a.C,{custom:{navigation:{controls:()=>o.createElement(u,Object.assign({},l,{mobileView:s}))},blocks:{page:()=>o.createElement(F,Object.assign({},v,O?{}:l))}},content:{blocks:[{type:"page"}]},navigation:S?{header:{withBorder:!0,leftItems:T.map(_),rightItems:x.map(_)},logo:C}:void 0})),o.createElement(M,{theme:d}))}const O=document.getElementById("root"),z=window.__DATA__;if(!O)throw new Error("Root element not found!");window.STATIC_CONTENT?(0,r.a)(O,o.createElement(x,z)):(0,r.s)(O).render(o.createElement(x,z))},9380:()=>{"undefined"!=typeof Element&&function(e){const t=e.matches||e.matchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector||e.msMatchesSelector||e.oMatchesSelector;e.matches=e.matchesSelector=t||function(e){const t=this;return Array.prototype.some.call(document.querySelectorAll(e),(e=>e===t))}}(Element.prototype),"undefined"!=typeof document&&document.addEventListener("click",(e=>{const t=e.target.href,n=window.location.origin;if(e.target.matches(".dc-doc-layout__center a")&&t.startsWith(n)){e.preventDefault();const n="index",o=".html";if(t.endsWith("/"))return void(window.location.href=`${t}${n}${o}`);const r=t.split("#");if(r.length>0&&!r[0].endsWith(o))return r[0]+=o,void(window.location.href=r.join("#"));window.location.href=t}}))},3615:(e,t,n)=>{"use strict";function o(){}n.d(t,{Z:()=>o})},4654:()=>{}},n={};function o(e){var r=n[e];if(void 0!==r)return r.exports;var i=n[e]={id:e,loaded:!1,exports:{}};return t[e].call(i.exports,i,i.exports,o),i.loaded=!0,i.exports}o.m=t,o.amdO={},e=[],o.O=(t,n,r,i)=>{if(!n){var a=1/0;for(d=0;d<e.length;d++){for(var[n,r,i]=e[d],c=!0,l=0;l<n.length;l++)(!1&i||a>=i)&&Object.keys(o.O).every((e=>o.O[e](n[l])))?n.splice(l--,1):(c=!1,i<a&&(a=i));if(c){e.splice(d--,1);var s=r();void 0!==s&&(t=s)}}return t}i=i||0;for(var d=e.length;d>0&&e[d-1][2]>i;d--)e[d]=e[d-1];e[d]=[n,r,i]},o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{var e={143:0};o.O.j=t=>0===e[t];var t=(t,n)=>{var r,i,[a,c,l]=n,s=0;if(a.some((t=>0!==e[t]))){for(r in c)o.o(c,r)&&(o.m[r]=c[r]);if(l)var d=l(o)}for(t&&t(n);s<a.length;s++)i=a[s],o.o(e,i)&&e[i]&&e[i][0](),e[i]=0;return o.O(d)},n=self.webpackChunk_diplodoc_client=self.webpackChunk_diplodoc_client||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))})();var r=o.O(void 0,[514,736],(()=>o(3616)));r=o.O(r)})();
2
2
  //# sourceMappingURL=app.js.map
package/build/index.js CHANGED
@@ -510,13 +510,15 @@ function preprocessPageHtmlForSinglePage(content, options) {
510
510
  // src/utils/markup.ts
511
511
  var import_ssr = require("@diplodoc/client/ssr");
512
512
  var import_manifest = __toESM(require("@diplodoc/client/manifest"));
513
+ var import_html_escaper = require("html-escaper");
513
514
  var dst = (bundlePath) => (target) => (0, import_path4.join)(bundlePath, target);
515
+ var \u0441arriage = import_process.platform === "win32" /* WINDOWS */ ? "\r\n" : "\n";
514
516
  function generateStaticMarkup(props, pathToBundle) {
515
- const { title: metaTitle, style, script } = props.data.meta || {};
517
+ const _a = props.data.meta || {}, { style, script, metadata } = _a, restYamlConfigMeta = __objRest(_a, ["style", "script", "metadata"]);
516
518
  const { title: tocTitle } = props.data.toc;
517
519
  const { title: pageTitle } = props.data;
518
520
  const title = getTitle({
519
- metaTitle,
521
+ metaTitle: props.data.meta.title,
520
522
  tocTitle,
521
523
  pageTitle
522
524
  });
@@ -528,7 +530,7 @@ function generateStaticMarkup(props, pathToBundle) {
528
530
  <html lang="${props.lang}">
529
531
  <head>
530
532
  <meta charset="utf-8">
531
- ${getMetadata(props.data.meta)}
533
+ ${getMetadata(metadata, restYamlConfigMeta)}
532
534
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
533
535
  <title>${title}</title>
534
536
  <style type="text/css">
@@ -563,16 +565,25 @@ function getTitle({ tocTitle, metaTitle, pageTitle }) {
563
565
  }
564
566
  return resultPageTitle && tocTitle ? `${resultPageTitle} | ${tocTitle}` : "";
565
567
  }
566
- function getMetadata(metadata) {
567
- if (!metadata) {
568
- return "";
568
+ function getMetadata(metadata, restMeta) {
569
+ let result = "";
570
+ const addMetaTagsFromObject = (value) => {
571
+ const args = Object.entries(value).reduce((acc, [name4, content]) => {
572
+ return acc + `${(0, import_html_escaper.escape)(name4)}="${(0, import_html_escaper.escape)(content.toString())}" `;
573
+ }, "");
574
+ if (args.length) {
575
+ result += `<meta ${args} />` + \u0441arriage;
576
+ }
577
+ };
578
+ if (metadata) {
579
+ metadata.forEach(addMetaTagsFromObject);
569
580
  }
570
- const metaEntries = Object.entries(metadata).filter(
571
- ([key]) => !Object.keys(ResourceType).includes(key)
572
- );
573
- return metaEntries.map(([name4, content]) => {
574
- return `<meta name="${name4}" content="${content}">`;
575
- }).join("\n");
581
+ if (restMeta) {
582
+ Object.entries(restMeta).map(([name4, value]) => {
583
+ return { name: name4, content: value };
584
+ }).forEach(addMetaTagsFromObject);
585
+ }
586
+ return result;
576
587
  }
577
588
  function getResources({ style, script }) {
578
589
  const resourcesTags = [];
@@ -588,7 +599,6 @@ function getResources({ style, script }) {
588
599
  }
589
600
  return resourcesTags.join("\n");
590
601
  }
591
- var \u0441arriage = import_process.platform === "win32" /* WINDOWS */ ? "\r\n" : "\n";
592
602
  function joinSinglePageResults(singlePageResults2, root, tocDir) {
593
603
  const delimeter = `<hr class="yfm-page__delimeter">`;
594
604
  return singlePageResults2.filter(({ content }) => content).map(
@@ -786,7 +796,8 @@ function transformTocForSinglePage(toc, options) {
786
796
  var import_path7 = require("path");
787
797
  function getVarsPerFile(filePath) {
788
798
  const { vars: argVars } = argv_default.getConfig();
789
- return __spreadValues(__spreadValues({}, preset_default.get((0, import_path7.dirname)(filePath))), argVars);
799
+ const result = __spreadValues(__spreadValues({}, preset_default.get((0, import_path7.dirname)(filePath))), argVars);
800
+ return result;
790
801
  }
791
802
  function getVarsPerRelativeFile(filePath) {
792
803
  const { input } = argv_default.getConfig();
@@ -985,7 +996,7 @@ function getFileIncludes(fileData) {
985
996
 
986
997
  // src/services/metadata.ts
987
998
  var import_path10 = require("path");
988
- function getContentWithUpdatedMetadata(fileContent, options, systemVars) {
999
+ function getContentWithUpdatedMetadata(fileContent, options, systemVars, metadataVars) {
989
1000
  return __async(this, null, function* () {
990
1001
  var _a;
991
1002
  let result;
@@ -995,7 +1006,8 @@ function getContentWithUpdatedMetadata(fileContent, options, systemVars) {
995
1006
  addSystemMeta: options == null ? void 0 : options.addSystemMeta,
996
1007
  addSourcePath: options == null ? void 0 : options.addSourcePath,
997
1008
  resources: options == null ? void 0 : options.resources,
998
- systemVars
1009
+ systemVars,
1010
+ metadataVars
999
1011
  });
1000
1012
  result = yield getContentWithUpdatedDynamicMetadata(result, options);
1001
1013
  return result;
@@ -1007,10 +1019,11 @@ function getContentWithUpdatedStaticMetadata({
1007
1019
  addSystemMeta,
1008
1020
  addSourcePath,
1009
1021
  resources,
1010
- systemVars
1022
+ systemVars,
1023
+ metadataVars = []
1011
1024
  }) {
1012
1025
  const newMetadatas = [];
1013
- if ((!addSystemMeta || !systemVars) && !addSourcePath && !resources) {
1026
+ if ((!addSystemMeta || !systemVars) && !addSourcePath && !resources && metadataVars.length === 0) {
1014
1027
  return fileContent;
1015
1028
  }
1016
1029
  const matches = matchMetadata(fileContent);
@@ -1026,7 +1039,19 @@ function getContentWithUpdatedStaticMetadata({
1026
1039
  }
1027
1040
  if (matches && matches.length > 0) {
1028
1041
  const [, fileMetadata, , fileMainContent] = matches;
1029
- return `${getUpdatedMetadataString(newMetadatas, fileMetadata)}${fileMainContent}`;
1042
+ if (!metadataVars.length) {
1043
+ return `${getUpdatedMetadataString(newMetadatas, fileMetadata)}${fileMainContent}`;
1044
+ }
1045
+ const parsed = (0, import_js_yaml2.load)(fileMetadata);
1046
+ if (!Array.isArray(parsed.metadata)) {
1047
+ parsed.metadata = [parsed.metadata];
1048
+ }
1049
+ parsed.metadata = parsed.metadata.concat(metadataVars);
1050
+ const patchedMetada = (0, import_js_yaml2.dump)(parsed);
1051
+ return `${getUpdatedMetadataString(newMetadatas, patchedMetada)}${fileMainContent}`;
1052
+ }
1053
+ if (metadataVars.length) {
1054
+ newMetadatas.push((0, import_js_yaml2.dump)({ metadata: metadataVars }));
1030
1055
  }
1031
1056
  return `${getUpdatedMetadataString(newMetadatas)}${fileContent}`;
1032
1057
  }
@@ -1140,7 +1165,7 @@ function getUpdatedMetadataString(newMetadatas, defaultMetadata = "") {
1140
1165
  const updatedMetadata = `${preparedDefaultMetadata}${defaultMetadata\u0421arriage}${newMetadata}`;
1141
1166
  return `${metadataBorder}${\u0441arriage}${updatedMetadata}${metadataBorder}${defaultMetadata.length ? "" : \u0441arriage}`;
1142
1167
  }
1143
- function getUpdatedMetadata(options, fileContent, meta2) {
1168
+ function getVCSMetadata(options, fileContent, meta2) {
1144
1169
  return __async(this, null, function* () {
1145
1170
  const { vcsConnector } = options;
1146
1171
  const newMetadata = {
@@ -1775,7 +1800,9 @@ var tocs_default = {
1775
1800
  var import_path15 = require("path");
1776
1801
  var presetStorage = /* @__PURE__ */ new Map();
1777
1802
  function add2(parsedPreset, path, varsPreset) {
1778
- const combinedValues = __spreadValues(__spreadValues({}, parsedPreset.default || {}), parsedPreset[varsPreset] || {});
1803
+ const combinedValues = __spreadProps(__spreadValues(__spreadValues({}, parsedPreset.default || {}), parsedPreset[varsPreset] || {}), {
1804
+ __metadata: parsedPreset.__metadata
1805
+ });
1779
1806
  const key = (0, import_path15.dirname)((0, import_path15.normalize)(path));
1780
1807
  presetStorage.set(key, combinedValues);
1781
1808
  }
@@ -2046,7 +2073,8 @@ function resolveMd2Md(options) {
2046
2073
  const content = yield getContentWithUpdatedMetadata(
2047
2074
  (0, import_fs6.readFileSync)(resolvedInputPath, "utf8"),
2048
2075
  metadata,
2049
- vars.__system
2076
+ vars.__system,
2077
+ vars.__metadata
2050
2078
  );
2051
2079
  const { result, changelogs } = transformMd2Md(content, {
2052
2080
  path: resolvedInputPath,
@@ -2176,13 +2204,19 @@ function resolveMd2HTML(options) {
2176
2204
  const tocBase = toc && toc.base ? toc.base : "";
2177
2205
  const pathToFileDir = pathToDir === tocBase ? "" : pathToDir.replace(`${tocBase}${import_path20.sep}`, "");
2178
2206
  const relativePathToIndex = (0, import_path20.relative)(pathToDir, `${tocBase}${import_path20.sep}`);
2207
+ const vars = getVarsPerFile(inputPath);
2179
2208
  const { input, lang, allowCustomResources } = argv_default.getConfig();
2180
2209
  const resolvedPath = (0, import_path20.resolve)(input, inputPath);
2181
2210
  const content = (0, import_fs7.readFileSync)(resolvedPath, "utf8");
2182
2211
  const transformFn = FileTransformer[fileExtension];
2183
2212
  const { result } = transformFn(content, { path: inputPath });
2184
- const updatedMetadata = metadata && metadata.isContributorsEnabled ? yield getUpdatedMetadata(metadata, content, result == null ? void 0 : result.meta) : result.meta;
2213
+ const updatedMetadata = (metadata == null ? void 0 : metadata.isContributorsEnabled) ? yield getVCSMetadata(metadata, content, result == null ? void 0 : result.meta) : result.meta;
2185
2214
  const fileMeta = fileExtension === ".yaml" ? (_a = result.data.meta) != null ? _a : {} : updatedMetadata;
2215
+ if (Array.isArray(fileMeta == null ? void 0 : fileMeta.metadata)) {
2216
+ fileMeta.metadata.push(...vars.__metadata || []);
2217
+ } else {
2218
+ fileMeta.metadata = vars.__metadata || [];
2219
+ }
2186
2220
  if (allowCustomResources) {
2187
2221
  const { script, style } = (metadata == null ? void 0 : metadata.resources) || {};
2188
2222
  fileMeta.style = (fileMeta.style || []).concat(style || []).map(fixRelativePath(inputPath));
@@ -3413,6 +3447,11 @@ function builder(argv) {
3413
3447
  describe: "Include static content in the page",
3414
3448
  type: "boolean",
3415
3449
  group: "Build options:"
3450
+ }).option("need-to-sanitize-html", {
3451
+ default: true,
3452
+ describe: "Enable sanitize html",
3453
+ type: "boolean",
3454
+ group: "Build options:"
3416
3455
  }).check(argvValidator).example("yfm -i ./input -o ./output", "").demandOption(
3417
3456
  ["input", "output"],
3418
3457
  "Please provide input and output arguments to work with this tool"
@@ -4208,7 +4247,7 @@ import_yargs.default.command(build).command(publish).command(xliff).command(tran
4208
4247
  default: false,
4209
4248
  describe: "Run in quiet mode. Don't write logs to stdout",
4210
4249
  type: "boolean"
4211
- }).group(["config", "strict", "quiet", "help", "version"], "Common options:").version(true ? "4.11.0" : "").help().parse((0, import_helpers.hideBin)(process.argv), {}, (err, { strict }, output) => {
4250
+ }).group(["config", "strict", "quiet", "help", "version"], "Common options:").version(true ? "4.12.1" : "").help().parse((0, import_helpers.hideBin)(process.argv), {}, (err, { strict }, output) => {
4212
4251
  console.timeEnd(MAIN_TIMER_ID);
4213
4252
  if (err) {
4214
4253
  console.error(err);