Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vuepress/markdown

Package Overview
Dependencies
Maintainers
6
Versions
183
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vuepress/markdown - npm Package Compare versions

Comparing version 2.0.0-beta.50-pre.1 to 2.0.0-rc.0

100

dist/index.d.ts

@@ -18,5 +18,4 @@ import { SfcPluginOptions } from '@mdit-vue/plugin-sfc';

export { titlePlugin } from '@mdit-vue/plugin-title';
import { RuleBlock } from 'markdown-it/lib/parser_block.js';
declare type AnchorPluginOptions = anchorPlugin.AnchorOptions;
type AnchorPluginOptions = anchorPlugin.AnchorOptions;

@@ -34,4 +33,2 @@ interface AssetsPluginOptions {

declare const resolveLink: (link: string, relativePathPrefix: string, env: MarkdownEnv) => string;
interface CodePluginOptions {

@@ -77,68 +74,4 @@ /**

/**
* Language type for syntax highlight
*/
interface HighlightLanguage {
/**
* Name of the language
*
* The name to be used for the class name,
* e.g. `class="language-typescript"`
*/
name: string;
/**
* Extension of the language
*
* The file extension, which will be used for the
* class name, e.g. `class="ext-ts"`
*/
ext: string;
/**
* Aliases that point to this language
*
* Do not conflict with other languages
*/
aliases: string[];
}
declare const languageBash: HighlightLanguage;
declare const languageCsharp: HighlightLanguage;
declare const languageDocker: HighlightLanguage;
declare const languageFsharp: HighlightLanguage;
declare const languageJavascript: HighlightLanguage;
declare const languageKotlin: HighlightLanguage;
declare const languageMarkdown: HighlightLanguage;
declare const languagePython: HighlightLanguage;
declare const languageRuby: HighlightLanguage;
declare const languageRust: HighlightLanguage;
declare const languageStylus: HighlightLanguage;
declare const languageTypescript: HighlightLanguage;
declare const languageYaml: HighlightLanguage;
type EmojiPluginOptions = emojiPlugin.Options;
declare type HighlightLinesRange = [number, number];
/**
* Resolve highlight-lines ranges from token info
*/
declare const resolveHighlightLines: (info: string) => HighlightLinesRange[] | null;
/**
* Check if a line number is in ranges
*/
declare const isHighlightLine: (lineNumber: number, ranges: HighlightLinesRange[]) => boolean;
/**
* Resolve language for highlight from token info
*/
declare const resolveLanguage: (info: string) => HighlightLanguage;
/**
* Resolve the `:line-numbers` / `:no-line-numbers` mark from token info
*/
declare const resolveLineNumbers: (info: string) => boolean | null;
/**
* Resolve the `:v-pre` / `:no-v-pre` mark from token info
*/
declare const resolveVPre: (info: string) => boolean | null;
declare type EmojiPluginOptions = emojiPlugin.Options;
interface ImportCodePluginOptions {

@@ -152,15 +85,2 @@ /**

declare const createImportCodeBlockRule: ({ handleImportPath }: ImportCodePluginOptions) => RuleBlock;
interface ImportCodeTokenMeta {
importPath: string;
lineStart: number;
lineEnd?: number;
}
declare const resolveImportCode: ({ importPath, lineStart, lineEnd }: ImportCodeTokenMeta, { filePath }: MarkdownEnv) => {
importFilePath: string | null;
importCode: string;
};
interface LinksPluginOptions {

@@ -194,12 +114,4 @@ /**

/**
* Resolve relative and absolute paths according to the `base` and `filePathRelative`
*/
declare const resolvePaths: (rawPath: string, base: string, filePathRelative: string | null) => {
absolutePath: string;
relativePath: string;
};
type Markdown = MarkdownIt;
declare type Markdown = MarkdownIt;
interface MarkdownOptions extends MarkdownIt.Options {

@@ -223,3 +135,3 @@ anchor?: false | AnchorPluginOptions;

*/
declare type MarkdownHeader = PageHeader;
type MarkdownHeader = PageHeader;
/**

@@ -271,3 +183,3 @@ * Internal links in markdown file

*/
declare type MarkdownSlugifyFunction = (str: string) => string;
type MarkdownSlugifyFunction = (str: string) => string;

@@ -279,2 +191,2 @@ /**

export { AnchorPluginOptions, AssetsPluginOptions, CodePluginOptions, EmojiPluginOptions, HighlightLanguage, HighlightLinesRange, ImportCodePluginOptions, ImportCodeTokenMeta, LinksPluginOptions, Markdown, MarkdownEnv, MarkdownHeader, MarkdownLink, MarkdownOptions, MarkdownSlugifyFunction, assetsPlugin, codePlugin, createImportCodeBlockRule, createMarkdown, importCodePlugin, isHighlightLine, languageBash, languageCsharp, languageDocker, languageFsharp, languageJavascript, languageKotlin, languageMarkdown, languagePython, languageRuby, languageRust, languageStylus, languageTypescript, languageYaml, linksPlugin, resolveHighlightLines, resolveImportCode, resolveLanguage, resolveLineNumbers, resolveLink, resolvePaths, resolveVPre };
export { AnchorPluginOptions, AssetsPluginOptions, CodePluginOptions, EmojiPluginOptions, ImportCodePluginOptions, LinksPluginOptions, Markdown, MarkdownEnv, MarkdownHeader, MarkdownLink, MarkdownOptions, MarkdownSlugifyFunction, assetsPlugin, codePlugin, createMarkdown, importCodePlugin, linksPlugin };

132

dist/index.js

@@ -26,3 +26,3 @@ var __defProp = Object.defineProperty;

// src/plugins/anchorPlugin.ts
import anchorPlugin from "markdown-it-anchor";
import { default as anchorPlugin } from "markdown-it-anchor";

@@ -32,5 +32,14 @@ // src/plugins/assetsPlugin/resolveLink.ts

import { decode } from "mdurl";
var resolveLink = (link, relativePathPrefix, env) => {
var resolveLink = (link, relativePathPrefix, env, strict = false) => {
if (link.startsWith("data:"))
return link;
let resolvedLink = decode(link);
if (/^\.{1,2}\//.test(link) && env.filePathRelative) {
const isRelativePath = strict ? (
// in strict mode, only link that starts with `./` or `../` is considered as relative path
/^\.{1,2}\//.test(link)
) : (
// in non-strict mode, link that does not start with `/` and does not have protocol is considered as relative path
!link.startsWith("/") && !/[A-z]+:\/\//.test(link)
);
if (isRelativePath && env.filePathRelative) {
resolvedLink = `${relativePathPrefix}/${path.join(

@@ -57,11 +66,12 @@ path.dirname(env.filePathRelative),

tokens[idx].content = tokens[idx].content.replace(
/(<img\b.*?src=")([^"]*)(")/gs,
(_, prefix, src, suffix) => `${prefix}${resolveLink(
/(<img\b.*?src=)(['"])([^\2]*?)\2/gs,
(_, prefix, quote, src) => `${prefix}${quote}${resolveLink(
src.trim(),
relativePathPrefix,
env
)}${suffix}`
env,
true
)}${quote}`
).replace(
/(<img\b.*?srcset=")([^"]*)(")/gs,
(_, prefix, srcset, suffix) => `${prefix}${srcset.split(",").map(
/(<img\b.*?srcset=)(['"])([^\2]*?)\2/gs,
(_, prefix, quote, srcset) => `${prefix}${quote}${srcset.split(",").map(
(item) => item.trim().replace(

@@ -72,6 +82,7 @@ /^([^ ]*?)([ \n].*)?$/,

relativePathPrefix,
env
env,
true
)}${descriptor.replace(/[ \n]+/g, " ").trimEnd()}`
)
).join(", ")}${suffix}`
).join(", ")}${quote}`
);

@@ -242,3 +253,4 @@ return rawHtmlRule(tokens, idx, options, env, self);

const code = options.highlight?.(token.content, language.name, "") || md.utils.escapeHtml(token.content);
let result = code.startsWith("<pre") ? code : `<pre class="${languageClass}"><code>${code}</code></pre>`;
token.attrJoin("class", languageClass);
let result = code.startsWith("<pre") ? code : `<pre${slf.renderAttrs(token)}><code>${code}</code></pre>`;
const useVPre = resolveVPre(info) ?? vPreBlock;

@@ -267,3 +279,3 @@ if (useVPre) {

}
result = `<div class="${languageClass} ext-${language.ext}${useLineNumbers ? " line-numbers-mode" : ""}">${result}</div>`;
result = `<div class="${languageClass}${useLineNumbers ? " line-numbers-mode" : ""}" data-ext="${language.ext}">${result}</div>`;
return result;

@@ -322,3 +334,3 @@ };

// src/plugins/importCodePlugin/resolveImportCode.ts
import { fs, path as path3 } from "@vuepress/utils";
import { colors, fs, logger, path as path3 } from "@vuepress/utils";
var resolveImportCode = ({ importPath, lineStart, lineEnd }, { filePath }) => {

@@ -328,2 +340,5 @@ let importFilePath = importPath;

if (!filePath) {
logger.error(
`Import file ${colors.magenta(importPath)} can not be resolved`
);
return {

@@ -337,2 +352,3 @@ importFilePath: null,

if (!fs.existsSync(importFilePath)) {
logger.error(`Import file ${colors.magenta(importPath)} not found`);
return {

@@ -365,4 +381,4 @@ importFilePath,

if (importFilePath) {
const importedFiles = env.importedFiles || (env.importedFiles = []);
importedFiles.push(importFilePath);
;
(env.importedFiles ??= []).push(importFilePath);
}

@@ -393,2 +409,3 @@ return md.renderer.rules.fence(tokens, idx, options2, env, slf);

relativePath = path4.join(
// file path may contain non-ASCII characters
path4.dirname(encodeURI(filePathRelative)),

@@ -453,4 +470,3 @@ rawPath

hrefAttr[1] = `${normalizedPath}${rawHash}`;
const links = env.links || (env.links = []);
links.push({
(env.links ??= []).push({
raw: hrefLink,

@@ -493,7 +509,5 @@ relative: relativePath,

...markdownItOptions,
// should always enable html option
html: true
});
if (emoji !== false) {
md.use(emojiPlugin, emoji);
}
if (anchor !== false) {

@@ -512,23 +526,14 @@ md.use(anchorPlugin, {

}
if (toc !== false) {
md.use(tocPlugin, {
level: [2, 3],
slugify,
linkTag: "router-link",
...toc
});
if (assets !== false) {
md.use(assetsPlugin, assets);
}
if (headers !== false) {
md.use(headersPlugin, {
level: [2, 3],
slugify,
...headers
});
if (code !== false) {
md.use(codePlugin, code);
}
if (title !== false) {
md.use(titlePlugin);
}
if (component !== false) {
md.use(componentPlugin);
}
if (emoji !== false) {
md.use(emojiPlugin, emoji);
}
if (frontmatter !== false) {

@@ -538,4 +543,3 @@ md.use(frontmatterPlugin, {

grayMatterOptions: {
excerpt: true,
excerpt_separator: "<!-- more -->",
excerpt: false,
...frontmatter?.grayMatterOptions

@@ -545,7 +549,11 @@ }

}
if (assets !== false) {
md.use(assetsPlugin, assets);
if (headers !== false) {
md.use(headersPlugin, {
level: [2, 3],
slugify,
...headers
});
}
if (sfc !== false) {
md.use(sfcPlugin, sfc);
if (importCode !== false) {
md.use(importCodePlugin, importCode);
}

@@ -555,8 +563,16 @@ if (links !== false) {

}
if (code !== false) {
md.use(codePlugin, code);
if (sfc !== false) {
md.use(sfcPlugin, sfc);
}
if (importCode !== false) {
md.use(importCodePlugin, importCode);
if (toc !== false) {
md.use(tocPlugin, {
level: [2, 3],
slugify,
linkTag: "router-link",
...toc
});
}
if (title !== false) {
md.use(titlePlugin);
}
return md;

@@ -569,3 +585,2 @@ };

componentPlugin,
createImportCodeBlockRule,
createMarkdown,

@@ -576,24 +591,3 @@ emojiPlugin,

importCodePlugin,
isHighlightLine,
languageBash,
languageCsharp,
languageDocker,
languageFsharp,
languageJavascript,
languageKotlin,
languageMarkdown,
languagePython,
languageRuby,
languageRust,
languageStylus,
languageTypescript,
languageYaml,
linksPlugin,
resolveHighlightLines,
resolveImportCode,
resolveLanguage,
resolveLineNumbers,
resolveLink,
resolvePaths,
resolveVPre,
sfcPlugin,

@@ -600,0 +594,0 @@ titlePlugin,

{
"name": "@vuepress/markdown",
"version": "2.0.0-beta.50-pre.1",
"version": "2.0.0-rc.0",
"description": "Markdown package of VuePress",

@@ -30,21 +30,21 @@ "keywords": [

"dependencies": {
"@mdit-vue/plugin-component": "^0.9.0",
"@mdit-vue/plugin-frontmatter": "^0.9.1",
"@mdit-vue/plugin-headers": "^0.9.1",
"@mdit-vue/plugin-sfc": "^0.9.1",
"@mdit-vue/plugin-title": "^0.9.1",
"@mdit-vue/plugin-toc": "^0.9.1",
"@mdit-vue/shared": "^0.9.1",
"@mdit-vue/types": "^0.9.0",
"@types/markdown-it": "^12.2.3",
"@types/markdown-it-emoji": "^2.0.2",
"@vuepress/shared": "2.0.0-beta.50-pre.1",
"@vuepress/utils": "2.0.0-beta.50-pre.1",
"markdown-it": "^13.0.1",
"markdown-it-anchor": "^8.6.4",
"@mdit-vue/plugin-component": "^1.0.0",
"@mdit-vue/plugin-frontmatter": "^1.0.0",
"@mdit-vue/plugin-headers": "^1.0.0",
"@mdit-vue/plugin-sfc": "^1.0.0",
"@mdit-vue/plugin-title": "^1.0.0",
"@mdit-vue/plugin-toc": "^1.0.0",
"@mdit-vue/shared": "^1.0.0",
"@mdit-vue/types": "^1.0.0",
"@types/markdown-it": "^13.0.6",
"@types/markdown-it-emoji": "^2.0.4",
"markdown-it": "^13.0.2",
"markdown-it-anchor": "^8.6.7",
"markdown-it-emoji": "^2.0.2",
"mdurl": "^1.0.1"
"mdurl": "^1.0.1",
"@vuepress/shared": "2.0.0-rc.0",
"@vuepress/utils": "2.0.0-rc.0"
},
"devDependencies": {
"@types/mdurl": "^1.0.2"
"@types/mdurl": "^1.0.5"
},

@@ -65,3 +65,3 @@ "publishConfig": {

"sourcemap": false,
"target": "es2020",
"target": "es2022",
"tsconfig": "../tsconfig.dts.json"

@@ -68,0 +68,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc