Zim

Make a Table of Contents from the headings

Bug #373280 reported by dotancohen
44
This bug affects 8 people
Affects Status Importance Assigned to Milestone
Zim
Fix Released
Wishlist
Unassigned

Bug Description

As Zim supports semantically correct markup, it would be nice if Zim could create a Table of Contents at the top of notes to let the user quickly navigate to the place he needs. I have a user who uses semantically-correct document formatting, and has some very long notes that should not be broken up into smaller notes. The Table of Contents would be a large help.

Thanks!

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

May be quite easy to have a plugin that puts a widget somewhere in the interface, e.g. in the side pane above the index tree, that shows the ToC as a treeview. You can get the headings quite easily by walking the parse tree of the page and hook that up to the page-loaded signal to re-fresh the ToC widget.

This would be a good starter project for anyone wanting to try their hands on a plugin.

Actually inserting a ToC in the page and updating on the fly is more of an advanced project as we currently lack the framework for such inline objects.

Changed in zim:
importance: Undecided → Wishlist
status: New → Confirmed
Revision history for this message
dotancohen (dotancohen) wrote :

I just noticed that Thunderbird can create a table of contents from an HTML email message. See attached Thunderbird dialogue.

Revision history for this message
Holstener Liesel (holstenerliesel) wrote :

I agree this would make a great addition.

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

Attached a first stab at such a plugin. Usuable bit still a bit rough.

1/ need way for user to resize the widget (?)
2/ need to make the pageview scroll to the header instead of just highlighting it

Also looking for some input on visual design - is there some way to make it look more attractive ?

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

P.S. to use the attached plugin, just drop it in zim/plugins in the zim install dir.

Changed in zim:
status: Confirmed → In Progress
Revision history for this message
dotancohen (dotancohen) wrote :

Terrific, Jaap. I'll download and test shortly. Should I mention issues on this bug report, on the mailing list, or in a new bug report for each issue?

Thanks! It's great to see Zim improving the past few weeks!

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote : Re: [Bug 373280] Re: Make a Table of Contents from the headings

On Fri, Jan 28, 2011 at 6:11 PM, dotancohen <email address hidden> wrote:
> Terrific, Jaap. I'll download and test shortly. Should I mention issues
> on this bug report, on the mailing list, or in a new bug report for each
> issue?

Please add them here. Please note you need latest dev version of zim
(or 0.50 release when available) to use this plugin.

Revision history for this message
smu (smu) wrote :

On Fri, Jan 28, 2011 at 03:49:59PM -0000, Jaap Karssenberg wrote:
> Attached a first stab at such a plugin. Usuable bit still a bit rough.
>
> 1/ need way for user to resize the widget (?)
> 2/ need to make the pageview scroll to the header instead of just highlighting it
>
> Also looking for some input on visual design - is there some way to make
> it look more attractive ?
>

Really usefull plugin!
Is it possible to add a 'header' to the sidepane widgets, when more than
one widget is displayed? That would add some structure and enable an
easy identification of the TOC or index. Now they both look very
similar.
Did you disable the vertical scrollbar on purpose? Actually vscrollbar
is off and the hscrollbar on.

best regards,
 stefan

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

On Sat, Jan 29, 2011 at 1:27 PM, smu <email address hidden> wrote:
> Did you disable the vertical scrollbar on purpose? Actually vscrollbar
> is off and the hscrollbar on.

That would be a typo, intended it the other way around (same as for
index treeview).

-- Jaap

Revision history for this message
smu (smu) wrote :

Hi Jaap,

are your currently working on this?
If not, I made some improvements which may make the plugin more usable:

 - Instead of putting the widget in top of the index panel, I put it in
   a tab behind the index. Otherwise the index becomes very small when
   the calendar widget is placed in the sidepane and with the tab title
   the widgets look better structured.
 - jump to the header in the page is implemented, althrough a bit
   hack.

Diff to the version you posted some weeks ago ist attached.

best regards,
 stefan

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

