Skip to content

Commit

Permalink
fix($markdown): remove region comment when importing snippets
Browse files Browse the repository at this point in the history
permit nesting regions for partial code snippets import
  • Loading branch information
nlm-pro committed Mar 23, 2020
1 parent 563c093 commit da909e8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/@vuepress/markdown/lib/snippet.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function findRegion (lines, regionName) {
}
}
} else if (testLine(line, regexp, regionName, true)) {
return { start, end: lineId }
return { start, end: lineId, regexp }
}
}

Expand Down Expand Up @@ -90,7 +90,10 @@ module.exports = function snippet (md, options = {}) {

if (region) {
content = dedent(
lines.slice(region.start, region.end).join('\n')
lines
.slice(region.start, region.end)
.filter(line => !region.regexp.test(line.trim()))
.join('\n')
)
}
}
Expand Down

0 comments on commit da909e8

Please sign in to comment.