Skip to content

Commit 385d0c5

Browse files
authored
Merge pull request #61 from CourseOrchestra/fiddlededee202512190144
fix: Removed leading space after line break
2 parents 4314eab + 6e2439f commit 385d0c5

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

lib/a-od-producer/asciidoctor-od.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,24 @@ def h_subs_variable_set_fields
249249
end
250250
end
251251
end
252+
253+
def h_remove_whitespace_after_line_breaks
254+
# Find all text nodes that immediately follow a text:line-break element
255+
# and remove leading whitespace from them
256+
line_breaks = @pre.xpath("//text:line-break",
257+
'text' => 'urn:oasis:names:tc:opendocument:xmlns:text:1.0')
258+
259+
line_breaks.each do |line_break|
260+
# Get the next sibling node
261+
next_sibling = line_break.next_sibling
262+
263+
# If the next sibling is a text node, remove leading whitespace
264+
if next_sibling && next_sibling.is_a?(Nokogiri::XML::Text)
265+
# Remove leading whitespace (spaces, tabs, newlines) from the beginning of the text
266+
next_sibling.content = next_sibling.content.gsub(/\A\s+/, '')
267+
end
268+
end
269+
end
252270
end
253271

254272
=begin

0 commit comments

Comments
 (0)