On 26-6-2018 22:05, Richard Hipp wrote:
> On 6/26/18, Chad Perrin <c...@apotheon.net> wrote:
>> I see no Markdown formatting option for tickets when visiting the web UI
>> via `fossil serve`:
> Go to /Admin/Tickets and edit the scripts you find there to provide
> support for markdown.  As the scripts already provide support for
> text/plain, text/html, and text/x-fossil-wiki, it should be apparent
> how to enhance them with an extra case for text/markdown.

Rendering the markdown is not quite that easy: all the existing options
use the "wiki" command, supplied with various incantations of the
<verbatim> tag. This doesn't appear to work for markdown.

Browsing the source code suggests there is a separate "markdown"
command, but that returns a list instead of actually rendering HTML,
like the wiki command does.

> Once you get this working, submit your changes for inclusion in the
> SQLite source tree.

After some spelunking in th_language.c, here’s what I got working to
render the markdown. Setting the proper mimetype and including it as an
option is left as an exercise for the reader.

     if {$mutype eq "Markdown"} {
       set md [string trimright $icomment]
       set md [markdown $md]
       set title [lindex $md 0]
       set body [lindex $md 1]
       html "<h2>"
       html $title
       html "</h2>"
       html $body
    } elseif {$mutype eq "Wiki"} {

I’d never written TH1 (or Tcl) before, so it can probably be improved
upon — most notably skipping the <h2> if the title is empty, which will
usually be the case in a ticket — but it seems to work OK.

Martijn Coppoolse
fossil-users mailing list

Reply via email to