liamcain / obsidian-things-logbook

Sync your Things 3 Logbook with Obsidian
MIT License
120 stars 22 forks source link

section headings with links don't nest properly #8

Closed pmbauer closed 3 years ago

pmbauer commented 3 years ago

Describe the bug

If the Section heading contains a wiki link instead of starting with a word boundary character after the heading #s, (e.g. "## [[Logbook]]") the areas that should be nested are all H1.

This is because the regex in getHeadingLevel requires \s\b (space followed by word boundary) to compute the number of #s at the front of the Section heading and getHeadingLevel("## [[Logbook]]") => null. I edited the main.js plugin file to remove \b locally and this plugin behaves as expected.

I'd be happy to submit a pull request, but I see this regex was explicitly added here https://github.com/liamcain/obsidian-things-logbook/commit/b057ecf3cfb1757e7fc007111005c44c123928e3#diff-39b2554fd18da165b59a6351b1aafff3714e2a80c1435f2de9706355b4d32351R5

... and I assume there is some context I'm missing or some other use case that removing the \b might break.

Steps to reproduce

  1. From the "Things Logbook" preferences dialog, set Section heading to ## [[Logbook]]
  2. Run Things Logbook: Sync from the command pallet
  3. Imported tasks will not be properly nested and all areas will be H1 because getHeadingLevel("## [[Logbook]]") => null
## [[Logbook]]
# [[Area 51]]
- [x] task 1

Expected behavior

Areas should nest under the Section heading.

OS

macOS

Obsidian Version

v0.11.7

obsidian-things-logbook Version

0.1.8

liamcain commented 3 years ago

Oh, good catch! For some reason I was thinking \b matched all non-whitespace characters. I changed this to be \s+\S which should better match the markdown spec.

pmbauer commented 3 years ago

Thanks so much!!