Permalink
Browse files

Renaming convert_line to convert.

  • Loading branch information...
1 parent f539c2a commit 8cbf5eae73b1925a5d4ffacd6cf2e0002a0f9095 @dongola7 committed Sep 25, 2011
Showing with 28 additions and 28 deletions.
  1. +13 −13 src/textile.tcl
  2. +15 −15 tests/tests.tcl
View
@@ -4,21 +4,21 @@ package provide textile 0.1
namespace eval ::textile { }
-proc ::textile::convert_line {line} {
- if {[regexp -- {^h[1-6]\.} $line]} {
- set line [regsub -- {^h([1-6])\.\s*(.*)} $line {<h\1>\2</h\1>}]
+proc ::textile::convert {text} {
+ if {[regexp -- {^h[1-6]\.} $text]} {
+ set text [regsub -- {^h([1-6])\.\s*(.*)} $text {<h\1>\2</h\1>}]
} else {
- set line "<p>$line</p>"
+ set text "<p>$text</p>"
}
- set line [regsub -- {\n} $line {<br/>}]
+ set text [regsub -- {\n} $text {<br/>}]
- set line [regsub -- {\_(.+)\_} $line {<em>\1</em>}]
- set line [regsub -- {\*(.+)\*} $line {<strong>\1</strong>}]
- set line [regsub -- {\?\?(.+)\?\?} $line {<cite>\1</cite>}]
- set line [regsub -- {\-(.+)\-} $line {<del>\1</del>}]
- set line [regsub -- {\+(.+)\+} $line {<ins>\1</ins>}]
- set line [regsub -- {\^(.+)\^} $line {<sup>\1</sup>}]
- set line [regsub -- {\~(.+)\~} $line {<sub>\1</sub>}]
- set line [regsub -- {\%(.+)\%} $line {<span>\1</span>}]
+ set text [regsub -- {\_(.+)\_} $text {<em>\1</em>}]
+ set text [regsub -- {\*(.+)\*} $text {<strong>\1</strong>}]
+ set text [regsub -- {\?\?(.+)\?\?} $text {<cite>\1</cite>}]
+ set text [regsub -- {\-(.+)\-} $text {<del>\1</del>}]
+ set text [regsub -- {\+(.+)\+} $text {<ins>\1</ins>}]
+ set text [regsub -- {\^(.+)\^} $text {<sup>\1</sup>}]
+ set text [regsub -- {\~(.+)\~} $text {<sub>\1</sub>}]
+ set text [regsub -- {\%(.+)\%} $text {<span>\1</span>}]
}
View
@@ -9,63 +9,63 @@ namespace eval ::textile::test {
namespace import ::tcltest::*
test heading-1 "h1 tag is converted" -body {
- ::textile::convert_line "h1. This is a heading"
+ ::textile::convert "h1. This is a heading"
} -result "<h1>This is a heading</h1>"
test heading-2 "h2 tag is converted" -body {
- ::textile::convert_line "h2. This is a heading"
+ ::textile::convert "h2. This is a heading"
} -result "<h2>This is a heading</h2>"
test heading-10 "h10 tag is not converted" -body {
- ::textile::convert_line "h10. This is a heading"
+ ::textile::convert "h10. This is a heading"
} -result "<p>h10. This is a heading</p>"
test heading-7 "h7 tag is not converted" -body {
- ::textile::convert_line "h7. This is a heading"
+ ::textile::convert "h7. This is a heading"
} -result "<p>h7. This is a heading</p>"
test paragraph "paragraph tag is applied to non-headings" -body {
- ::textile::convert_line "This is a paragraph"
+ ::textile::convert "This is a paragraph"
} -result "<p>This is a paragraph</p>"
test multiline-block-paragraph "paragraph spanning multiple lines" -body {
- ::textile::convert_line "This is a paragraph\nThis is a continuation"
+ ::textile::convert "This is a paragraph\nThis is a continuation"
} -result "<p>This is a paragraph<br/>This is a continuation</p>"
test emphasis "emphasis is applied to _ tag" -body {
- ::textile::convert_line "This is _emphasized_"
+ ::textile::convert "This is _emphasized_"
} -result "<p>This is <em>emphasized</em></p>"
test strong "strong is applied to * tag" -body {
- ::textile::convert_line "This is *strong*"
+ ::textile::convert "This is *strong*"
} -result "<p>This is <strong>strong</strong></p>"
test citation "citation is applied to ?? tag" -body {
- ::textile::convert_line "This is ??cited??"
+ ::textile::convert "This is ??cited??"
} -result "<p>This is <cite>cited</cite></p>"
test deleted-text "strikethrough is applied to - tag" -body {
- ::textile::convert_line "This is -deleted-"
+ ::textile::convert "This is -deleted-"
} -result "<p>This is <del>deleted</del></p>"
test inserted-text "underline is applied to + tag" -body {
- ::textile::convert_line "This is +added+"
+ ::textile::convert "This is +added+"
} -result "<p>This is <ins>added</ins></p>"
test superscript "superscript is applied to ^ tag" -body {
- ::textile::convert_line "This is ^superscript^"
+ ::textile::convert "This is ^superscript^"
} -result "<p>This is <sup>superscript</sup></p>"
test subscript "subscript is applied to ~ tag" -body {
- ::textile::convert_line "This is ~subscript~"
+ ::textile::convert "This is ~subscript~"
} -result "<p>This is <sub>subscript</sub></p>"
test span "span is applied to % tag" -body {
- ::textile::convert_line "This is %spanned%"
+ ::textile::convert "This is %spanned%"
} -result "<p>This is <span>spanned</span></p>"
test emphasis-with-spaces "emphasis is applied to _ tag with spaces" -body {
- ::textile::convert_line "This is _spaced emphasis_"
+ ::textile::convert "This is _spaced emphasis_"
} -result "<p>This is <em>spaced emphasis</em></p>"
cleanupTests

0 comments on commit 8cbf5ea

Please sign in to comment.