1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00

Merge pull request #816 from asmsuechan/iss-809

iss #809 normalize text works only in img tag
This commit is contained in:
SuenagaRyota
2017-08-19 09:44:56 +09:00
committed by GitHub
2 changed files with 9 additions and 3 deletions

View File

@@ -291,8 +291,9 @@ export default class MarkdownPreview extends React.Component {
}) })
_.forEach(this.refs.root.contentWindow.document.querySelectorAll('img'), (el) => { _.forEach(this.refs.root.contentWindow.document.querySelectorAll('img'), (el) => {
el.src = markdown.normalizeLinkText(el.src)
if (!/\/:storage/.test(el.src)) return if (!/\/:storage/.test(el.src)) return
el.src = `file:///${path.join(storagePath, 'images', path.basename(el.src))}` el.src = `file:///${markdown.normalizeLinkText(path.join(storagePath, 'images', path.basename(el.src)))}`
}) })
codeBlockTheme = consts.THEMES.some((_theme) => _theme === codeBlockTheme) codeBlockTheme = consts.THEMES.some((_theme) => _theme === codeBlockTheme)

View File

@@ -165,12 +165,17 @@ function strip (input) {
return output return output
} }
function normalizeLinkText (linkText) {
return md.normalizeLinkText(linkText)
}
const markdown = { const markdown = {
render: function markdown (content) { render: function markdown (content) {
if (!_.isString(content)) content = '' if (!_.isString(content)) content = ''
const renderedContent = md.render(content) const renderedContent = md.render(content)
return md.normalizeLinkText(renderedContent) return renderedContent
}, },
strip strip,
normalizeLinkText
} }
export default markdown export default markdown