Skip to content

Commit

Permalink
fix: windos escapeBackslash
Browse files Browse the repository at this point in the history
  • Loading branch information
uiolee committed Sep 12, 2023
1 parent f36a035 commit 4920484
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/plugins/tag/include_code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(' ');
Expand Down Expand Up @@ -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);
Expand All @@ -71,6 +74,5 @@ export = ctx => function includeCodeTag(args) {
args: [code, options]
});
}

return `<pre><code>${code}</code></pre>`;
};

0 comments on commit 4920484

Please sign in to comment.