Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(highlight): respect highlight option #1372

Merged
merged 1 commit into from
Jul 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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