Skip to content
New issue

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

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

Already on GitHub? # to your account

Cannot have more than one character as headings symbol #12

Closed
Rukenshia opened this issue Apr 3, 2024 · 2 comments
Closed

Cannot have more than one character as headings symbol #12

Rukenshia opened this issue Apr 3, 2024 · 2 comments

Comments

@Rukenshia
Copy link

Just found this cool plugin and wanted to customise it.

I wanted to replace the default heading symbols (because they're super tiny at least with my current font) with something else so I figured I would use h1., h2., and so on as the characters replacing the # in headings.

I used this config

return {
  'MeanderingProgrammer/markdown.nvim',
  dependencies = { 'nvim-treesitter/nvim-treesitter' },
  config = function()
    require('render-markdown').setup {
      headings = { 'h ', 'h2. ', 'h3. ', 'h4. ', 'h5. ', 'h6. ' },
    }
  end,
}

and have this markdown file

# heading

## subheading

I see this:

imagen
  • Heading with a single character + space (h ) works fine
  • Heading with more characters seem to cut off the subheading text

I'm not sure if it is intended like this (only allowing a single character), or if I'm doing stuff wrong, but the documentation for headings only says -- Characters that will replace the # at the start of headings which left it a bit unclear to me.

MeanderingProgrammer added a commit that referenced this issue Apr 3, 2024
# Details

As stated in this issue: #12,
we currently only handle headings with a string width of 1 or 2, longer
headings will overlay the titles.

To fix this calculate the width of the heading to determine the amount
of paddings needed. This will still fail if the heading provided is
longer than the level of the heading, since we have fewer characters
to work with.
@MeanderingProgrammer
Copy link
Owner

Hi, thanks for brining this up. The way the logic was setup was to handle headings of length 1 or 2 only essentially.

I went ahead and patched this behavior in this commit: a0da7cf.

Please try it out with the following configuration and let me know what you think:

headings = { 'h ', 'h2 ', 'h3 ', 'h4 ', 'h5 ', 'h6 ' },

There is still a limitation on length for lower level headings. What I mean by that is since we don't shift text and just overlay it with an h1 like:

# Test

We only have 2 characters to play with, the # and the space before Test, anything longer will end up overwriting the title itself still.

@Rukenshia
Copy link
Author

Thank you very much!

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

No branches or pull requests

2 participants