diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-03-20 20:59:28 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-03-20 20:59:28 +0100 |
| commit | 2fa6122a3cfa0e801f4a36b39f50e0bf7d575e4b (patch) | |
| tree | b8de41fec71f78debe97ee9fcdd8dc3be65f9b45 /src | |
| parent | ec87fa55c5909ae85429fc5344469cf284e5f6b3 (diff) | |
fixup! Nearly pretty-print subtitle XML (though not in <Text> nodes).2205-subtitle-formatting
Diffstat (limited to 'src')
| -rw-r--r-- | src/subtitle_asset.cc | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/subtitle_asset.cc b/src/subtitle_asset.cc index de6332e6..bd8bb993 100644 --- a/src/subtitle_asset.cc +++ b/src/subtitle_asset.cc @@ -803,6 +803,8 @@ SubtitleAsset::fix_empty_font_ids () } +namespace { + struct State { int indent; @@ -810,13 +812,19 @@ struct State int disable_formatting; }; +} + static void format_xml_node (xmlpp::Node const* node, State& state) { if (auto text_node = dynamic_cast<const xmlpp::TextNode*>(node)) { - state.xml += text_node->get_content(); + string content = text_node->get_content(); + boost::replace_all(content, "&", "&"); + boost::replace_all(content, "<", "<"); + boost::replace_all(content, ">", ">"); + state.xml += content; } else if (auto element = dynamic_cast<const xmlpp::Element*>(node)) { ++state.indent; |