Attached another proof of concept of a while back (didn't test it with current trunk) which shows the ToC in a floating window on top of the editor. This could better approach the look of the foldable ToC in dokuwiki pages.

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

Attached an updated version - now allows embedding in the side pane as a tab or can be shown as a floating widget on top of the page. Later mode still has a few rough edges, but is usable. Will commit this version to trunk before next release.

Revision history for this message
smu (smu) wrote :

thank you Jaap.

I found a small bug in the 'jump to header' functionality: If the header
contains brackets, the search failes, probably due to the fact that the
brackets are interpreted as regex. Unfortunately I could not figure out
how to search for the 'raw' string. The flag FIND_CASE_SENSITIVE failed
as well.

cheers,
 Stefan

On Fri, Jan 06, 2012 at 01:01:40PM -0000, Jaap Karssenberg wrote:
> Attached an updated version - now allows embedding in the side pane as a
> tab or can be shown as a floating widget on top of the page. Later mode
> still has a few rough edges, but is usable. Will commit this version to
> trunk before next release.
>
> ** Attachment added: "tableofcontents.py"
> https://bugs.launchpad.net/zim/+bug/373280/+attachment/2659899/+files/tableofcontents.py
>
> --
> You received this bug notification because you are subscribed to Zim.
> https://bugs.launchpad.net/bugs/373280
>
> Title:
> Make a Table of Contents from the headings
>
> Status in Zim desktop wiki:
> In Progress
>
> Bug description:
> As Zim supports semantically correct markup, it would be nice if Zim
> could create a Table of Contents at the top of notes to let the user
> quickly navigate to the place he needs. I have a user who uses
> semantically-correct document formatting, and has some very long notes
> that should not be broken up into smaller notes. The Table of Contents
> would be a large help.
>
> Thanks!
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/zim/+bug/373280/+subscriptions
>

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

Thanks for the note - will need to add a "re.escape()" around the
header when creating the regex

(Hope we can merge later with the code for anchors and just refer to
those to locate the headers)

On Fri, Jan 6, 2012 at 4:02 PM, smu <email address hidden> wrote:
> thank you Jaap.
>
> I found a small bug in the 'jump to header' functionality: If the header
> contains brackets, the search failes, probably due to the fact that the
> brackets are interpreted as regex. Unfortunately I could not figure out
> how to search for the 'raw' string. The flag FIND_CASE_SENSITIVE failed
> as well.
>
> cheers,
>  Stefan
>
> On Fri, Jan 06, 2012 at 01:01:40PM -0000, Jaap Karssenberg wrote:
>> Attached an updated version - now allows embedding in the side pane as a
>> tab or can be shown as a floating widget on top of the page. Later mode
>> still has a few rough edges, but is usable. Will commit this version to
>> trunk before next release.
>>
>> ** Attachment added: "tableofcontents.py"
>>    https://bugs.launchpad.net/zim/+bug/373280/+attachment/2659899/+files/tableofcontents.py
>>
>> --
>> You received this bug notification because you are subscribed to Zim.
>> https://bugs.launchpad.net/bugs/373280
>>
>> Title:
>>   Make a Table of Contents from the headings
>>
>> Status in Zim desktop wiki:
>>   In Progress
>>
>> Bug description:
>>   As Zim supports semantically correct markup, it would be nice if Zim
>>   could create a Table of Contents at the top of notes to let the user
>>   quickly navigate to the place he needs. I have a user who uses
>>   semantically-correct document formatting, and has some very long notes
>>   that should not be broken up into smaller notes. The Table of Contents
>>   would be a large help.
>>
>>   Thanks!
>>
>> To manage notifications about this bug go to:
>> https://bugs.launchpad.net/zim/+bug/373280/+subscriptions
>>
>
> --
> You received this bug notification because you are subscribed to Zim.
> https://bugs.launchpad.net/bugs/373280
>
> Title:
>  Make a Table of Contents from the headings
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/zim/+bug/373280/+subscriptions

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

Fix committed in rev470

Changed in zim:
status: In Progress → Fix Committed
Revision history for this message
dotancohen (dotancohen) wrote :

Wow, thanks Jaap! This is the most exciting Zim feature since the checkmarks were implemented! Zim is coming along very nicely and is certainly maturing.

Revision history for this message
Peer Neubert (erklaer-peer) wrote :

Hi, I modified the table of contents plugin to provide more possible locations of the TOC widget: floating, left panel top, left panel as tab, right panel top and right panel as tab. I attached the modified python file (I modified the version from post #12)

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

On Tue, Jan 17, 2012 at 4:50 PM, Peer Neubert <email address hidden> wrote:
> Hi, I modified the table of contents plugin to provide more possible
> locations of the TOC widget: floating, left panel top, left panel as
> tab, right panel top and right panel as tab. I attached the modified
> python file (I modified the version from post #12)

I like the idea, but afraid this patch is to "ad hoc". Would like to
introduce a generic "widget position" preference type that can be used
by all plugins.

-- Jaap

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

Fixed in zim 0.55

Changed in zim:
status: Fix Committed → Fix Released
Revision history for this message
dotancohen (dotancohen) wrote :

Thank you Jaap! This is a great plugin!

After playing with it for some time, it is quite a bit tedious to switch between the ToC and Index views. I installed Peer's version which places the ToC on the side and it is much more comfortable to use. I very much recommend that this approach be taken in the official plugin as well.

Thanks!

Revision history for this message
Michael Nagel (nailor) wrote :

I'd also like to see the TOC and index at the same time in the left pane. It would be great if something like Peers approach could get official!

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.