Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flexdown does not support Advance Latex math #825

Open
sadsquirrel369 opened this issue Jul 22, 2024 · 1 comment
Open

Flexdown does not support Advance Latex math #825

sadsquirrel369 opened this issue Jul 22, 2024 · 1 comment

Comments

@sadsquirrel369
Copy link

I am trying to build a blog of my own using this website as an example. When parsing more advance latex to the markdown function $\sum_{x^2+1}$ the system breaks (\sum_{x^2+1})

`
Traceback (most recent call last):
File "/opt/homebrew/Caskroom/miniforge/base/envs/Blog/lib/python3.10/site-packages/flexdown/utils.py", line 45, in evaluate_templates
eval_result = str(eval(match, env, env))
File "", line 1
{x^2+1
^
SyntaxError: '{' was never closed

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/opt/homebrew/Caskroom/miniforge/base/envs/Blog/bin/reflex", line 8, in
sys.exit(cli())
File "/opt/homebrew/Caskroom/miniforge/base/envs/Blog/lib/python3.10/site-packages/typer/main.py", line 326, in call
raise e
File "/opt/homebrew/Caskroom/miniforge/base/envs/Blog/lib/python3.10/site-packages/typer/main.py", line 309, in call
return get_command(self)(*args, **kwargs)
File "/opt/homebrew/Caskroom/miniforge/base/envs/Blog/lib/python3.10/site-packages/click/core.py", line 1157, in call
return self.main(*args, **kwargs)
File "/opt/homebrew/Caskroom/miniforge/base/envs/Blog/lib/python3.10/site-packages/typer/core.py", line 723, in main
return _main(
File "/opt/homebrew/Caskroom/miniforge/base/envs/Blog/lib/python3.10/site-packages/typer/core.py", line 193, in _main
rv = self.invoke(ctx)
File "/opt/homebrew/Caskroom/miniforge/base/envs/Blog/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/opt/homebrew/Caskroom/miniforge/base/envs/Blog/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/opt/homebrew/Caskroom/miniforge/base/envs/Blog/lib/python3.10/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
File "/opt/homebrew/Caskroom/miniforge/base/envs/Blog/lib/python3.10/site-packages/typer/main.py", line 692, in wrapper
return callback(**use_params)
File "/opt/homebrew/Caskroom/miniforge/base/envs/Blog/lib/python3.10/site-packages/reflex/reflex.py", line 260, in run
_run(env, frontend, backend, frontend_port, backend_port, backend_host, loglevel)
File "/opt/homebrew/Caskroom/miniforge/base/envs/Blog/lib/python3.10/site-packages/reflex/reflex.py", line 186, in _run
prerequisites.get_compiled_app()
File "/opt/homebrew/Caskroom/miniforge/base/envs/Blog/lib/python3.10/site-packages/reflex/utils/prerequisites.py", line 288, in get_compiled_app
app_module = get_app(reload=reload)
File "/opt/homebrew/Caskroom/miniforge/base/envs/Blog/lib/python3.10/site-packages/reflex/utils/prerequisites.py", line 261, in get_app
app = import(module, fromlist=(constants.CompileVars.APP,))
File "/Users/kobus/Documents/Private/Codebase/Blog/Blog/Blog.py", line 18, in
app.add_page(
File "/opt/homebrew/Caskroom/miniforge/base/envs/Blog/lib/python3.10/site-packages/reflex/app.py", line 500, in add_page
component = self._generate_component(component)
File "/opt/homebrew/Caskroom/miniforge/base/envs/Blog/lib/python3.10/site-packages/reflex/app.py", line 422, in _generate_component
return component if isinstance(component, Component) else component()
File "/Users/kobus/Documents/Private/Codebase/Blog/Blog/utils/template.py", line 48, in wrapper
contents(*children, **props),
File "/Users/kobus/Documents/Private/Codebase/Blog/Blog/pages/blog/blog.py", line 15, in
lambda doc=document: page(doc, route)
File "/Users/kobus/Documents/Private/Codebase/Blog/Blog/pages/blog/page.py", line 130, in page
xd.render(document, "blog.md"),
File "/opt/homebrew/Caskroom/miniforge/base/envs/Blog/lib/python3.10/site-packages/flexdown/flexdown.py", line 205, in render
f"\n{block.get_content(env)}"
File "/opt/homebrew/Caskroom/miniforge/base/envs/Blog/lib/python3.10/site-packages/flexdown/blocks/block.py", line 110, in get_content
return "\n".join(self.get_lines(env))
File "/opt/homebrew/Caskroom/miniforge/base/envs/Blog/lib/python3.10/site-packages/flexdown/blocks/block.py", line 95, in get_lines
lines = [
File "/opt/homebrew/Caskroom/miniforge/base/envs/Blog/lib/python3.10/site-packages/flexdown/blocks/block.py", line 96, in
self._apply_transforms(line, env)
File "/opt/homebrew/Caskroom/miniforge/base/envs/Blog/lib/python3.10/site-packages/flexdown/blocks/block.py", line 79, in _apply_transforms
line = transform(line, env)
File "/opt/homebrew/Caskroom/miniforge/base/envs/Blog/lib/python3.10/site-packages/flexdown/utils.py", line 49, in evaluate_templates
raise ValueError(f"Failed to evaluate expression '{match}'") from e
ValueError: Failed to evaluate expression '{x^2+1'
`

@picklelo
Copy link
Contributor

@sadsquirrel369 Currently flexdown looks for {expr} and fills it in with Python expressions. I need to make the escape a double brace instead to avoid this, but you can escape it by doing \{expr} - for example

Sum is  $\sum_\{x^2+1}$

That makes it compile for me, but sum still doesn't render. Maybe something missing without our katex implementation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants