Skip to content

Commit

Permalink
fix(cli): 修复windows template highlight 编译异常
Browse files Browse the repository at this point in the history
affects: @varlet/cli, @varlet/ui
  • Loading branch information
齐皓 authored and 齐皓 committed Feb 23, 2021
1 parent 4988626 commit babb72d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/varlet-cli/src/compiler/compileTemplateHighlight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,10 @@ export function compileMD(
if (!path.endsWith(HL_MD)) {
return
}

const md = readFileSync(path, 'utf-8')

const [_, componentName] = path.match(HL_COMPONENT_NAME_RE)!
const componentName = path.match(HL_COMPONENT_NAME_RE)![2]

const attributesTable = parseTable(compileTable(md, HL_TITLE_ATTRIBUTES_RE))
const eventsTable = parseTable(compileTable(md, HL_TITLE_EVENTS_RE))
Expand Down
2 changes: 1 addition & 1 deletion packages/varlet-cli/src/shared/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const SITE_CONFIG = resolve(__dirname, '../../site/site.config.json')
export const SITE_OUTPUT_PATH = resolve(CWD, 'site')

// template highlight
export const HL_COMPONENT_NAME_RE = /.*\/(.+)\/docs\//
export const HL_COMPONENT_NAME_RE = /.*(\/|\\)(.+)(\/|\\)docs(\/|\\)/
export const HL_API_RE = /##\s*API\n+/
export const HL_TITLE_ATTRIBUTES_RE = /###\s*属性\s*\n+/
export const HL_TITLE_EVENTS_RE = /###\s*事件\s*\n+/
Expand Down
3 changes: 3 additions & 0 deletions packages/varlet-ui/highlight/tag.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@
"tabs-items": {
"attributes": []
},
"time-picker": {
"attributes": []
},
"uploader": {
"attributes": []
}
Expand Down
6 changes: 6 additions & 0 deletions packages/varlet-ui/highlight/web-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,12 @@
"events": [],
"slots": []
},
{
"name": "var-time-picker",
"attributes": [],
"events": [],
"slots": []
},
{
"name": "var-uploader",
"attributes": [],
Expand Down

0 comments on commit babb72d

Please sign in to comment.