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

Fix to handle when codeBlocks is null

This commit is contained in:
asmsuechan
2017-03-19 21:43:54 -07:00
parent e60a5430b4
commit 10043cc755

View File

@@ -260,7 +260,7 @@ export default class MarkdownPreview extends React.Component {
this.refs.root.contentWindow.document.body.setAttribute('data-theme', theme)
const codeBlocks = value.match(/(```)(.|[\n])*?(```)/g)
if (codeBlocks.length > 0) {
if (codeBlocks !== null && codeBlocks.length > 0) {
codeBlocks.forEach((codeBlock) => {
const encodedCodeBlock = encodeHTMLEntities(codeBlock)
value = value.replace(codeBlock, encodedCodeBlock)