Skip to content

fix undefined method error when textile ends with a NOTE #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/guides/textile_transformer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def scan_until(regex)
end

def consume_note(css_class)
match = scan_until /(\r?\n){2,}/ # We need at least 2 line breaks but we want to match as many as exist
match = scan_until /((\r?\n){2,}|\z)/ # We need at least 2 line breaks but we want to match as many as exist
note = match.pre_match.gsub(/\n\s*/, " ")
note = RedCloth.new(note, [:lite_mode]).to_html
@output << %{<div class="#{css_class}"><p>#{note}</p></div>\n}
Expand Down
5 changes: 5 additions & 0 deletions spec/textile_transformer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@
%{<p>Another paragraph</p>\n}
end

it "handles NOTE: when it's the last thing on page" do
result = @transformer.transform("h1. foo\n\nHi there.\n\nNOTE: Some note\nmore of *the same* note")
result.should == %{<h1>foo</h1>\n<p>Hi there.</p>\n<div class="note"><p>Some note more of <strong>the same</strong> note</p></div>\n\n}
end

it "does not convert single line breaks to <br>" do
@transformer.transform("This\nhas\nbreaks.").should == "<p>This has breaks.</p>\n"
@transformer.transform("This\nhas\nbreaks.\n\nAnd\nparagraphs.").should == "<p>This has breaks.</p>\n<p>And paragraphs.</p>\n"
Expand Down