diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2012-12-11 02:04:54 -0700 |
|---|---|---|
| committer | Dan Allen <dan.j.allen@gmail.com> | 2012-12-11 02:04:54 -0700 |
| commit | 1ddb79e3b3463d5ed8a6cf13717df0d9764808d3 (patch) | |
| tree | 0651b6af8c9fd27cb9d5f0a96ca210d7c1ed2928 | |
| parent | 2030da2ca07eb4cfe5d96053298d5bdc96eb1a0c (diff) | |
allow quoted text to be at start or end of line
| -rw-r--r-- | lib/asciidoctor/block.rb | 12 | ||||
| -rw-r--r-- | test/text_test.rb | 18 |
2 files changed, 23 insertions, 7 deletions
diff --git a/lib/asciidoctor/block.rb b/lib/asciidoctor/block.rb index 11205b98..03254327 100644 --- a/lib/asciidoctor/block.rb +++ b/lib/asciidoctor/block.rb @@ -307,12 +307,12 @@ class Asciidoctor::Block # "Constrained" quotes, which must be bounded by white space or # common punctuation characters - html.gsub!(/([\s\W])\*([^\*]+)\*([\s\W])/m, '\1<strong>\2</strong>\3') - html.gsub!(/([\s\W])'(.+?)'([\s\W])/m, '\1<em>\2</em>\3') - html.gsub!(/([\s\W])_([^_]+)_([\s\W])/m, '\1<em>\2</em>\3') - html.gsub!(/([\s\W])\+([^\+]+)\+([\s\W])/m, '\1<tt>\2</tt>\3') - html.gsub!(/([\s\W])\^([^\^]+)\^([\s\W])/m, '\1<sup>\2</sup>\3') - html.gsub!(/([\s\W])\~([^\~]+)\~([\s\W])/m, '\1<sub>\2</sub>\3') + html.gsub!(/(^|\s|\W)\*([^\*]+)\*(\s|\W|$)/m, '\1<strong>\2</strong>\3') + html.gsub!(/(^|\s|\W)'(.+?)'(\s|\W|$)/m, '\1<em>\2</em>\3') + html.gsub!(/(^|\s|\W)_([^_]+)_(\s|\W|$)/m, '\1<em>\2</em>\3') + html.gsub!(/(^|\s|\W)\+([^\+]+)\+(\s|\W|$)/m, '\1<tt>\2</tt>\3') + html.gsub!(/(^|\s|\W)\^([^\^]+)\^(\s|\W|$)/m, '\1<sup>\2</sup>\3') + html.gsub!(/(^|\s|\W)\~([^\~]+)\~(\s|\W|$)/m, '\1<sub>\2</sub>\3') html.gsub!(/\\([\{\}\-])/, '\1') html.gsub!(/linkgit:([^\]]+)\[(\d+)\]/, '<a href="\1.html">\1(\2)</a>') diff --git a/test/text_test.rb b/test/text_test.rb index efddb03d..579fedea 100644 --- a/test/text_test.rb +++ b/test/text_test.rb @@ -23,6 +23,22 @@ context "Text" do assert_xpath "//em", render_string("An 'emphatic' no") end + test "emphasized text with escaped single quote" do + assert_xpath "//em[text()=\"Johnny's\"]", render_string("It's 'Johnny\'s' phone") + end + + test "emphasized text at end of line" do + assert_xpath "//em", render_string("This library is 'awesome'") + end + + test "emphasized text at beginning of line" do + assert_xpath "//em", render_string("'drop' it") + end + + test "emphasized text across line" do + assert_xpath "//em", render_string("'check it'") + end + test "unquoted text" do assert_no_match /#/, render_string("An #unquoted# word") end @@ -74,4 +90,4 @@ context "Text" do assert_xpath "//tt", rendered_chars end end -end
\ No newline at end of file +end |
