Skip to content

Commit

Permalink
Add textilize filter for transforming input into HTML via RedCloth, s…
Browse files Browse the repository at this point in the history
…o you can have Textile-formatted attributes other than the page's content (for example, an excerpt)
  • Loading branch information
kmarsh committed Feb 12, 2009
1 parent 9a81255 commit ee65dad
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.textile
Expand Up @@ -306,6 +306,12 @@ Convert an array into a sentence.
becomes

foo, bar, and baz

h3. Textilize

Convert a Textile-formatted string into HTML, formatted via RedCloth

{{ page.excerpt | textilize }}

h3. Include (Tag)

Expand Down
4 changes: 4 additions & 0 deletions lib/jekyll/filters.rb
@@ -1,6 +1,10 @@
module Jekyll

module Filters
def textilize(input)
RedCloth.new(input).to_html
end

def date_to_string(date)
date.strftime("%d %b %Y")
end
Expand Down
4 changes: 4 additions & 0 deletions test/test_filters.rb
Expand Up @@ -10,6 +10,10 @@ def setup
@filter = JekyllFilter.new
end

def test_textilize_with_simple_string
assert_equal "<p>something <strong>really</strong> simple</p>", @filter.textilize("something *really* simple")
end

def test_array_to_sentence_string_with_no_args
assert_equal "", @filter.array_to_sentence_string([])
end
Expand Down

0 comments on commit ee65dad

Please sign in to comment.