@vuepress/markdown
Advanced tools
Comparing version 2.0.0-beta.41 to 2.0.0-beta.42
@@ -14,3 +14,2 @@ "use strict"; | ||
md.renderer.rules.fence = (tokens, idx, options, env, slf) => { | ||
var _a, _b, _c; | ||
const token = tokens[idx]; | ||
@@ -23,3 +22,3 @@ // get token info | ||
// try to get highlighted code | ||
const code = ((_a = options.highlight) === null || _a === void 0 ? void 0 : _a.call(options, token.content, language.name, '')) || | ||
const code = options.highlight?.(token.content, language.name, '') || | ||
md.utils.escapeHtml(token.content); | ||
@@ -31,3 +30,3 @@ // wrap highlighted code with `<pre>` and `<code>` | ||
// resolve v-pre mark from token info | ||
const useVPre = (_b = (0, resolveVPre_1.resolveVPre)(info)) !== null && _b !== void 0 ? _b : vPre; | ||
const useVPre = (0, resolveVPre_1.resolveVPre)(info) ?? vPre; | ||
if (useVPre) { | ||
@@ -59,5 +58,6 @@ result = `<pre v-pre${result.slice('<pre'.length)}`; | ||
// resolve line-numbers mark from token info | ||
const useLineNumbers = (_c = (0, resolveLineNumbers_1.resolveLineNumbers)(info)) !== null && _c !== void 0 ? _c : (typeof lineNumbers === 'number' | ||
? lines.length >= lineNumbers | ||
: lineNumbers); | ||
const useLineNumbers = (0, resolveLineNumbers_1.resolveLineNumbers)(info) ?? | ||
(typeof lineNumbers === 'number' | ||
? lines.length >= lineNumbers | ||
: lineNumbers); | ||
// generate line numbers | ||
@@ -64,0 +64,0 @@ if (useLineNumbers) { |
@@ -30,8 +30,7 @@ "use strict"; | ||
const resolveLanguage = (info) => { | ||
var _a, _b; | ||
// get user-defined language alias | ||
const alias = ((_a = info.match(/^([^ :[{]+)/)) === null || _a === void 0 ? void 0 : _a[1]) || 'text'; | ||
const alias = info.match(/^([^ :[{]+)/)?.[1] || 'text'; | ||
// if the alias does not have a match in the map | ||
// fallback to the alias itself | ||
return ((_b = getLanguagesMap()[alias]) !== null && _b !== void 0 ? _b : { | ||
return (getLanguagesMap()[alias] ?? { | ||
name: alias, | ||
@@ -38,0 +37,0 @@ ext: alias, |
/** | ||
* Vue reserved tags | ||
* | ||
* @see https://v3.vuejs.org/api/built-in-components.html | ||
* @see https://vuejs.org/api/built-in-components.html | ||
*/ | ||
export declare const vueReservedTags: string[]; |
@@ -7,3 +7,3 @@ "use strict"; | ||
* | ||
* @see https://v3.vuejs.org/api/built-in-components.html | ||
* @see https://vuejs.org/api/built-in-components.html | ||
*/ | ||
@@ -10,0 +10,0 @@ exports.vueReservedTags = [ |
@@ -28,5 +28,4 @@ "use strict"; | ||
md.render = (src, env = {}) => { | ||
var _a, _b; | ||
const result = render(src, env); | ||
env.title = (_b = (_a = env.frontmatter) === null || _a === void 0 ? void 0 : _a.title) !== null && _b !== void 0 ? _b : title; | ||
env.title = env.frontmatter?.title ?? title; | ||
return result; | ||
@@ -33,0 +32,0 @@ }; |
@@ -44,3 +44,3 @@ "use strict"; | ||
// use user specified info, or fallback to file ext | ||
token.info = info !== null && info !== void 0 ? info : utils_1.path.extname(meta.importPath).slice(1); | ||
token.info = info ?? utils_1.path.extname(meta.importPath).slice(1); | ||
token.markup = '```'; | ||
@@ -47,0 +47,0 @@ token.map = [startLine, startLine + 1]; |
@@ -29,6 +29,5 @@ "use strict"; | ||
tokens.forEach((_, idx) => { | ||
var _a; | ||
const token = tokens[idx]; | ||
// if the token type does not match, skip | ||
if ((token === null || token === void 0 ? void 0 : token.type) !== 'heading_open') { | ||
if (token?.type !== 'heading_open') { | ||
return; | ||
@@ -54,3 +53,3 @@ } | ||
// if the id does not exist, slugify the title ourselves | ||
const slug = (_a = token.attrGet('id')) !== null && _a !== void 0 ? _a : slugify(title); | ||
const slug = token.attrGet('id') ?? slugify(title); | ||
// push the header to tree | ||
@@ -57,0 +56,0 @@ push({ |
@@ -11,5 +11,4 @@ "use strict"; | ||
const resolveTitleFromToken = (token, { allowHtml, escapeText, }) => { | ||
var _a; | ||
// children of the token contains the parsed result of the heading title | ||
const children = (_a = token.children) !== null && _a !== void 0 ? _a : []; | ||
const children = token.children ?? []; | ||
// type of tokens to be included in the heading title | ||
@@ -22,8 +21,5 @@ const titleTokenTypes = ['text', 'emoji', 'code_inline']; | ||
// filter the token type to be included in the title | ||
const titleTokens = children.filter((item) => { | ||
var _a; | ||
return titleTokenTypes.includes(item.type) && | ||
// filter permalink symbol that generated by markdown-it-anchor | ||
!((_a = item.meta) === null || _a === void 0 ? void 0 : _a.isPermalinkSymbol); | ||
}); | ||
const titleTokens = children.filter((item) => titleTokenTypes.includes(item.type) && | ||
// filter permalink symbol that generated by markdown-it-anchor | ||
!item.meta?.isPermalinkSymbol); | ||
// get title from tokens | ||
@@ -30,0 +26,0 @@ return titleTokens |
{ | ||
"name": "@vuepress/markdown", | ||
"version": "2.0.0-beta.41", | ||
"version": "2.0.0-beta.42", | ||
"description": "Markdown package of VuePress", | ||
@@ -26,4 +26,4 @@ "keywords": [ | ||
"@types/markdown-it": "^12.2.3", | ||
"@vuepress/shared": "2.0.0-beta.41", | ||
"@vuepress/utils": "2.0.0-beta.41", | ||
"@vuepress/shared": "2.0.0-beta.42", | ||
"@vuepress/utils": "2.0.0-beta.42", | ||
"markdown-it": "^13.0.0", | ||
@@ -30,0 +30,0 @@ "markdown-it-anchor": "^8.4.1", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20
72004
1949
+ Added@vuepress/shared@2.0.0-beta.42(transitive)
+ Added@vuepress/utils@2.0.0-beta.42(transitive)
- Removed@vuepress/shared@2.0.0-beta.41(transitive)
- Removed@vuepress/utils@2.0.0-beta.41(transitive)