Skip to content

Commit

Permalink
fix(highlight): respect highlight option (#1372)
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz committed Jul 22, 2022
1 parent b832f24 commit 32eec9c
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/runtime/transformers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,16 @@ import markdown from './markdown'
import yaml from './yaml'
import pathMeta from './path-meta'
import json from './json'
import highlight from './shiki'

const TRANSFORMERS = [
csv,
markdown,
json,
yaml,
pathMeta,
highlight
pathMeta
]

function getParser (ext, additionalTransformers: ContentTransformer[] = []): ContentTransformer {
function getParser (ext, additionalTransformers: ContentTransformer[] = []): ContentTransformer | undefined {
let parser = additionalTransformers.find(p => ext.match(new RegExp(p.extensions.join('|'), 'i')) && p.parse)
if (!parser) {
parser = TRANSFORMERS.find(p => ext.match(new RegExp(p.extensions.join('|'), 'i')) && p.parse)
Expand All @@ -42,7 +40,7 @@ export async function transformContent (id, content, options: TransformContentOp
const file = { _id: id, body: content }

const ext = extname(id)
const parser: ContentTransformer = getParser(ext, transformers)
const parser = getParser(ext, transformers)
if (!parser) {
// eslint-disable-next-line no-console
console.warn(`${ext} files are not supported, "${id}" falling back to raw content`)
Expand Down

0 comments on commit 32eec9c

Please sign in to comment.