SidOfc/mkdx

jumping to underlined headers doesn't work

m-fonseca opened this issue ยท 4 comments

OS type:

  • Unix
  • Windows
  • Other ([SPECIFY])

Vim:

  • vim
  • neovim
  • Other ([SPECIFY])

Vim version:
NVIM v0.4.4

Using mkdx 602a784

Reproduce steps:

Use the following markdown file.

Title
=====

# Table of Contents

- [Title](#title)
- [Table of Contents](#table-of-contents)
    - [Head1](#head1)
        - [Head2](#head2)
            - [Head3](#head3)

Head1
-----

### Head2

#### Head3
  1. Jumping to each heading from the table of contents is possible except for Head1

Expected:

Jumps to Head1

Actual:

Doesn't jump to Head1

Thanks!

I see, yeah this should indeed work with setex style headings, will look into it, cheers ๐Ÿ‘

And hello again @m-fonseca, setex style headers should now also work, feel free to reopen if you still experience issues.

Awesome. Thanks for all your work on these. I did encounter another problem that's related, but you might consider another bug. (If you think so, I can open a separate issue).

If you use the same markdown file with no table of contents (don't just delete it and stick it back in, make sure its deleted, save it and exit, and then open it again), and then insert the table of contents, you can't jump to head2 and head3, but as soon as you save it, the the links will work.

I.e. you can't jump to level 3 & 4 headers without saving first.

@m-fonseca yeah this is indeed a side effect which has to do with how mkdx find these headers.

Viml isn't the fastest language out there so to compensate, mkdx uses grep in a background job to speed things up.
Because of this, the buffer needs to be written to disk because grep doesn't work on the in-memory file.

The reason it does work for setex style headers is because this is a lot trickier to implement with grep since they span more than one line (text line followed by - / =), so there I decided to use the native language features.

In any case I don't think this is something I want to change or fix, it's always good to save your changes at any point in time (I save literally tons of times since I'm a bit paranoid of losing work in case of editor / pc crash or power outage).

Cheers for pointing it out though ๐Ÿ‘Œ