Skip to content

Commit

Permalink
improve mode handling
Browse files Browse the repository at this point in the history
  • Loading branch information
panoply committed Dec 25, 2022
1 parent 7bf20f6 commit eb7a7ec
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/prettify/src/parser/mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { parse } from '@parser/parse';
import { size, repeatChar } from '@utils/helpers';
import { NIL } from '@utils/chars';
import { keys } from '@utils/native';
import { detect, reference } from '@parser/language';
import { detect, setLexer, setLanguageName, reference } from '@parser/language';

/**
* Parse Input
Expand Down Expand Up @@ -150,6 +150,11 @@ export function execute (prettify: Prettify) {
prettify.options.languageName = 'Plain Text';
prettify.options.lexer = 'markup';

} else if (prettify.options.lexer === 'auto' && prettify.options.language !== 'text') {

prettify.options.lexer = setLexer(prettify.options.language);
prettify.options.languageName = setLanguageName(prettify.options.language);

} else if (prettify.options.language === 'auto' || prettify.options.language === undefined) {

const { lexer, language, languageName } = detect(prettify.source);
Expand Down

0 comments on commit eb7a7ec

Please sign in to comment.