diff options
| author | martial.simon <martial.simon@epita.fr> | 2025-04-13 19:54:19 +0200 |
|---|---|---|
| committer | martial.simon <martial.simon@epita.fr> | 2025-04-13 19:54:19 +0200 |
| commit | 66c3bbfa94d8a41e58adf154be25e6d86fee8e30 (patch) | |
| tree | 9c5e998f324f2f60c1717759144da3f996c5ae1a /.obsidian/plugins/obsidian-enhancing-export/lua/math_block.lua | |
init: initial commit
Diffstat (limited to '.obsidian/plugins/obsidian-enhancing-export/lua/math_block.lua')
| -rwxr-xr-x | .obsidian/plugins/obsidian-enhancing-export/lua/math_block.lua | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/.obsidian/plugins/obsidian-enhancing-export/lua/math_block.lua b/.obsidian/plugins/obsidian-enhancing-export/lua/math_block.lua new file mode 100755 index 0000000..380d96a --- /dev/null +++ b/.obsidian/plugins/obsidian-enhancing-export/lua/math_block.lua @@ -0,0 +1,68 @@ +traverse = 'topdown' + +math_block_text = nil +function process(el) + + -- MathBlock start or end + if el.t == 'Str' and el.text == '$$' then + if math_block_text == nil then -- start + math_block_text = '' + else -- end + local math_block = pandoc.Math('DisplayMath', '\n' .. math_block_text .. '\n') + math_block_text = nil + return math_block + end + return {} + end + + if math_block_text then + if (el.t == 'RawInline' or el.t == 'RawBlock') and el.format == 'tex' then + math_block_text = math_block_text .. el.text + return {} + elseif el.t == 'Str' then + math_block_text = math_block_text .. el.text + return {} + elseif el.t == 'SoftBreak' or el.t == 'BulletList' then + return {} + end + end + return el +end + +function RawInline(el) + return process(el) +end + +function RawBlock(el) + return process(el) +end + +function Str(el) + return process(el) +end + +function SoftBreak(el) + return process(el) +end + +function Header(el) + return process(el) +end + +function Para(el) + return process(el) +end + +function Plain(el) + return process(el) +end + +function BulletList(el) + return process(el) +end + + + + + + |
