keroosha.cybergulag.today/quartz/plugins/transformers
Hrishikesh Barman 2f99339dcf
feat: add transformations for latex in oxhugofm (#510)
ox-hugo currently supports the following syntax for latex equations:
- https://orgmode.org/manual/LaTeX-fragments.html
- https://ox-hugo.scripter.co/doc/equations

This syntax is supported by mathjax as is mentioned in the ox-hugo documentation.

But quartz uses remark-math which has some issues with the \( \) syntax.
See https://github.com/remarkjs/remark-math/issues/39

This change adds few more transformations to the OxHugoFlavouredMarkdown
plugin, which makes a best effort conversion of this syntax into what
the Quartz Latex transformer plugin supports.

With these changes, the generated files show latex formatting with
default quartz configuration.

Sidenote on `\_` escape by ox-hugo:

ox-hugo escapes, _ using \_, we match against it after we transform
equations into what quartz supports($$ and $).

This could be achieved using lookaround like regex as follows
```js
(?<=(\$|\$\$)[\s\S]*) -> Positive lookbehind for $ or $$
\\_ -> Matches \_
(?=[\s\S]*(?:\1)) Positive lookahead for $ or $$ if matched
const escapedUnderscoreRegex = new RegExp(/(?<=(\$|\$\$)[\s\S]*)\\_(?=[\s\S]*(?:\1))/, "g")
````

But since lookahead/behind can slow things down on large files, we just
look up all equations with $ and $$ delimiters and then try replacing \_
2023-09-29 11:35:26 -07:00
..
description.ts fix: escape encoding for titles in rss 2023-09-06 21:47:59 -07:00
frontmatter.ts fix: coerce title to string 2023-09-25 18:15:55 -07:00
gfm.ts run prettier 2023-07-22 17:27:41 -07:00
index.ts feat: plugin for remark-breaks (#467) 2023-09-10 23:11:42 -07:00
lastmod.ts fix: treat the 0 time as invalid too 2023-09-24 14:47:30 -07:00
latex.ts docs on making plugins 2023-08-10 21:16:07 -07:00
linebreaks.ts feat: plugin for remark-breaks (#467) 2023-09-10 23:11:42 -07:00
links.ts feat: note transclusion (#475) 2023-09-13 11:28:53 -07:00
ofm.ts feat: implement breadcrumb component (#508) 2023-09-29 10:26:15 +02:00
oxhugofm.ts feat: add transformations for latex in oxhugofm (#510) 2023-09-29 11:35:26 -07:00
syntax.ts run prettier 2023-07-22 17:27:41 -07:00
toc.ts fix: toc for cyrillic and other non-latin alphabets (closes #396) 2023-08-22 22:41:50 -07:00