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

Fix inline Latex rendering #1442

Closed
2 tasks done
glyh opened this issue May 28, 2024 · 8 comments
Closed
2 tasks done

Fix inline Latex rendering #1442

glyh opened this issue May 28, 2024 · 8 comments
Labels
bug Issues related to bugs. Please attach a severity, a priority and category with this label.

Comments

@glyh
Copy link

glyh commented May 28, 2024

Prerequisites

  • I am using the latest stable release of Neovim
  • I am using the latest version of the plugin

Neovim Version

NVIM v0.10.0 Build type: Release LuaJIT 2.1.1713773202 Run "nvim -V1 -v" for more info

Neorg setup

      require("neorg").setup {
        load = {
          ["core.defaults"] = {},
          ["core.export"] = {},
          ["core.export.markdown"] = {},
          ["core.concealer"] = {},
          ["core.completion"] = {
            config = {
              engine = "nvim-cmp",
            },
          },
          ["core.dirman"] = {
            config = {
              workspaces = {
                notes = "~/Documents/notes/neorg",
              },
              default_workspace = "notes",
            },
          },
          ["core.integrations.image"] = {},
          ["core.latex.renderer"] = {},
        },
      }

Actual behavior

image

Expected behavior

  1. Source is hidden when the formula is rendered
  2. Have the formula using corresponding colors, if it's inside some text then the formula should be rendered using text's color. If it's inside a title, it should be rendered with a title's color.
  3. The around text is aligned so that there's not a lot of space between the formula and the adjacent text.
  4. The rendered Latex takes care of line breaks. When the formula is rendered in 2 lines the issue is resolved automagically like in markdown.
I can use $\LaTeX\\ like \\ this$, and it works 

image

  1. for a single line of latex, if it exceeded the right end of the editor it should be rendered in the next line.
  2. For now it seems that for latex formula to render correctly, all forward slashes should be double quoted. Is there a point for that or is that a bug?

Steps to reproduce

Follow the cookbook with latex support.

Potentially conflicting plugins

image.nvim?

Other information

None.

Help

Yes, but I don't know how to start. I would need guidance (check question below)

Implementation help

No response

@glyh glyh added the bug Issues related to bugs. Please attach a severity, a priority and category with this label. label May 28, 2024
@github-project-automation github-project-automation bot moved this to added-updated-reopened in sorting neorg issue tracker May 28, 2024
@glyh
Copy link
Author

glyh commented May 28, 2024

I don't know if it's related to #1438, it seems not?

@glyh glyh changed the title Hide the formula source when using latex rendering Better inline Latex rendering May 28, 2024
@glyh glyh changed the title Better inline Latex rendering Fix inline Latex rendering May 28, 2024
@glyh
Copy link
Author

glyh commented May 28, 2024

I personally tends toward a typst support instead of latex, though.

@benlubas
Copy link
Contributor

I don't know if it's related to #1438, it seems not?

it's not. that PR is to fix a single issue. You're asking for a bunch of new features it seems like


Source is hidden when the formula is rendered

This already works. and is the default, you probably don't have conceallevel set properly.

Have the formula using corresponding colors, if it's inside some text then the formula should be rendered using text's color. If it's inside a title, it should be rendered with a title's color.

Well then I guess you expect the math to always be blue? That's how math displays when it's in headers, or bolded, or anything really. I also think this would be an additional performance hit for no real gain.

image image

The around text is aligned so that there's not a lot of space between the formula and the adjacent text.

wdym? text is concealed so there is no additional space between the image and the adjacent text. This might be a misunderstanding related to the conceallevel issue at the top of this list.

The rendered Latex takes care of line breaks. When the formula is rendered in 2 lines the issue is resolved automagically like in markdown.

This is a lot harder than you think it is. It would be really hacky in the current implementation, let alone the upcoming one which will support typst.

for a single line of latex, if it exceeded the right end of the editor it should be rendered in the next line.

Near impossible with the current implementation due to how much work image.nvim is doing for us.

For now it seems that for latex formula to render correctly, all forward slashes should be double quoted. Is there a point for that or is that a bug?

not a bug, \ is the escape char in the norg file format. So typing \$ will produce a $ in norg. (This is easy to see when you have the concealer turned on btw). So \\ is needed to produce a \. I recommend using this syntax: $| \frac{1}{2} |$ where everything between the | is verbatim.


typst support is around the corner

@glyh
Copy link
Author

glyh commented May 28, 2024

Thanks, I initially disabled conceal level config as it messes up my other files that uses foldmarkers, I'll try to see if I can fix it.

@glyh glyh closed this as completed May 28, 2024
@github-project-automation github-project-automation bot moved this from added-updated-reopened to done in sorting neorg issue tracker May 28, 2024
@glyh
Copy link
Author

glyh commented May 28, 2024

Also I guess I'll split this into separte feature requests for what makes sense.

@benlubas
Copy link
Contributor

Thanks, I initially disabled conceal level config as it messes up my other files that uses foldmarkers, I'll try to see if I can fix it.

you can set it just for norg files with a filetype plugin.

:h ftplugin

tldr: create a file in your config at: nvim/ftplugin/norg.lua and add this to it (along with anything else you might want to set for norg files only):

vim.opt_local.conceallevel = 2

@benlubas
Copy link
Contributor

@glyh to make sure you see that

@glyh
Copy link
Author

glyh commented May 28, 2024

Yeah I saw it, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues related to bugs. Please attach a severity, a priority and category with this label.
Projects
None yet
Development

No branches or pull requests

2 participants