File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff 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
252270end
253271
254272=begin
You can’t perform that action at this time.
0 commit comments