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

Link to file with multiple level 1 heading show as "ambiguous" #323

Closed
Hirschiii opened this issue Jul 19, 2024 · 6 comments
Closed

Link to file with multiple level 1 heading show as "ambiguous" #323

Hirschiii opened this issue Jul 19, 2024 · 6 comments
Labels

Comments

@Hirschiii
Copy link

I have the practise to set the title in the yaml-header and use multiple level one headings in the document. I pretty sure this is the issue, when I reduce the number of level one headings, the warning goes away.

I did not find any setting like offsetting the heading by one, or even ignore this warning.

Is there a way to remove this warning?

Thank you very much, except of this I really do enjoy using this LSP

@noman-test
Copy link

The diagnostics function of marksman can be disabled directly if you doesn't mind the absence of marksman's other link diagnostics prompts. Such as:

-- in your nvim's config file
local lspconfig = require("lspconfig")
lspconfig.marksman.setup{
  handlers = {
    ["textDocument/publishDiagnostics"] = function() end
  }
}

@artempyanykh
Copy link
Owner

@Hirschiii this is something that came up a few times. I need to figure out how to make the UX consistent including how to tie this to the completion style, e.g.:

  • when completion.wiki.style = title-slug Marksman would expect only a single level-1 header that is also the name of the doc,
  • when completion style is file-based, it will only use file names and leave the headers to mark sections of the document.
  • adding support for yaml front-matter as another source of 'titles' (as a feature it'll have to work with rename refactor)

Currently, Marksman uses both file names and level-1 headers to figure out the ID of a document, which I understand is suboptimal.

@bearv5 nice workaround!

@ncaq
Copy link

ncaq commented Oct 29, 2024

I have been using multiple h1s for a long time.
Since marksman recommends having only one h1, I looked at the Mozilla page and learned that indeed one h1 is better.
So I decided to change my habits and use only one h1 and use h2.

However, that created a problem.
When converting Markdown to PDF via Pandoc, the LaTeX engine considers the header to be a section heading, so with that in mind, it is better to use h1 as the top-level heading than h2.
I also wanted to write author information, abstract, etc. before the heading.
If I just want to convert Markdown to HTML, I can assume h2, but considering that I also want to make it into PDF, I still want to use h1.

Thus, I still could not adopt the practice of linking to only one h1.
I would like to be able to control this in marksman's settings or something.

@wardw
Copy link

wardw commented Nov 21, 2024

I'm also in the club of using multiple level 1 headings in a markdown document.

I've set my config to

[completion]
wiki.style = "file-stem"

but I'm still getting "Ambiguous link to document" for any link to a file with more than one h1. Am I misunderstanding this, or with "file-stem" a vanilla link such as [[my doc]] should unambiguously link to the file my doc.md regardless of the headings within the file? I'm more than happy just to write [[my doc#my-heading]] for those times I want to link to a specific heading (which i also do, so love this flexible approach).

@artempyanykh
Copy link
Owner

@wardw I'm planning to make the h1 header == title configurable, starting with some preliminary work in #364. But I think in the next release, you'll be able to say in .marksman.toml something like:

[core]
title_from_heading = false

And then H1s will be treated like regular headings (it will also affect the default completion style for wiki links).

@artempyanykh
Copy link
Owner

I think this should be addressed in 2024-12-04. Please, report if something doesn't work as expected.

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

No branches or pull requests

5 participants