nvim-neorg / neorg

Modernity meets insane extensibility. The future of organizing your life in Neovim.
GNU General Public License v3.0
6.48k stars 212 forks source link

unable to export a neorg document to markdown #478

Closed ThyW closed 2 years ago

ThyW commented 2 years ago

Prerequisites

Neovim Version

v0.8.0-dev(built from source on commit: cf2738109af69f572034147a1aad35a200608180)

Neorg setup

require "neorg".setup {
  load = {
    ["core.defaults"] = {},
    ["core.keybinds"] = {
      config = {
        default_keybinds = true,
        neorg_leader = "<Leader>i"
      }
    },
    ["core.norg.completion"] = {
      config = {
        engine = "nvim-cmp"
      }
    },
    ["core.norg.concealer"] = {},
    ["core.norg.dirman"] = {
      config = {
        workspaces = {
          my_workspace = "~/neorg",
          dashboard = "~/dashboard"
        }
      }
    },
    ["core.gtd.base"] = {
      config = {
        workspace = "dashboard",
        default_lists = {
          inbox = "inbox.norg",
        },
        syntax = {
          context = "#contexts",
          start = "#time.start",
          due = "#time.due",
          waiting = "#waiting.for",
        }
      }
    },
    ["core.export"] = { config = {}},
  },
  requires = "nvim-lua/plenary.nvim"
}

Actual behavior

while in file a.norg which contains:

* Hello world
  - hello world
* Hello world 2

(contents of this file are unimportant) when running :Neorg export to-file a.md markdown, i get an error saying `Unable to export file - did not find exporter for filetype 'markdown'.

Expected behavior

expected to export into a markdown file without any errors

Steps to reproduce

  1. have a neorg file of any name with any content:
    * This
    - and this
    * And That
  2. run nvim command: Neorg export <filename> markdown
  3. errors should be present

Potentially conflicting plugins

there shouldn't be any conflicting plugins

Other information

at first i assumed that im just stupid, so i dug around the documentation. after not finding anything that could have caused this, i started digging around the source code. this issue is that the "core.export.markdown" module is not loaded. i was able to resolve this by adding this line:

module.setup = function()
    return {
        success = true,
        requires = {
            "core.integrations.treesitter",
            "core.export.markdown", -- <- this line
        },
    }
end

to lua/neorg/modules/core/export/module.lua on line 32 or by loading the "core.export.markdown" module in neorg's setup function.

i suspect that this is not a valid fix, since we should be able to load any parser modules depending on the filetype specified(its not an issue now, since there is only one parser, but it could turn into one in the future).

other, probably a more preferable fix, which should be possible would be, in function: lua/neorg/modules/core/export/module.lua:82:

return neorg.modules.get_module("core.export." .. ftype),

this would ideally be changed to load the module on the fly, if it is not present in loaded modules and then get it and probably its configuration as well.

now, after writing all this i realize that this is not really a bug, but it took me some time to figure out and i wasn't able to find anything in the documentation which would hint that i should also load the parser module. im still reporting this as a bug, because i think that at least the documentation should state that one should also load the parser module for the filetype one wishes to export to.

Help

No

Implementation help

No response

max397574 commented 2 years ago

you didn't load the module "core.export.markdown"

ThyW commented 2 years ago

yea my bad, i found the documentation for it now :D, pardon me