Skip to content

Commit

Permalink
resolves #519 support backslash hard line break for GFM when hard_wra…
Browse files Browse the repository at this point in the history
…p is off
  • Loading branch information
mojavelinux committed Jun 2, 2018
1 parent 0044235 commit b393793
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/kramdown/parser/gfm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ def parse

def update_elements(element)
element.children.map! do |child|
if child.type == :text && @options[:hard_wrap] && child.value =~ /\n/
if child.type == :text && child.value.include?(hard_line_break = "#{@options[:hard_wrap] ? '' : '\\'}\n")
children = []
lines = child.value.split(/\n/, -1)
lines = child.value.split(hard_line_break, -1)
omit_trailing_br = (Kramdown::Element.category(element) == :block && element.children[-1] == child &&
lines[-1].empty?)
lines.each_with_index do |line, index|
Expand Down
3 changes: 3 additions & 0 deletions test/testcases_gfm/hard_line_breaks_off.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
<p>This is just a normal paragraph.<br />
Containing a manual line break above.</p>

<p>It was the best of times,<br />
it was the worst of times.</p>
3 changes: 3 additions & 0 deletions test/testcases_gfm/hard_line_breaks_off.text
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
This is just a normal paragraph.
Containing a manual line break above.

It was the best of times,\
it was the worst of times.

0 comments on commit b393793

Please sign in to comment.