0

In python there is a markdown extension which highlights code which is codehilite. This extension wraps the snippets in codehilite classes. How can I get a function like this but to only put class='prettyprint' on every snippet without processing with codehilite.

Basically convert every <pre></pre> tag that markdown makes into <pre class='prettyprint'></pre>

Luis Liz
  • 1,939
  • 4
  • 20
  • 31

1 Answers1

1

Why not using str.replace() or 're.subn()'? E.g.:

replaced = markup.replace('<pre>', '<pre class="prettyprint">')

or

replaced = re.subn('(<pre[^>]*)', '\\1 class="prettyprint"', markup)
twil
  • 6,032
  • 1
  • 30
  • 28
  • If you meen Django template then that's not the problem. Just use `render_to_string()` https://docs.djangoproject.com/en/1.5/ref/templates/api/#the-render-to-string-shortcut – twil Jul 18 '13 at 07:31