tscanlin / tocbot

Build a table of contents from headings in an HTML document.
MIT License
1.36k stars 113 forks source link

Additional input text line for either filtering or searching #329

Open stenzengel opened 4 months ago

stenzengel commented 4 months ago

Thanks for this nice project, which I like a lot and which I use for Asciidoctor documents.

Have you ever thought about adding an additional input text line that could be used to quickly find headings in a very long table of contents?

Two alternatives come to mind. I don't know which one makes more sense. Maybe you have other ideas:

What do you think?

tscanlin commented 4 months ago

Hi, thanks for the suggestion Winfried. This is an interesting idea and should be possible to implement with the existing APIs on top of Tocbot.

I think the trickiest things to figure out would be the scroll interactions and hiding things when the user may not want them hidden, as you mentioned. For instance, if you did hide things when filtered and then scrolled would it show everything or just the current heading and its ancestors? Also what would the scroll threshold be?

Are there reasons why the built in browser search is insufficient? I feel like when I’m searching for something, I want to search the whole page since the content is often not in headings. But maybe there is a use case I’m missing. I have not heard this request before and currently don’t have time to implement it, but if you’d like to make a plugin or something I’d be happy to review and link to it.

Thanks, -Tim

On Tue, Feb 13, 2024 at 1:50 AM Winfried Stenzel @.***> wrote:

Thanks for this nice project, which I like a lot and which I use for Asciidoctor documents.

Have you ever thought about adding an additional input text line that could be used to quickly find headings in a very long table of contents?

Two alternatives come to mind. I don't know which one makes more sense. Maybe you have other ideas:

  • Filtering: This hides all headings (except ancestors) that do not match the specified filter string. If it is confusing for the user that the current heading may not be visible when scrolling in the document, the filter string could either be cleared when scrolling, or the heading at the current position (and its ancestors) should not be filtered away even if it does not match the filter string.
  • Searching: This is similar to the standard browser search, but only searches the TOC. There are no options (uppercase, whole word), but there are "Next" and "Previous" buttons that allow you to jump to the matches in the TOC and thus in the normal document.

What do you think?

— Reply to this email directly, view it on GitHub https://github.com/tscanlin/tocbot/issues/329, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABGMYSE6HXBUIMFYSMPVLALYTMLN5AVCNFSM6AAAAABDGAXDSWVHI2DSMVQWIX3LMV43ASLTON2WKOZSGEZTCNRVGI4TSOA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

stenzengel commented 4 months ago

Hi Tim,

Thanks for the reply. The use case mainly revolves around using this filtering/search on a smartphone (for long a long text and toc), where you don't see much information on the screen and don't want to tap a lot of letters.

For example, I imagine the filtering alternative as in VS Code when using the menu item Go -> Go to Symbol in Editor. Other editors that I know of, have similar features (in addition to a normal search) to quickly jump to headings in a text or functions in source code.

Also, on a smartphone, the "scroll interactions and hiding things" you and I mentioned, would be less of a (or no) problem, because only the (filtered) toc is visible.

Thanks for the review offer. Maybe I will give it a try.

Winfried