refactor: extract latex symbol replacement into private method
This commit is contained in:
parent
fc4934af4a
commit
6372dfc41f
1 changed files with 12 additions and 8 deletions
|
|
@ -164,14 +164,7 @@ class LmcRenderer extends Renderer {
|
|||
const parsed = this.parser.parseInline(token.tokens);
|
||||
return wrapAnsi(parsed, this.columns - 12);
|
||||
}
|
||||
return token.text
|
||||
.replaceAll("$\\rightarrow$", "-->")
|
||||
.replaceAll("$\\leftarrow$", "<--")
|
||||
.replaceAll("$\\leftrightarrow$", "<->")
|
||||
.replaceAll("$\\Rightarrow$", "==>")
|
||||
.replaceAll("$\\Leftarrow$", "<==")
|
||||
.replaceAll("$\\Leftrightarrow$", "<=>")
|
||||
.replaceAll("$\\to$", "->");
|
||||
return this.replaceLatex(token.text);
|
||||
}
|
||||
|
||||
override html({ text: _ }: Tokens.HTML | Tokens.Tag) {
|
||||
|
|
@ -181,6 +174,17 @@ class LmcRenderer extends Renderer {
|
|||
override br() {
|
||||
return "\n";
|
||||
}
|
||||
|
||||
private replaceLatex(text: string) {
|
||||
return text
|
||||
.replaceAll("$\\rightarrow$", "-->")
|
||||
.replaceAll("$\\leftarrow$", "<--")
|
||||
.replaceAll("$\\leftrightarrow$", "<->")
|
||||
.replaceAll("$\\Rightarrow$", "==>")
|
||||
.replaceAll("$\\Leftarrow$", "<==")
|
||||
.replaceAll("$\\Leftrightarrow$", "<=>")
|
||||
.replaceAll("$\\to$", "->");
|
||||
}
|
||||
}
|
||||
|
||||
export async function renderMarkdown(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue