@vuepress/markdown
Advanced tools
Comparing version 2.0.0-beta.12 to 2.0.0-beta.13
@@ -6,2 +6,18 @@ # Change Log | ||
# [2.0.0-beta.13](https://github.com/vuepress/vuepress-next/compare/v2.0.0-beta.12...v2.0.0-beta.13) (2021-05-06) | ||
### Bug Fixes | ||
* **markdown:** ensure ending newline in import code ([160df2d](https://github.com/vuepress/vuepress-next/commit/160df2de1567a3b6b3e889b86e6bd7b95a3cc77b)) | ||
### Features | ||
* **markdown:** allow omitting start or end of import code lines range ([21bba5c](https://github.com/vuepress/vuepress-next/commit/21bba5c86bc8e8dec1c86f820e9de27cf15919b2)) | ||
# [2.0.0-beta.12](https://github.com/vuepress/vuepress-next/compare/v2.0.0-beta.11...v2.0.0-beta.12) (2021-04-30) | ||
@@ -8,0 +24,0 @@ |
@@ -10,3 +10,3 @@ "use strict"; | ||
// regexp to match the import syntax | ||
const SYNTAX_RE = /^@\[code(?:{(?:(\d+)-(\d+))})?(?: ([^\]]+))?\]\(([^)]*)\)/; | ||
const SYNTAX_RE = /^@\[code(?:{(?:(\d+)?-(\d+)?)})?(?: ([^\]]+))?\]\(([^)]*)\)/; | ||
const createImportCodeBlockRule = ({ handleImportPath = (str) => str, }) => (state, startLine, endLine, silent) => { | ||
@@ -39,4 +39,4 @@ // if it's indented more than 3 spaces, it should be a code block | ||
importPath: handleImportPath(importPath), | ||
lineStart: Number.parseInt(lineStart || '0', 10), | ||
lineEnd: Number.parseInt(lineEnd || '0', 10), | ||
lineStart: lineStart ? Number.parseInt(lineStart, 10) : 0, | ||
lineEnd: lineEnd ? Number.parseInt(lineEnd, 10) : undefined, | ||
}; | ||
@@ -43,0 +43,0 @@ // create a import_code token |
@@ -27,8 +27,2 @@ "use strict"; | ||
const fileContent = utils_1.fs.readFileSync(importFilePath).toString(); | ||
if (lineStart < 1 || lineEnd < 1 || lineStart > lineEnd) { | ||
return { | ||
importFilePath, | ||
importCode: fileContent, | ||
}; | ||
} | ||
// resolve partial import | ||
@@ -39,6 +33,7 @@ return { | ||
.split('\n') | ||
.slice(lineStart - 1, lineEnd) | ||
.join('\n'), | ||
.slice(lineStart ? lineStart - 1 : lineStart, lineEnd) | ||
.join('\n') | ||
.replace(/\n?$/, '\n'), | ||
}; | ||
}; | ||
exports.resolveImportCode = resolveImportCode; |
export interface ImportCodeTokenMeta { | ||
importPath: string; | ||
lineStart: number; | ||
lineEnd: number; | ||
lineEnd?: number; | ||
} |
{ | ||
"name": "@vuepress/markdown", | ||
"version": "2.0.0-beta.12", | ||
"version": "2.0.0-beta.13", | ||
"description": "Markdown package of VuePress", | ||
@@ -39,3 +39,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "f3fadbc8a730a5985115b8e94f9a634b92354ac3" | ||
"gitHead": "1e20c489ef2d1418d7da5c22847e05c516ba62a2" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
78149
1880