fix(vetur): fix markdown vetur output format

This commit is contained in:
陈嘉涵
2020-01-15 16:05:20 +08:00
parent 17b2f2be71
commit 50252ff553
4 changed files with 37 additions and 24 deletions
+14 -16
View File
@@ -24,6 +24,18 @@ function readLine(input: string) {
return input.substr(0, end !== -1 ? end : input.length);
}
function splitTableLine(line: string) {
line = line.replace('\\|', 'JOIN');
const items = line.split('|').map(item => item.trim().replace('JOIN', '|'));
// remove pipe character on both sides
items.pop();
items.shift();
return items;
}
function tableParse(input: string) {
let start = 0;
let isHead = true;
@@ -44,25 +56,11 @@ function tableParse(input: string) {
if (TABLE_SPLIT_LINE_REG.test(target)) {
isHead = false;
} else if (isHead) {
// temp do nothing
} else {
} else if (!isHead && line.includes('|')) {
const matched = line.trim().match(TD_REG);
if (matched) {
table.body.push(
matched.map(i => {
if (i.indexOf('|') !== 0) {
return i
.trim()
.toLowerCase()
.split('|')
.map(s => s.trim())
.join('|');
}
return i.trim();
})
);
table.body.push(splitTableLine(line));
}
}