djangosnippets.org: Latest snippets tagged with 'markup'https://djangosnippets.org/tags/markup/2009-08-26T20:25:58.654889-05:00Template Filter: Add indentation
2009-08-26T20:25:58.654889-05:00chuck-harmstonhttps://djangosnippets.org/snippets/1702/<p>Template filter to add the given number of tabs to the beginning of each line. Useful for keeping markup pretty, plays well with Markdown.</p>
<p>Usage: </p>
<pre><code>{{ content|indent:"2" }}
{{ content|markdown|indent:"2" }}
</code></pre>
Freely redistributableMarkupField
2009-02-20T15:03:05.284923-06:00jpthttps://djangosnippets.org/snippets/1332/<p>This is a field that allows multiple markup types but also stores the pre-rendered result in the database which offers an advantage over calling one of the render methods each time. Example usage looks like:</p>
<pre><code>class BlogPost(models.Model):
...
post = MarkupField()
</code></pre>
<p>the various extra fields can then be accessed as …</p>
Freely redistributableMedia Wiki With mwlib
2009-01-05T09:33:06.654958-06:00nosrednakramhttps://djangosnippets.org/snippets/1277/<h3>Simple wiki with MediaWiki and Markdown Support</h3>
<p>Once you install the mwlib you can use mwit to convert Mediawiki markup to HTML. I am include the model that uses it to hopefully provide a good example. I maintain a version and only one copy of each wiki entry in the …</p>
Freely redistributableSafing HTML Text Input
2008-12-16T14:40:43.366140-06:00PizzaPantherhttps://djangosnippets.org/snippets/1251/<p>Personally I hate using markdown for text input just so it can be converted into HTML. Markdown languages almost always don't support some thing I want to do; thus, why not just use HTML in the first place. Well because you don't want anybody posting any kind of HTML on …</p>
Freely redistributableMarkupTextField
2008-11-06T09:10:37.060372-06:00myleshttps://djangosnippets.org/snippets/1169/<p>I updated <a href="http://www.djangosnippets.org/snippets/882/">MarkdownTextField</a> to have some choices in markup. It currently support for Markdown, Textile, Plain Text, and Plain HTML. It will add <code>%s_html</code> for the complied HTML and <code>%s_markup_choices</code> for a drop down of markup choices.</p>
<p>Usage:</p>
<pre><code>class MyModel(models.Model):
description = MarkupTextField()
</code></pre>
Freely redistributableTemplate filter implementing the Trac wiki markup language
2008-09-11T16:08:36.502541-05:00simonhttps://djangosnippets.org/snippets/1047/<p>I don't know how robust or secure this is, but it's working for me so far.
</p>
Freely redistributableWiki-like markup for sub templates
2007-09-07T07:58:57.218182-05:00luckystarrhttps://djangosnippets.org/snippets/408/<p>I wanted to have the possibility to use a wiki-like markup style in my flatpages for various purposes (embedding images, quoting, etc.)</p>
<p>After a few dead ends I came up with this, which is quite nice I think.</p>
<blockquote>
<p>It basically takes a named tag, loads the corresponding template, passes in …</p></blockquote>
Freely redistributabletypygmentdown
2007-08-22T21:01:14.853214-05:00ubernostrumhttps://djangosnippets.org/snippets/381/<p>Based heavily on <a href="/snippets/119/">snippet #119</a>, this is an all-in-one function which applies Markdown and typogrify, and adds Pygments highlighting (selected from a class name or by having Pygments guess the language) to any <code><code></code> elements found in the text.</p>
<p>It also adds some niceties for picking up useful arguments …</p>
Freely redistributableMarkup Selection in Admin
2007-08-15T19:54:40.267943-05:00jonathanhttps://djangosnippets.org/snippets/368/<p>This method lets you define your markup language and then processes your entries and puts the HTML output in another field on your database.</p>
<p>I came from a content management system that worked like this and to me it makes sense. Your system doesn't have to process your entry every …</p>
Freely redistributableextending generic_markup.apply_markup
2007-05-22T00:39:13.947893-05:00mandrichttps://djangosnippets.org/snippets/246/<p>I wanted to keep the flexibility of generic_markup but add my own filtering option for apply_markup. So I created app/templatetags/mm_markup.py.</p>
Freely redistributablerender_markup filter, specify the markup filter as a string
2007-04-10T14:25:44.111227-05:00exogenhttps://djangosnippets.org/snippets/170/<p>Ever since django.contrib.markup appeared I've added a <code>markup_lang</code> field to my models where I want to support multiple input formats. This filter lets you pass the filter name as a string (from your model field, for example) and it will call the appropriate filter. I use None when the text …</p>
Freely redistributableMediaWiki Markup
2007-03-28T12:10:36.280779-05:00zeeghttps://djangosnippets.org/snippets/139/<p>This is a copy paste job of mediawiki's syntax parser built in Python. You'll probably have to edit it to fit your needs</p>
<p>MediaWiki-style markup
parse(text) -- returns safe-html from wiki markup
code based off of mediawiki</p>
Freely redistributableGeneric markup converter
2007-03-13T11:35:37.800116-05:00ubernostrumhttps://djangosnippets.org/snippets/104/<p>I'm a big fan of Markdown, and often set up models to automatically apply it to certain fields before saving. But that's not really flexible, because if I then distribute the code someone else might want to use reStructuredText or Textile or whatever, and then they have to hack my …</p>
Freely redistributable