1pub fn extract_body_xml(document_xml: &str) -> String {
3 body_xml(document_xml).to_owned()
4}
5
6pub(crate) fn body_xml(document_xml: &str) -> &str {
7 if let Some(body) = crate::xml_index::unique_inner_xml(document_xml, "w:body") {
8 return body;
9 }
10 let Some(open) = super::scan::find_tag_token_ref(document_xml, "w:body") else {
11 return document_xml;
12 };
13 let start = open.as_ptr() as usize - document_xml.as_ptr() as usize + open.len();
14 let remainder = &document_xml[start..];
15 if let Some(end) = remainder.find("</w:body>") {
16 return &remainder[..end];
17 }
18 let mut cursor = 0;
19 while let Some(offset) = remainder[cursor..].find("</") {
20 let end = cursor + offset;
21 if super::scan::starts_with_ignore_ascii_case(&remainder[end..], "</w:body>") {
22 return &remainder[..end];
23 }
24 cursor = end + 2;
25 }
26 document_xml
27}