I often need to post things to a company wiki (using DokuWiki), but I prefer to write in markdown. The HTML to DW macro I made works fine, but the MD to DW converter seems to do the first line and then stop. Could someone take a look at the macro and tell me what's the issue? In the attached macro, I've put a primer to MD to DW syntax in the first comment.
DW - Convert MD.kmmacros (13.9 KB)
I admit that it's unpolished. The whole macro is a series of clipboard regex searches and finally a paste. Is this bad practice?
The macro cuts selected text, usually a full markdown document, and performs a series of regex search and replaces on the clipboard. For example, to convert an MD H1 to a DW H1
`====== $1 ======\n`
It does this for all other headings then moves on to lists, images, links, etc. and finally pastes the text.
The first line is an H1. It converts that and literally nothing else.
Haven’t had time to take a close look, I’m afraid, but in passing I wondered if you had experimented with MD to DW conversion through a recent version of Pandoc ?
DokuWiki writing is now listed here:
I’ve played around with Pandoc a bit before and definitely recognize the power behind it. It’s on my stack of better solutions. I usually like to build solutions to things that I understand first before moving onto something like a command line utility.
^ is, by default in ICU Regular Expressions, only matched at the start of the text.
If you wish it to match at the start of any line, then you need to turn on multi-line matching mode with (?m). So (?m:^) or (?m)^, either of them should work to match more than the start of the text.
Have you looked at the DokuWiki plugin markdowku? That’s what I installed on our wiki to get some semblance of Markdown syntax. Not brilliant, but closer.
That did the trick, thanks!
I always build my search patterns in TextWrangler which handles regex slightly differently, so moving over to KM causes headaches sometimes.
I’ll be sure to check out that plugin!