In my last post I introduced extended-markup, which is the light-weight markup system used to generate posts in Django-Techblog. I'll cover a few other things it can do in this post.

When the Post model is saved to the database, the extended markup is parsed in to a structure that is basically a dictionary containing a list of chunks, and associated variables. The order that the chunks appear in each section is the same as the order they appear in the markup, unless a chunk variable called priority is defined. This causes the chunks to be sorted in descending order of priority, chunks without a priority value are assigned a default of 100.

Here is an example of two chunks with a priority value assigned:

This appears at the end.

This appears at the top.

So why would you want to assign a priority to a chunk, when you already define the order they appear in the text? It becomes useful when combined with another feature of Django-Techblog – extended-markup can be derived from parent markup.

In this blog there is some markup associated with the blog itself, which specifies the content in the right hand column (and potentially other places). The markup in the post is combined with this to create the final page. By giving a chunk a priority that is greater than the default of 100, the chunk will display at the top of the section, rather than the bottom.

Alternatively the markup for a post could replace the content in a section entirely, by assigning a value to a chunk variable called replace. There is a shortcut for chunk variables that don't need a value assigned to them, {..replace!} has the same effect as {..replace=1}.

Here's an example of using replace in a chunk:

This will blank out the right hand column and go at the top.
Me, as a South Park Character

This is me as a South Park character – it is uncannily accurate!

A useful chunk type, which you should see to the left, is siteimage. This inserts an image that was uploaded via Django admin. A number of parameters are used to specify the image to insert, its dimensions and at what side it is to be floated. Any text in the chunk is used for the image caption.

When the markup is saved, Django-Techblog creates a high-quality antialiased thumbnail with Python Image Library . This makes it easy to tweak the image dimensions if–like me–you are never satisfied with defaults.

Here is the markup used to display the South Park image:

This is me as a South Park character -- it is uncannily accurate!

There are a few more features of extended-markup that I haven't covered here. I probably wont blog about them, but if anyone is interested, feel free to ask me.

This blog post was posted to It's All Geek to Me on Thursday February 26th, 2009 at 8:04PM

Leave a Comment

You can use bbcode in the comment: e.g. [b]This is bold[/b], [url][/url], [code python]import this[/code]
Preview Posting...
Previewing comment, please wait a moment...
Will McGugan

My name is Will McGugan. I am an unabashed geek, an author, a hacker and a Python expert – amongst other things!

You are reading my tech blog. See the homepage for my other blogs.

Search for Posts
Possibly related posts
Popular Tags
Recent Comments
Sir, can you give me full code.?
Trying to implement this code. What are the requirements? Does it need a certain version of PHP, etc? Do I ...
Hi Will Can't seem to run any pyopengl applications on my Win7 64bit setup. Using python 3.3 but keep getting ...
Great work, is it possible to jump to a specified picture?
Thanks for the lesson and library, but: What if I wanted to limit the frames as well? Is it really ...
- The novice on Master time with PyGame
© 2008 Will McGugan.

A technoblog blog, design by Will McGugan