From 2fa6122a3cfa0e801f4a36b39f50e0bf7d575e4b Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 20 Mar 2022 20:59:28 +0100 Subject: fixup! Nearly pretty-print subtitle XML (though not in nodes). --- src/subtitle_asset.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') 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(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(node)) { ++state.indent; -- cgit v1.2.3