mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 09:46:22 +00:00
fix gallery on windows
This commit is contained in:
committed by
Junyoung Choi
parent
782d71ddb0
commit
850561613b
@@ -2,6 +2,7 @@ import markdownit from 'markdown-it'
|
||||
import sanitize from './markdown-it-sanitize-html'
|
||||
import emoji from 'markdown-it-emoji'
|
||||
import math from '@rokt33r/markdown-it-math'
|
||||
import mdurl from 'mdurl'
|
||||
import smartArrows from 'markdown-it-smartarrows'
|
||||
import _ from 'lodash'
|
||||
import ConfigManager from 'browser/main/lib/ConfigManager'
|
||||
@@ -150,9 +151,9 @@ class Markdown {
|
||||
const content = token.content.split('\n').slice(0, -1).map(line => {
|
||||
const match = /!\[[^\]]*]\(([^\)]*)\)/.exec(line)
|
||||
if (match) {
|
||||
return match[1]
|
||||
return mdurl.encode(match[1])
|
||||
} else {
|
||||
return line
|
||||
return mdurl.encode(line)
|
||||
}
|
||||
}).join('\n')
|
||||
|
||||
|
||||
@@ -287,7 +287,11 @@ it('should replace the all ":storage" path with the actual storage path', functi
|
||||
' </p>\n' +
|
||||
' <pre class="fence" data-line="8">\n' +
|
||||
' <span class="filename"></span>\n' +
|
||||
' <div class="gallery" data-autoplay="undefined" data-height="undefined">:storage' + mdurl.encode(path.sep) + noteKey + mdurl.encode(path.sep) + 'f939b2c3.jpg</div>\n' +
|
||||
' <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' +
|
||||
' </pre>\n' +
|
||||
' <pre class="fence" data-line="10">\n' +
|
||||
' <span class="filename"></span>\n' +
|
||||
' <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' +
|
||||
' </pre>\n' +
|
||||
' </body>\n' +
|
||||
'</html>'
|
||||
@@ -312,6 +316,10 @@ it('should replace the all ":storage" path with the actual storage path', functi
|
||||
' <span class="filename"></span>\n' +
|
||||
' <div class="gallery" data-autoplay="undefined" data-height="undefined">file:///' + storagePath + path.sep + storageFolder + path.sep + noteKey + path.sep + 'f939b2c3.jpg</div>\n' +
|
||||
' </pre>\n' +
|
||||
' <pre class="fence" data-line="10">\n' +
|
||||
' <span class="filename"></span>\n' +
|
||||
' <div class="gallery" data-autoplay="undefined" data-height="undefined">file:///' + storagePath + path.sep + storageFolder + path.sep + noteKey + path.sep + 'f939b2c3.jpg</div>\n' +
|
||||
' </pre>\n' +
|
||||
' </body>\n' +
|
||||
'</html>'
|
||||
const actual = systemUnderTest.fixLocalURLS(testInput, storagePath)
|
||||
|
||||
Reference in New Issue
Block a user