Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Add Body Replace Feature #27

merged 3 commits into from

2 participants

Xuan Hu (Sean) Thomas Frössman
Xuan Hu (Sean)

Sometimes we need to replace certain patterns in body.
It can be configurable via config.yaml

The user case for me is:
I use syntaxhighlighter for my wp blog, which I have to add '[python]' and '[/python]' before and after the source code.
But when moving to Octopress, I have to replace them with '{% codeblock lang:python %}' and '{endcodeblock}'

Thomas Frössman


Thomas Frössman thomasf merged commit dcbbe79 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 16, 2012
  1. Xuan Hu (Sean)

    Add body_replace feature

    huxuan authored
  2. Xuan Hu (Sean)

    remove test code

    huxuan authored
  3. Xuan Hu (Sean)

    A typo error

    huxuan authored
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 0 deletions.
  1. +6 −0 config.yaml
  2. +3 −0 
6 config.yaml
@@ -30,3 +30,9 @@ taxonomies:
# Rename taxonomies when writing jekyll output format.
name_mapping: {category: categories, post_tag: tags}
+# Replace certain patterns in body
+# Simply replace the key with its value
+body_replace: {
+# '[python]': '{% codeblock lang:python %}',
+# '[/python]': '{% endcodeblock %}',
3 
@@ -33,6 +33,7 @@
item_type_filter = set(config['item_type_filter'])
item_field_filter = config['item_field_filter']
date_fmt = config['date_format']
+body_replace = config['body_replace']
class ns_tracker_tree_builder(XMLTreeBuilder):
@@ -105,6 +106,8 @@ def gi(q, unicode_wrap=True):
return result
body = gi('content:encoded')
+ for key in body_replace:
+ body = body.replace(key, body_replace[key])
img_srcs = []
if body is not None:
Something went wrong with that request. Please try again.