diff --git a/lib/plugins/tag/include_code.ts b/lib/plugins/tag/include_code.ts index 914f614f39..83a6529776 100644 --- a/lib/plugins/tag/include_code.ts +++ b/lib/plugins/tag/include_code.ts @@ -11,7 +11,10 @@ const rTo = /\s*to:(\d+)/i; * Syntax: * {% include_code [title] [lang:language] path/to/file %} */ - +const escapeBackslash = path => { + // Replace backslashes on Windows + return path.replace(/\\/g, '/'); +}; export = ctx => function includeCodeTag(args) { let codeDir = ctx.config.code_dir; let arg = args.join(' '); @@ -45,7 +48,7 @@ export = ctx => function includeCodeTag(args) { // If the language is not defined, use file extension instead lang = lang || extname(path).substring(1); - const src = join(codeDir, path); + const src = escapeBackslash(join(codeDir, path)); // If the title is not defined, use file name instead const title = match[1] || basename(path); @@ -71,6 +74,5 @@ export = ctx => function includeCodeTag(args) { args: [code, options] }); } - return `
${code}
`; };