Skip to content

Commit 8505616

Browse files
daiyamRokt33r
authored andcommitted
fix gallery on windows
1 parent 782d71d commit 8505616

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

browser/lib/markdown.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import markdownit from 'markdown-it'
22
import sanitize from './markdown-it-sanitize-html'
33
import emoji from 'markdown-it-emoji'
44
import math from '@rokt33r/markdown-it-math'
5+
import mdurl from 'mdurl'
56
import smartArrows from 'markdown-it-smartarrows'
67
import _ from 'lodash'
78
import ConfigManager from 'browser/main/lib/ConfigManager'
@@ -150,9 +151,9 @@ class Markdown {
150151
const content = token.content.split('\n').slice(0, -1).map(line => {
151152
const match = /!\[[^\]]*]\(([^\)]*)\)/.exec(line)
152153
if (match) {
153-
return match[1]
154+
return mdurl.encode(match[1])
154155
} else {
155-
return line
156+
return mdurl.encode(line)
156157
}
157158
}).join('\n')
158159

tests/dataApi/attachmentManagement.test.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,11 @@ it('should replace the all ":storage" path with the actual storage path', functi
287287
' </p>\n' +
288288
' <pre class="fence" data-line="8">\n' +
289289
' <span class="filename"></span>\n' +
290-
' <div class="gallery" data-autoplay="undefined" data-height="undefined">:storage' + mdurl.encode(path.sep) + noteKey + mdurl.encode(path.sep) + 'f939b2c3.jpg</div>\n' +
290+
' <div class="gallery" data-autoplay="undefined" data-height="undefined">:storage' + mdurl.encode(path.win32.sep) + noteKey + mdurl.encode(path.win32.sep) + 'f939b2c3.jpg</div>\n' +
291+
' </pre>\n' +
292+
' <pre class="fence" data-line="10">\n' +
293+
' <span class="filename"></span>\n' +
294+
' <div class="gallery" data-autoplay="undefined" data-height="undefined">:storage' + mdurl.encode(path.posix.sep) + noteKey + mdurl.encode(path.posix.sep) + 'f939b2c3.jpg</div>\n' +
291295
' </pre>\n' +
292296
' </body>\n' +
293297
'</html>'
@@ -312,6 +316,10 @@ it('should replace the all ":storage" path with the actual storage path', functi
312316
' <span class="filename"></span>\n' +
313317
' <div class="gallery" data-autoplay="undefined" data-height="undefined">file:///' + storagePath + path.sep + storageFolder + path.sep + noteKey + path.sep + 'f939b2c3.jpg</div>\n' +
314318
' </pre>\n' +
319+
' <pre class="fence" data-line="10">\n' +
320+
' <span class="filename"></span>\n' +
321+
' <div class="gallery" data-autoplay="undefined" data-height="undefined">file:///' + storagePath + path.sep + storageFolder + path.sep + noteKey + path.sep + 'f939b2c3.jpg</div>\n' +
322+
' </pre>\n' +
315323
' </body>\n' +
316324
'</html>'
317325
const actual = systemUnderTest.fixLocalURLS(testInput, storagePath)

0 commit comments

Comments
 (0)