← Back to team overview

zim-wiki team mailing list archive

Re: Recursive print/export of sub-pages (determined by sub-links)


On 10 August 2012 18:10, NorfCran <norfcran@xxxxxxxxx> wrote:

> On 10 August 2012 16:16, Jaap Karssenberg <jaap.karssenberg@xxxxxxxxx>wrote:
>> OK, after some thinking about it I did a very quick hack to make this
>> work. Figured I could use it as well for my own reporting :)
>> To try it out drop the attached files in the source folder (in zim/
>> and zim/gui/ respectively). There now should be an option in the
>> export dialog "include child pages".
>> This hack does not handle internal links and attachments of sub pages.
>> This would need to be added before merging it in the main branch.
>> Internal links would need support for anchors in the output formats.
> Here is edited html.py from from formats folder, which supports anchors (I
> have done it yesterday and it was not working, but with your present
> improvements it does), thank you!
>> Handling attachments of sub pages needs some refactoring of how the
>> exporter works.
>> Have fun!
>> Jaap
> Good afternoon,
The proposed solution works, but it doesn't keep an order of pages defined
by +relative links, which is quite important for my use case. So there is
attached a custom script, which generates and stores text to clipboard
(preserving wiki syntax) and on demand it also generates table of content
(depending on presence of a page with the same title).

Copy the "export_subpages_to_clipboard.py" to
"/home/username/.local/share/zim/customtools/". Assign an executable flag
to the file.
Create a custom tool with a command:
%n %s
After the button is pushed you get a text in you clipboard, which contains
wiki formatted text including the content of all sub-pages linked through
relative links (+sub-page).
If page title equals to "table of content" or "Table of content", the page
will represent TOC. This may be relevant for an export to HTML (so far it
is still not implemented in html.py), that is going to be a next step.

The output of hierarchically linked pages is illustrated with two

Regards, JK

Attachment: export_subpages_to_clipboard.py
Description: Binary data

Attachment: 20120817 141953_Selection.png
Description: PNG image

Attachment: 20120817 141908_Selection.png
Description: PNG image

Follow ups