oleeskild / obsidian-digital-garden

MIT License
1.32k stars 122 forks source link

Complex LaTex expressions cause a build failure #299

Open aigoncharov opened 1 year ago

aigoncharov commented 1 year ago

Complex LaTex expressions like this one:

$$ \frac{{n \choose k} {N - n \choose m - k}}{{N \choose m}} $$

are parsed as njk templates first, which leads to an njk error - it tries to treat {{}} as an njk expression.

The error:

[11ty] Original error stack trace: Template render error: (./src/site/notes/Math/Probability/Hypergeometric probability.md) [Line 6, Column 10]
[11ty]   expected variable end
[11ty]     at Object._prettifyError (/vercel/path0/node_modules/nunjucks/src/lib.js:36:11)
[11ty]     at Template.init (/vercel/path0/node_modules/nunjucks/src/environment.js:511:19)
[11ty]     at Template.Obj (/vercel/path0/node_modules/nunjucks/src/object.js:62:15)
[11ty]     at new Template (/vercel/path0/node_modules/nunjucks/src/environment.js:478:18)
[11ty]     at Nunjucks.compile (/vercel/path0/node_modules/@11ty/eleventy/src/Engines/Nunjucks.js:406:14)
[11ty]     at Markdown.compile (/vercel/path0/node_modules/@11ty/eleventy/src/Engines/Markdown.js:68:28)
[11ty]     at TemplateRender.getCompiledTemplate (/vercel/path0/node_modules/@11ty/eleventy/src/TemplateRender.js:269:26)
[11ty]     at Template.compile (/vercel/path0/node_modules/@11ty/eleventy/src/TemplateContent.js:362:42)
[11ty]     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[11ty]     at async Template._render (/vercel/path0/node_modules/@11ty/eleventy/src/TemplateContent.js:486:16)

It could be fixed by:

  1. Setting "markdownTemplateEngine" to false in .eleventy.js
  2. Removing "templateEngineOverride" from src/site/notes/notes.json

I am not submitting a PR because I am not sure if my use case is niche or how it could affect other digital gardens. Feel free to close the issue. I merely wanted other poor soul to be able to find it by the error name in search.

Commit with the fix - link

wheresalice commented 1 year ago

Similar to #143 and #271 - so that's now at least three of us who have hit this issue

Thank you for finding a solution!

aigoncharov commented 1 month ago

If you see it again with the site update, it might be caused by a minification error. To fix it add "continueOnParseError: true" to your minification config. See https://github.com/aigoncharov/first-and-only-brain/commit/774c7ed54aa012373a45b6bc75b8c29e56be83b4