sethyuan / logseq-plugin-tocgen

Generate a TOC of any page anywhere to quickly access the page's content.
MIT License
144 stars 10 forks source link

Recognize heading using metadata instead of `#` #13

Closed nhan000 closed 2 years ago

nhan000 commented 2 years ago

When set a block as a heading in Logseq, I right click a block -> convert to a heading. Logseq then add heading:: true as a property for that block.

I prefer this over using # because the heading will automatically change its level base on how deep it is nested, so when I move the blocks around I don't have to change the number of #

This heading currently is not supported by tocgen plugin, so when I use {{renderer :tocgen, *, 2, h}} it doesn't work.

Could you please add support for heading based on the metadata? Thanks a lot!

sethyuan commented 2 years ago

Great suggestion! Personally I never used the heading feature you mentioned. I think it’s doable, I’ll let you know when I have it implemented.

在 2022年1月27日,21:57,nhan000 @.***> 写道:

 When set a block as a heading in Logseq, I right click a block -> convert to a heading. Logseq then add heading:: true as a property for that block.

I prefer this over using # because the heading will automatically change its level base on how deep it is nested, so when I move the blocks around I don't have to change the number of #

This heading currently is not supported by tocgen plugin, so when I use {{renderer :tocgen, *, 2, h}} it doesn't work.

Could you please add support for heading based on the metadata? Thanks a lot!

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you are subscribed to this thread.

sethyuan commented 2 years ago

@nhan000 It's implemented.

nhan000 commented 2 years ago

https://user-images.githubusercontent.com/85216095/151561062-d7f7f595-d99d-4de6-82cb-c85431a8130f.mp4

I've tried it a few times and it's not working for me. When I add h the rendered TOC is really off.

For a mock page that have a few and simple blocks, at the first few tries it rendered correctly, but then it no longer works as expected. For a real page that I use for my university coursework, it's not working at all.

sethyuan commented 2 years ago

Thanks for providing this detailed screenshot! I see you're using links from PDF files. I'll investigate.

sethyuan commented 2 years ago

Hi @nhan000 , I tried PDF links as you demonstrated but found no problem at all. I'm wondering if it could be a compatibility issue with other plugins?

Also, in your case, it's more appropriate to use [[]] as page name instead of *, * means active main page, which change depending how you are displaying the page, [[]] instead, will always follow the page the TOC belongs to.

sethyuan commented 2 years ago

BTW, what version of Logseq are you using?

nhan000 commented 2 years ago

I'm using 0.5.9 official beta (not nightly) I've turned off other plug-ins, closed and reopened Logseq, and still see the buggy behavior. (let me know if I have to uninstall them to test) I've change * to [[]] and it didn't help. Btw, I don't understand what's the difference between [[]] and *. * means active main page => when I zoom in a block the TOC will be rendered differently (only display TOC for the zoomed in block)?

sethyuan commented 2 years ago

I'm using 0.5.9 too. Is it possible you give me a copy of the page that have this issue?

Regarding the * behavior, you can refer to the README, which I just updated to reflect its typical usage.

nhan000 commented 2 years ago

You can download a copy of my Graph that has the 2 pages (together with the pdf and annotations) here

Okay I think I understand the dynamic TOC now. Is it that if we have the dynamic TOC on the right sidebar, in the Contents page, it will automatically renders the TOC for the page opened in the main panel? That's really cool! However, it also didn't work for me ha ha. Please test the dynamic TOC also with the graph I sent you.

Oh and just to be sure, I don't need to change anything in the user config for it to only recognize the heading when I add h to the tocgen code e.g. {{renderer :tocgen, *, 2, h}}? Or do I need to change to "defaultHeadingType": "h" as in the picture? image

thanks a lot for your time fixing this for me!

sethyuan commented 2 years ago

Your copy was very helpful in debugging the problem. I've located the issue and fixed it, please give new version a try.

Regarding the dynamic TOC, yes, it changes automatically depending on what page you're currently working on and, no, you don't need to change default settings if you specify all the parameters.

nhan000 commented 2 years ago

works amazing! :) Thank you so so much!

sethyuan commented 2 years ago

Glad I can help!

在 2022年1月29日,18:09,nhan000 @.***> 写道:

 works amazing! :) Thank you so so much!

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you commented.