Skip to content

Commit

Permalink
Do not encode code blocks passed to a custom highlighter
Browse files Browse the repository at this point in the history
  • Loading branch information
tipiirai committed Jan 24, 2024
1 parent befa122 commit 230c9d1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 6 additions & 3 deletions packages/nuemark/src/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,15 @@ const specialChars = {

const replaceSpecialChars = new RegExp(`[${Object.keys(specialChars).join('')}]`, 'g')

function encode(code) {
return code.replace(replaceSpecialChars, c => specialChars[c])
}

export function renderCodeBlock({ name, code, attr }, fn) {
// console.info(name, code, attr, fn)
if (name) attr.class = concat(`syntax-${name}`, attr.class)
const body = join(code).replace(replaceSpecialChars, c => specialChars[c])
const body = join(code)

return elem('pre', attr, fn ? fn(body) : body)
return elem('pre', attr, fn ? fn(body) : encode(body))
}

// export function renderPage()
Expand Down
4 changes: 1 addition & 3 deletions packages/nuemark/src/tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,6 @@ export const tags = {
)
},


/* later
codetabs(data, opts) {
const { content=[] } = data
const types = toArray(data.types) || []
Expand All @@ -164,6 +161,7 @@ export const tags = {
return tags.tabs(data, opts)
},

/* later
grid(data, opts) {
const { attr, content=[], _='a'} = data
const { cols, colspan } = getGridCols(content.length, _)
Expand Down

0 comments on commit 230c9d1

Please sign in to comment.