Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@vant/markdown-vetur

Package Overview
Dependencies
Maintainers
5
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vant/markdown-vetur - npm Package Compare versions

Comparing version
2.2.0
to
2.3.0
+47
-7
lib/formatter.js

@@ -6,4 +6,43 @@ "use strict";

function formatComponentName(name, tagPrefix) {
return tagPrefix + utils_1.toKebabCase(name);
return tagPrefix + (0, utils_1.toKebabCase)(name);
}
/**
* format arugments of events
* input = value: { foo: foo or 1, bar: bar or 2 }, value2: { one: 1 and 1, two: 2 and 2 }, foo: bar
* output = [{ name: 'value', type: '{ foo: foo or 1, bar: bar or 2 }' }, { name: 'value2', type: '{ one: 1 and 1, two: 2 and 2 }'}, { name: 'foo', type: 'bar' }]
*/
function formatArguments(input) {
if (input === '-')
return [];
const args = [];
const items = [];
input = (0, utils_1.formatType)(input);
while (input.length > 0) {
if (/(?!_)\w/.test(input[0])) {
const val = input.match(/(\w|\s|\p{P}|\||\[|\]|>|<)+/)[0] || '';
input = input.substring(val.length);
items.push(val);
}
else if (input[0] === '{') {
const val = input.match(/\{[^}]+\}/)[0] || '';
input = input.substring(val.length);
items.push(val);
}
else if ([':', ',', '_', ' '].includes(input[0])) {
input = input.substring(1);
}
else {
const val = input.match(/( |'|\||\w)+/)[0] || '';
input = input.substring(val.length);
items.push(val);
}
}
for (let i = 0; i < items.length; i += 2) {
args.push({
name: items[i],
type: items[i + 1],
});
}
return args;
}
function getNameFromTableTitle(tableTitle, tagPrefix) {

@@ -52,8 +91,8 @@ tableTitle = tableTitle.trim();

tag.attributes.push({
name: utils_1.removeVersion(name),
name: (0, utils_1.removeVersion)(name),
default: defaultVal,
description: desc,
options: utils_1.formatOptions(options),
options: (0, utils_1.formatOptions)(options),
value: {
type: utils_1.formatType(type),
type: (0, utils_1.formatType)(type),
kind: 'expression',

@@ -69,6 +108,7 @@ },

table.body.forEach((line) => {
const [name, desc] = line;
const [name, desc, args] = line;
tag.events.push({
name: utils_1.removeVersion(name),
name: (0, utils_1.removeVersion)(name),
description: desc,
arguments: formatArguments(args),
});

@@ -84,3 +124,3 @@ });

tag.slots.push({
name: utils_1.removeVersion(name),
name: (0, utils_1.removeVersion)(name),
description: desc,

@@ -87,0 +127,0 @@ });

+10
-10

@@ -16,6 +16,6 @@ "use strict";

async function readMarkdown(options) {
const mds = await fast_glob_1.default(utils_1.normalizePath(`${options.path}/**/*.md`));
const mds = await (0, fast_glob_1.default)((0, utils_1.normalizePath)(`${options.path}/**/*.md`));
return mds
.filter((md) => options.test.test(md))
.map((path) => fs_extra_1.readFileSync(path, 'utf-8'));
.map((path) => (0, fs_extra_1.readFileSync)(path, 'utf-8'));
}

@@ -29,13 +29,13 @@ async function parseAndWrite(options) {

mds.forEach((md) => {
const parsedMd = parser_1.mdParser(md);
formatter_1.formatter(vueTags, parsedMd, options.tagPrefix);
const parsedMd = (0, parser_1.mdParser)(md);
(0, formatter_1.formatter)(vueTags, parsedMd, options.tagPrefix);
});
const webTypes = web_types_1.genWebTypes(vueTags, options);
const veturTags = vetur_1.genVeturTags(vueTags);
const veturAttributes = vetur_1.genVeturAttributes(vueTags);
fs_extra_1.outputFileSync(path_1.join(options.outputDir, 'tags.json'), JSON.stringify(veturTags, null, 2));
fs_extra_1.outputFileSync(path_1.join(options.outputDir, 'attributes.json'), JSON.stringify(veturAttributes, null, 2));
fs_extra_1.outputFileSync(path_1.join(options.outputDir, 'web-types.json'), JSON.stringify(webTypes, null, 2));
const webTypes = (0, web_types_1.genWebTypes)(vueTags, options);
const veturTags = (0, vetur_1.genVeturTags)(vueTags);
const veturAttributes = (0, vetur_1.genVeturAttributes)(vueTags);
(0, fs_extra_1.outputFileSync)((0, path_1.join)(options.outputDir, 'tags.json'), JSON.stringify(veturTags, null, 2));
(0, fs_extra_1.outputFileSync)((0, path_1.join)(options.outputDir, 'attributes.json'), JSON.stringify(veturAttributes, null, 2));
(0, fs_extra_1.outputFileSync)((0, path_1.join)(options.outputDir, 'web-types.json'), JSON.stringify(webTypes, null, 2));
}
exports.parseAndWrite = parseAndWrite;
exports.default = { parseAndWrite };

@@ -14,4 +14,6 @@ "use strict";

function splitTableLine(line) {
line = line.replace('\\|', 'JOIN');
const items = line.split('|').map((item) => item.trim().replace('JOIN', '|'));
line = line.replace(/\\\|/g, 'JOIN');
const items = line
.split('|')
.map((item) => item.trim().replace(/JOIN/g, '|'));
// remove pipe character on both sides

@@ -18,0 +20,0 @@ items.pop();

@@ -24,3 +24,3 @@ "use strict";

exports.normalizePath = normalizePath;
// `default` `primary` -> ['default', 'primary']
// `default` `primary` -> ['default', 'primary']
function formatOptions(options) {

@@ -27,0 +27,0 @@ if (!options)

@@ -1,3 +0,3 @@

import { VueTag, VeturAttribute } from './type';
export declare function genVeturTags(tags: VueTag[]): Record<string, import("./type").VeturTag>;
export declare function genVeturAttributes(tags: VueTag[]): Record<string, VeturAttribute>;
import { VueTag, VeturTags, VeturAttributes } from './type';
export declare function genVeturTags(tags: VueTag[]): VeturTags;
export declare function genVeturAttributes(tags: VueTag[]): VeturAttributes;

@@ -6,5 +6,5 @@ "use strict";

const veturTags = {};
tags.forEach(tag => {
tags.forEach((tag) => {
veturTags[tag.name] = {
attributes: tag.attributes ? tag.attributes.map(item => item.name) : [],
attributes: tag.attributes ? tag.attributes.map((item) => item.name) : [],
};

@@ -17,8 +17,8 @@ });

const veturAttributes = {};
tags.forEach(tag => {
tags.forEach((tag) => {
if (tag.attributes) {
tag.attributes.forEach(attr => {
let attribute = {
tag.attributes.forEach((attr) => {
const attribute = {
type: attr.value.type,
description: `${attr.description}, 默认值: ${attr.default}`
description: `${attr.description}, Default: ${attr.default}`,
};

@@ -25,0 +25,0 @@ if (attr.options.length > 0) {

{
"name": "@vant/markdown-vetur",
"version": "2.2.0",
"version": "2.3.0",
"description": "simple parse markdown to vue component description for vetur auto-completion",
"main": "lib/index.js",
"license": "MIT",
"repository": "https://github.com/youzan/vant/tree/dev/packages/vant-markdown-vetur",
"author": "zhangshuai",
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
},
"files": [

@@ -18,12 +11,25 @@ "lib"

"dev": "tsc --watch",
"build": "tsc",
"release": "npm run build && npm publish"
"build": "rimraf ./lib && tsc",
"release": "pnpm build && npm publish",
"prepare": "pnpm build"
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
},
"repository": {
"type": "git",
"url": "https://github.com/youzan/vant.git",
"directory": "packages/vant-markdown-vetur"
},
"bugs": "https://github.com/youzan/vant/issues",
"author": "zhangshuai",
"license": "MIT",
"dependencies": {
"fast-glob": "^3.2.2",
"fs-extra": "^9.0.0"
"fs-extra": "^10.0.0"
},
"devDependencies": {
"@types/fs-extra": "^8.1.0"
"@types/fs-extra": "^9.0.13"
}
}

@@ -7,12 +7,11 @@ # Vant Markdown Vetur

#### NPM
```shell
# with npm
npm i @vant/markdown-vetur -D
```
#### YARN
# with yarn
yarn add @vant/markdown-vetur -D
```shell
yarn add @vant/markdown-vetur --dev
# with pnpm
pnpm add @vant/markdown-vetur -D
```

@@ -19,0 +18,0 @@