From 096fb043bbd4c9e15310516ab681fb6270bf1687 Mon Sep 17 00:00:00 2001 From: Nokome Bentley Date: Wed, 24 Mar 2021 12:33:21 +1300 Subject: [PATCH] fix(LaTeX): Match .tex file to LaTeX codec --- src/index.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 4fe9e2cf4..6980164d4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -71,6 +71,7 @@ export const codecList: string[] = [ // Math 'mathml', + 'tex', // Scripts 'dmagic', @@ -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