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

exporter: markdown math #701

Closed
2 tasks done
esquires opened this issue Jan 3, 2023 · 1 comment
Closed
2 tasks done

exporter: markdown math #701

esquires opened this issue Jan 3, 2023 · 1 comment
Labels
bug Issues related to bugs. Please attach a severity, a priority and category with this label.

Comments

@esquires
Copy link
Contributor

esquires commented Jan 3, 2023

Prerequisites

  • I am using either 0.7 stable with the 0.0.12 tag or the latest compiled Neovim version
  • I am using the latest version of the plugin

Neovim Version

NVIM v0.8.2 Build type: RelWithDebInfo LuaJIT 2.1.0-beta3 Compilation: /usr/bin/cc -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -DNVIM_TS_HAS_SET_ALLOCATOR -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/esquires3/repos/neovim/build/cmake.config -I/home/esquires3/repos/neovim/src -I/home/esquires3/repos/neovim/.deps/usr/include -I/usr/include -I/home/esquires3/repos/neovim/build/src/nvim/auto -I/home/esquires3/repos/neovim/build/include Compiled by esquires3@esquires-pc2 Features: +acl +iconv +tui See ":help feature-compile" system vimrc file: "$VIM/sysinit.vim" fall-back for $VIM: "/usr/local/share/nvim" Run :checkhealth for more info

Neorg setup

  use {
    "nvim-neorg/neorg",
    run = ":Neorg sync-parsers", -- This is the important bit!
    branch = 'main',
    requires = { {
      'nvim-lua/plenary.nvim', "nvim-neorg/neorg-telescope"
    } },
    config = function()
      require("neorg").setup {
        load = {
          ["core.defaults"] = {}, -- Load all the default modules
          ["core.norg.concealer"] = { config = { markup_preset = "conceal" } },
          ["core.norg.esupports.metagen"] = {config = {type = "auto"}},
          ["core.export"] = {config = {extensions = "all"}},
          ["core.export.markdown"] = {config = {extensions = "all"}},
          ["core.norg.dirman"] = { -- Manage your directories with Neorg
            config = {
              workspaces = { my_workspace = "~/norg" },
              autochdir = true,
            }
          },
          ["core.norg.completion"] = { config = { engine = "nvim-cmp" } },
          ["core.keybinds"] = { -- Configure core.keybinds
            config = {
              default_keybinds = true, -- Generate the default keybinds
              neorg_leader = "<Leader>o"
            }
          },
          ["core.integrations.telescope"] = {}
        },
      }
    end,
  }

Current neorg commit is 00532bd9 (the current main branch commit)

Actual behavior

Given foo.norg with the following contents:

$\sigma = 1$

  @math
  f(x) = y
  @end

when I run :Neorg export to-file /tmp/foo.md it outputs this:

$sigma = 1$

$$

f(x) = y
$$

There are 2 problems here:

  • The sigma is lacking a slash at the beginning (it should be \sigma, not sigma)
  • The display equation has an added new line after the first $$

This means when I run pandoc on the markdown file to convert it to pdf, the sigma greek letter is not displayed and the display equation is not rendered.

Expected behavior

I think the export to markdown should render as

$\sigma = 1$

$$
f(x) = y
$$

Steps to reproduce

See Actual Behavior section.

Potentially conflicting plugins

None I am aware of.

Other information

No response

Help

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

Implementation help

No response

@esquires esquires added the bug Issues related to bugs. Please attach a severity, a priority and category with this label. label Jan 3, 2023
@vhyrro
Copy link
Member

vhyrro commented Jan 5, 2023

Hey! The second issue with the display equation should be fixed now :). The first issue is actually expected - in the 1.0 syntax, verbatim inline elements have less precedence than backslashes, that is, backslashes can exist within verbatim inline elements. To fix your issue, you can do one of two things:

  1. add two backslashes. For example: $\\sigma = 1$. With latex this can get a bit messy though so I'd personally use it sparingly.
  2. Convert the syntax into a free-form verbatim markup element. A free-form element is written as such: $|content|$. It's the same characters but a | on the inside. This has greater precedence than the backslash, and as such you can write: $|\sigma = 1|$. In the near future when Neorg implements custom rules for autopairs, when typing $ the default for Neorg will be to autoinsert $||$, as it's the most common user-preferred operation.

The details of this are a little bit long so I guess just trust us:tm: on this behaviour being the right decision for the time being. Hope that helps!

@vhyrro vhyrro closed this as completed Jan 5, 2023
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