⎘ Copying markdown from ChatGPT or Gemini to TracWiki using pandoc

Although I lately do various stuff, such as flutter app development, video editing, and even digital marketing, I remain at heart a WordPress plugin developer. And as such, I of course use Trac for project management.

I don’t just use generative AI such as ChatGPT and Gemini for code prototyping, but at all stages of development, starting from analysis and all the way to test generation and even deployment. Very often, especially during the feasibility/analysis stage of product development, I find that an entire answer from our AI overlords is so good, that it can be copied verbatim into a ticket, as part of the analysis.

Chatbots output markdown, but Trac uses TracWiki as its markup format.

pandoc writers

There is no TracWiki writer for pandoc that I know of. Writers are lua scripts that you can use with pandoc to extend its output format capabilities. A writer simply tells pandoc how to output different typographic elements such as paragraph, list, code block, headings, etc.

ChatGPT is capable enough to create a rudimentary TracWiki writer for you, but it’s not perfect. It needs some manual work before it can be called complete. Paragraphs and lists are easy, but writing more complex elements, such as image links, requires some manual work. A fun side-project that I may get to at some time in the future.

ZimWiki ≈ TracWiki

But chatbots only output very basic markdown. A custom writer is not necessary for copying simple markdown from ChatGPT or Gemini to Trac. Instead, you can leverage the fact that the TracWiki markup format is very similar to ZimWiki. And pandoc has a built-in ZimWiki writer. (Incidentally both formats are similar to WikiCreole).

Online tool

There’s two ways to do this. The simplest one is to use the online tool for trying out pandoc:

https://pandoc.org/try

Just copy the markdown and paste it into the tool, select the output format to be zimwiki and click Convert.

Shell

You can also do this on the command line. If you have xclip installed, you can do it with the following one-liner that you can store as an alias:

alias md2trac="xclip -selection clipboard -o | pandoc --from markdown --to zimwiki --no-highlight | xclip -selection clipboard"

Now you can copy the markdown output from ChatGPT, run md2trac, then paste the clipboard contents directly into your Trac ticket or wiki page.

Leave a Reply

Your email address will not be published. Required fields are marked *