Skip to content

Commit

Permalink
Re-sructure If Block
Browse files Browse the repository at this point in the history
  • Loading branch information
guneskaan authored and Rokt33r committed Dec 14, 2020
1 parent cf010b9 commit 4dd6ab1
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions src/components/atoms/MarkdownPreviewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,25 +98,27 @@ function rehypeCodeMirrorAttacher(options: Partial<RehypeCodeMirrorOptions>) {
const cmResult = [] as Node[]
if (lang != null) {
const mime = getMime(lang)
if (mime != null) {
CodeMirror.runMode(rawContent, mime, (text, style) => {
cmResult.push(
h(
'span',
{
className: style
? 'cm-' + style.replace(/ +/g, ' cm-')
: undefined,
},
text
)
)
})
} else if (!ignoreMissing) {
if (mime == null) {
if (ignoreMissing){
return
}

throw new Error(`Unknown language: \`${lang}\` is not registered`)
} else {
return;
}

CodeMirror.runMode(rawContent, mime, (text, style) => {
cmResult.push(
h(
'span',
{
className: style
? 'cm-' + style.replace(/ +/g, ' cm-')
: undefined,
},
text
)
)
})
}

node.children = cmResult
Expand Down

0 comments on commit 4dd6ab1

Please sign in to comment.