← Back to team overview

zim-wiki team mailing list archive

A makeshift table plugin; breaks undo.

 

Hello!

I have written a make-shift table plugin, that just helps managing tables
made from verbatim text (though images and links are possible, but
currently break the formatting). Basically it looks for a line starting
with {{| and the earliest line afterwards ending with ||} and realigns
table contents in between.

However, I found this extremely difficult to do on the level of the
parsetree and instead extract the source code through
"page.dump(zim.formats.wiki)", modify the source and write it back with
"page.parse(...)".

Sadly though, afterwards Undo is not possible.

Is there some way that I can modify the contents of a page without breaking
Undo?

I have attached the experimental source and a file with example tables for
reference. (Note: High risk of data loss, it's still pretty buggy).

kind regards, Klaus
Content-Type: text/x-zim-wiki
Wiki-Format: zim 0.4

====== TableCopy ======
Created Monday 08 July 2013

{{| lrrl
''               |  Value   Error  Source''
''============== | ======  ======  ===========''
''Volume         |  35 Å³  0.3 Å³  ''[[Copy]]''E''[[quations]]
''Lattice Const. |   30 Å   0.1 Å  ''[[Home]] |}}

	''{{| l|rrl      |  Value   Error  Source''
	''======= | ======  ======  ===========''
	''Volume            |  35 Å³  0.3 Å³  ''[[Copy]]''E''[[quations]]
	''Lattice Const. |   30 Å   0.1 Å  ''[[Home]] ''|}}''

			''{{| ||l|rr||l|      |       Value   Error  Source''
			''============== | ===  ======  ===========''
			[[Table|TableLongerName]]
			''Volume             |       35 Å³  0.3 Å³  ''[[Copy]]''E''[[quations]]
			''Lattice Const. |       30 Å   0.1 Å  ''[[Home]] 
			''|}}''
Hallo Welt 

Attachment: tabletrix.py
Description: Binary data


Follow ups