File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -288,9 +288,11 @@ void Editor_Html2Usfm::close_element_node (const pugi::xml_node& node)
288
288
if (!wla_class.empty ()) {
289
289
const std::string contents = m_word_level_attributes[wla_class];
290
290
m_word_level_attributes.erase (wla_class);
291
- // The vertical bar separates the canonical word from the attribute(s) following it.
292
- current_line.append (" |" );
293
- current_line.append (contents);
291
+ if (!contents.empty ()) {
292
+ // The vertical bar separates the canonical word from the attribute(s) following it.
293
+ current_line.append (" |" );
294
+ current_line.append (contents);
295
+ }
294
296
}
295
297
// Add closing USFM, optionally closing embedded tags in reverse order.
296
298
character_styles = filter::strings::array_diff (character_styles, classes);
Original file line number Diff line number Diff line change @@ -1783,4 +1783,18 @@ TEST_F (usfm_html, word_level_attributes_linking)
1783
1783
}
1784
1784
1785
1785
1786
+ TEST_F (usfm_html, word_level_attributes_removed)
1787
+ {
1788
+ // This tests a situation where the \w ... is removed from the text body,
1789
+ // but the word-level attributes themselves are still in the XML tree.
1790
+ const std::string html = R"( <p class="b-p"><span>A</span><span class="i-w0wla2">B</span></p><p class="b-wordlevelattributes"> </p><p class="b-wla1">C="D"</p>)" ;
1791
+ const std::string usfm = R"( \p A\w B\w*)" ;
1792
+ Editor_Html2Usfm editor_html2usfm;
1793
+ editor_html2usfm.load (html);
1794
+ editor_html2usfm.stylesheet (styles_logic_standard_sheet ());
1795
+ editor_html2usfm.run ();
1796
+ EXPECT_EQ (usfm, editor_html2usfm.get ());
1797
+ }
1798
+
1799
+
1786
1800
#endif
You can’t perform that action at this time.
0 commit comments