Bookmarklet: Convert tab separated fields to Dokuwiki table rows

This article is from 2013 and has been archived. It's old and probably outdated.

When you deal with lots of table data and want to publish them in Dokuwiki, you will either have to replace everything manually or you will need several search and replace shortcuts that will replace all the tab separators to vertical bars: In the beginning of a line, between each field and at the end of a line. Especially when you have to do it quite often (read: more than once), the following bookmarklet might save some time.

To use the bookmarklet, just drag and drop it onto the bookmarks toolbar:

[DW] Tab rows 2 DW%3Bif%20('selectionStart'%20in%20t%20%26%26%20t.selectionStart%20%3C%20t.selectionEnd)%20%7Bvar%20tv%20%3D%20t.value%3Bvar%20tvs%3Dtv.substring(t.selectionStart%2C%20t.selectionEnd)%3Bvar%20tvsn%3Dtvs.replace(%2F(%5B%5Ct%5D)%2Fg%2C%20'%20%7C%20')%3Btvsn%3Dtvsn.replace(%2F(%5E)%2Fgm%2C%20'%7C%20')%3Btvsn%3Dtvsn.replace(%2F(%24)%2Fgm%2C%20'%20%7C')%3Btvsn%3Dtvsn.replace('%7C%20%20%7C'%2C%20'')%3Bt.value%20%3D%20tv.replace(tvs%2C%20tvsn)%3B%7D%3Breturn%20void(0)%3B%7D)(document)%3B)

Usage: Copy the table rows from LibreOffice/OpenOffice Calc or Microsoft Excel (contents will be copied tab-separated), edit the Dokuwiki page and paste the rows into the textarea in the desired location. Select these rows again and click the bookmarklet. That's all!

Tested in Firefox 18.0.1 (Sabayon Linux)

Jan Beilicke

About the author

Long-time IT professional and full-time nerd. Open source enthusiast, advocating security and privacy. Sees the cloud as other people's computers. Find me on Mastodon or Twitter.