Skip to content

Commit cd7b8cb

Browse files
committed
Fix: Image path error #14
1 parent aeec145 commit cd7b8cb

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## 0.1.7 (2017/xx/xx)
44
* Fix: broken code-blocks [#18](https://github.com/yzane/vscode-markdown-pdf/pull/18)
5+
* Fix: Image path error [#14](https://github.com/yzane/vscode-markdown-pdf/issues/14)
56

67
## 0.1.6 (2017/02/05)
78
* Fix: Relative path error of markdown-pdf.styles [#9](https://github.com/yzane/vscode-markdown-pdf/issues/9)

extension.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -359,14 +359,16 @@ function readFile(filename, encode) {
359359
function convertImgPath(src, filename) {
360360
var href = decodeURIComponent(src);
361361
href = href.replace(/("|')/g, '')
362-
.replace(/\\/g, '/');
362+
.replace(/\\/g, '/')
363+
.replace(/#/g, '%23');
363364
var protocol = url.parse(href).protocol;
364365
if (protocol === 'file:' && href.indexOf('file:///') !==0) {
365366
return href.replace(/^file:\/\//, 'file:///');
366367
} else if (protocol === 'file:') {
367368
return href;
368369
} else if (!protocol || path.isAbsolute(href)) {
369-
href = path.resolve(path.dirname(filename), href).replace(/\\/g, '/');
370+
href = path.resolve(path.dirname(filename), href).replace(/\\/g, '/')
371+
.replace(/#/g, '%23');
370372
if (href.indexOf('//') === 0) {
371373
return 'file:' + href;
372374
} else if (href.indexOf('/') === 0) {

0 commit comments

Comments
 (0)