Skip to content

Added ability to follow anchors to heading-id#381

Merged
lervag merged 4 commits intolervag:masterfrom
sonjiku:heading-id
Sep 14, 2024
Merged

Added ability to follow anchors to heading-id#381
lervag merged 4 commits intolervag:masterfrom
sonjiku:heading-id

Conversation

@sonjiku
Copy link
Copy Markdown
Contributor

@sonjiku sonjiku commented Sep 12, 2024

Pretty easy fix thanks to how well you've written your code. I suggest adding some more comments to make it easier for people to contribute, though the documentation was an enormous help!

Makes the wiki link handler look for exact, case-sensitive header-id match for anchors. Tested and works great!

@lervag
Copy link
Copy Markdown
Owner

lervag commented Sep 12, 2024

Pretty easy fix thanks to how well you've written your code.

Thanks!

I suggest adding some more comments to make it easier for people to contribute, though the documentation was an enormous help!

It's hard to say which parts would benefit from more comments. I don't mind adding comments, but I usually don't comment things unless I realize it may be useful. But I'll take note and use more comments in the future.

Makes the wiki link handler look for exact, case-sensitive header-id match for anchors. Tested and works great!

Could you give me a few examples and/or write a test for this as well?

@lervag
Copy link
Copy Markdown
Owner

lervag commented Sep 12, 2024

Related tests are under tests/test-links, e.g. here: https://github.com/sonjiku/wiki.vim/blob/master/test/test-links/test-follow-anchored.vim.

The tests may be slightly harder to understand. If you give me a few examples I could write the test myself.

@sonjiku
Copy link
Copy Markdown
Contributor Author

sonjiku commented Sep 12, 2024

I'll have a look, but essentially, markdown reference includes Heading IDs as anchor points that can be used as links. Example:

### Heading {#heading-id}
Lorem ipsum dolores my wife.

Essentially a heading that is appended by:

  • open curly brace {
  • numbersign #
  • a string of characters without spaces [^ ]+
  • close curly brace )

… work as expected due to conflicts with the other regex. This should work as expected now.
@sonjiku
Copy link
Copy Markdown
Contributor Author

sonjiku commented Sep 13, 2024

Tests made and feature works as expected.

@lervag
Copy link
Copy Markdown
Owner

lervag commented Sep 13, 2024

Thanks! On my end, two of the tests fail:

lervag@lotti: wiki.vim/test on  heading-id
❯ make
**** SYSTEM INFORMATION ****
commit e2863bc9aaa152beb357ca94f14a434d0f08e23f (HEAD -> heading-id)
Author: sonjiku <dev.50nj1ku@erine.email>
Date:   2024-09-13 04:57:52 +0300

    Fixed. Should pass all the tests I've made.
NVIM v0.11.0-dev-727+g5ddf2ab768
Build type: Release
LuaJIT 2.1.1723675123
Run "nvim -V1 -v" for more info
**** SYSTEM INFORMATION ****
make -C test-complete
make -C test-graph
make -C test-init
make -C test-journal
make -C test-links
test-follow-anchored-id.vim:18
  Expected: 16
  Observed: 9
test-follow-anchored-id.vim:22
  Expected: 22
  Observed: 10
make[1]: *** [Makefile:11: test-follow-anchored-id.vim] Error 1
make: *** [Makefile:12: test-links] Error 2

These correspond to lines 9 and 10 in the new index.md. I'm not quite sure why they fail, and I don't have time to look into it further until possibly tomorrow.

@sonjiku
Copy link
Copy Markdown
Contributor Author

sonjiku commented Sep 13, 2024

Lol, I hadn't slept while hacking it together, but now all tests pass.

@lervag lervag merged commit 455ff27 into lervag:master Sep 14, 2024
@lervag
Copy link
Copy Markdown
Owner

lervag commented Sep 14, 2024

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants