Skip to content

Commit 8d3bb21

Browse files
committed
Send the li before content only once
1 parent ffc1dd2 commit 8d3bb21

4 files changed

Lines changed: 6 additions & 3 deletions

File tree

examples/random_content.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ <h1>Random content <small>(with various elements and styles)</small></h1>
6363
Li 2
6464
<ol>
6565
<li>Li 2 - 1</li>
66-
<li>Li 2 - 2</li>
66+
<li>Text that is <b>bold</b> and <i>italic</i> also.</li>
6767
<li>Li 2 - 3</li>
6868
</ol>
6969
</li>

examples/random_content.pdf

261 Bytes
Binary file not shown.

lib/prawn_html/document_renderer.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ def apply_tag_open_styles(element)
106106
end
107107

108108
def prepare_text(content)
109-
text = context.before_content ? ::Oga::HTML::Entities.decode(context.before_content) : ''
109+
before_content = context.before_content
110+
text = before_content ? ::Oga::HTML::Entities.decode(before_content) : ''
110111
return (@last_text = text + content) if context.white_space_pre?
111112

112113
content = content.lstrip if @last_text[-1] == ' ' || @last_tag_open

lib/prawn_html/tags/li.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ def block?
1313
end
1414

1515
def before_content
16-
@counter ? "#{@counter}. " : "#{@symbol} "
16+
return if @before_content_once
17+
18+
@before_content_once = @counter ? "#{@counter}. " : "#{@symbol} "
1719
end
1820

1921
def block_styles

0 commit comments

Comments
 (0)