trim content by default

This commit is contained in:
2023-11-16 15:43:48 +01:00
parent 7bb8db420f
commit a6c56e536a
6 changed files with 19 additions and 4 deletions

View File

@@ -6,6 +6,7 @@ function defaultOptions() {
return {
matcher: /@import\((?<file>.+)\)(\s*?\[(?<range>\d+-\d+)\])?/g,
root: process.cwd(),
trim: true,
}
}
@@ -40,6 +41,9 @@ export function importPlugin(md: any, options: Options = {}) {
const exists = fs.existsSync(filename)
if (!exists) throw new Error(`cannot locate file "${filename}"`)
let contents = fs.readFileSync(filename, 'utf-8')
if (o.trim) {
contents = contents.trim()
}
// Apply line range
if (range) {