mirror of
https://github.com/ytliu74/obsidian-pseudocode.git
synced 2026-07-22 07:40:25 +00:00
refactor: Use template literals
This commit is contained in:
parent
ffb1a15cb9
commit
ae392a2fdd
1 changed files with 6 additions and 3 deletions
9
main.ts
9
main.ts
|
|
@ -32,11 +32,14 @@ export default class PseudocodePlugin extends Plugin {
|
|||
// find all $ enclosements in source, and add the preamble.
|
||||
// TODO: Might be able to optimize.
|
||||
const mathRegex = /\$(.*?)\$/g;
|
||||
const withPreamble = source.replace(mathRegex, (match, group1) => {
|
||||
return "$" + this.preamble + group1 + "$";
|
||||
const withPreamble = source.replace(mathRegex, (_, group1) => {
|
||||
return `$${this.preamble}${group1}$`;
|
||||
});
|
||||
|
||||
const preEl = blockDiv.createEl("pre", { cls: "code", text: withPreamble });
|
||||
const preEl = blockDiv.createEl("pre", {
|
||||
cls: "code",
|
||||
text: withPreamble,
|
||||
});
|
||||
|
||||
try {
|
||||
pseudocode.renderElement(preEl, this.settings.jsSettings);
|
||||
|
|
|
|||
Loading…
Reference in a new issue