Not logged in. · Lost password · Register
Forum: General Help and Support Syntax and Usage RSS
Tutorial: Fastest way from HTML webpage to DokuWiki on Linux
using xclip and pandoc
zx81roadkill #1
Member for a week · 1 post
Group memberships: Members
Show profile · Link to this post
Subject: Tutorial: Fastest way from HTML webpage to DokuWiki on Linux
I was looking for a way to quickly get interesting parts of a web page formatted to DokuWiki markup.
No menus and headers and footers or sidebars — just a clean selection on the page.

I solved it by translating from HTML to DokuWiki markup in the clipboard using two Linux utilities, xclip and pandoc.

xclip is a command line interface to X11 clipboard, Pandoc is universal markup converter — a work of art from professor of Philosophy John MacFarlane.
It can also convert to MediaWiki, TikiWiki, TWiki, Vimwiki, XWiki and ZimWiki.

xclip and pandoc can use stdin / stdout for piping. Converting the clipboard thus becomes stupid simple. A shell script with a Zenity confirm & verify dialog looks like this…


# Pipe clipboard to pandoc and pipe the DokuWiki markup back to clipboard
xclip -o -selection clipboard | pandoc -f html -t dokuwiki | xclip -selection clipboard

# Save first five non-blank lines from clipboard truncated to one hundred characters in the confirmation dialog
result=$(xclip -o -selection clipboard | tr -s '\n' '\n' | head -n 5 | cut -c -100 )

# Info box with saved preview of clipboard contents
zenity --info --title="HTML to Dokuwiki markup" --text="Clipboard preview: \n\n $result" --width=300 --height=100

To implement; (1) put the above code in a file somewhere in your $PATH such as /home/user/.local/bin and (2) make executable by chmod u+x

Assign this script to a keyboard shortcut, why not Super-M for markup?
On xubuntu:  Keyboard settings -> Application Shortcuts tab -> Add
Enter the full script path /home/user/.local/bin/ and assign the keyboard shortcut.

  • Select the text you want to capture on the page in browser.
  • Right-click and choose “View Selection Source”. Your selection opens up as HTML in the page source.
  • Keyboard ctrl-C to copy, and then..
  • super-M to execute script and convert clipboard to DokuWiki markup.


Last step, create your empty DokuWiki page and ctrl-v paste the markup.


  • Select text in browser
  • Right-click “View selection source”
  • Ctrl-C, copy HTML-selection
  • Super-M, or other keyboard shortcut assigned, to execute script
  • Create empty DokuWiki Page
  • Ctrl-V to paste DokuWiki markup

The workflow is minimal, wikiwiki and smooth, hope you find it just as powerful as I did, let me know if you need any help in getting it to work.
Also shared this on Medium

Pandoc uses an intermediate representation format which produces a flawless conversion with headers, quotes, images and links.

This post was edited 4 times, last on 2019-04-15, 18:06 by zx81roadkill.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Go to forum
This board is powered by the Unclassified NewsBoard software, 20150713-dev, © 2003-2015 by Yves Goergen
Current time: 2019-04-20, 00:53:50 (UTC +02:00)