5

I have a Python web application (Django, specifically). I'm reading in some data from a Trac database (where the descriptions use wiki formatting) and displaying it as HTML. I considered the markdown module, but realised that Trac wiki formatting and markdown are really quite different. Is there a module for Django, or a Python package that supports the wiki formatting that Trac uses?

Update:

Looks like I was a little hasty with my vote to close - while the other ticket looks similar, my question is more to do with Trac wiki formatting. Thanks to petantik for the link!

Similar question: Where can i get a wiki formatting widget for my django application?

Community
  • 1
  • 1
Nick Bolton
  • 38,276
  • 70
  • 174
  • 242

2 Answers2

5

The below links shows a snippet which imports trac markup and makes a django template filter from it

http://www.djangosnippets.org/snippets/1047/

petantik
  • 1,072
  • 8
  • 12
  • Spot on, thanks. I had to read up on custom template tags (http://docs.djangoproject.com/en/dev/howto/custom-template-tags/), and install trac into my site-packages (on my dev pc), but the snippet works a treat! – Nick Bolton Jan 27 '10 at 01:44
  • Interestingly, this does not add `
    ` tags for new lines where Trac would. All the other formatting works though (bullet points, etc), I wonder why it's not the same for new lines...
    – Nick Bolton Jan 27 '10 at 01:52
  • Solved! The snippet does not add `
    ` because `escape_newlines` is `False` by default on the `generate` function. To fix, alter the code like so -- `return mark_safe(HtmlFormatter(env, context, s).generate(escape_newlines=True))`
    – Nick Bolton Jan 27 '10 at 02:03
  • Ah, that's great news. I learn so much myself from answering questions on here :) – petantik Jan 27 '10 at 11:41
0

I have made a plugin for Django-CMS which support Trac wiki syntax, with macros and everything else you expect from Trac:

https://bitbucket.org/mitar/cmsplugin-markup-tracwiki

Mitar
  • 6,756
  • 5
  • 54
  • 86