djangosnippets.org: Latest snippets tagged with 'syntax'https://djangosnippets.org/tags/syntax/2010-11-29T14:49:27-06:00Prettify HTML body contents in HTTP response2010-11-29T14:49:27-06:00n1k0https://djangosnippets.org/snippets/2279/<p>This is an enhancement of snippet <a href="http://djangosnippets.org/snippets/172/">#172</a>. Here I use <a href="http://www.crummy.com/software/BeautifulSoup/">BeautifulSoup</a> — far more easier to install through pip in a virtualenv, and possibly a bit more maintained — to format and properly indent the rendered HTML from templates. </p>
<p>I also added a check to only tidy contents in a <code>DEBUG=True ...</code></p>
Freely redistributablePygments Syntax highlighting template tag2008-11-24T09:42:06-06:00girasquidhttps://djangosnippets.org/snippets/1213/<p>This template tag will attempt to apply pygments syntax highlighting to anything inside {% code %} and {% endcode %} tags. You can optionally pass in the language to highlight in the form of {% code 'lang' %} - if you don't, it will first try to guess the syntax, and then fall back to Python ...</p>
Freely redistributableCode syntax highlighting templatetag2007-09-15T14:42:55-05:00badrunnerhttps://djangosnippets.org/snippets/416/<p>Replaces &lt;code&gt; blocks with syntax highlighted code. Use CSS to actually get the colours you want, look at pygments documentation for extracting css for various styles.</p>
<p>This snippet has the advantage of falling back on &lt;pre&gt; if anything goes wrong, and attempting to guess the syntax of code, falling back ...</p>
Freely redistributable