Skip to content

Commit

Permalink
fix(LaTeX): Match .tex file to LaTeX codec
Browse files Browse the repository at this point in the history
  • Loading branch information
nokome committed Mar 23, 2021
1 parent 2edc99d commit 096fb04
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export const codecList: string[] = [

// Math
'mathml',
'tex',

// Scripts
'dmagic',
Expand Down Expand Up @@ -167,8 +168,14 @@ export async function match(

let codec: Codec | undefined

// Attempt to match extension name to codec
if (extName !== undefined) codec = await getCodec(extName)
// Attempt to match extension name to codec name
// This is a shortcut attempted before iterating over codecs in codecList
if (extName !== undefined) {
// LaTeX files usually have a `tex` extension. Without this
// exception they get prematurely matched to the TeX codec (for math)
const codecName = extName === 'tex' ? 'latex' : extName
codec = await getCodec(codecName)
}
if (codec !== undefined) return codec

// Iterate through codecs searching for a match
Expand Down

0 comments on commit 096fb04

Please sign in to comment.