import {_XPathResult} from './xpathResult' const WORD_HTML_REGEX = /(class="?Mso|style=(?:"|')[^"]*?\bmso-|w:WordDocument||<\/font>)/ // xPaths for elements that will be removed from the document const unwantedPaths = [ '//o:p', "//span[@style='mso-list:Ignore']", "//span[@style='mso-list: Ignore']", ] // xPaths for elements that needs to be remapped into other tags const mappedPaths = [ "//p[@class='MsoTocHeading']", "//p[@class='MsoTitle']", "//p[@class='MsoToaHeading']", "//p[@class='MsoSubtitle']", "//span[@class='MsoSubtleEmphasis']", "//span[@class='MsoIntenseEmphasis']", ] // Which HTML element(s) to map the elements matching mappedPaths into const elementMap: Record = { MsoTocHeading: ['h3'], MsoTitle: ['h1'], MsoToaHeading: ['h2'], MsoSubtitle: ['h5'], MsoSubtleEmphasis: ['span', 'em'], MsoIntenseEmphasis: ['span', 'em', 'strong'], // Remove cruft } function isWordHtml(html: string) { return WORD_HTML_REGEX.test(html) } /** * Extract @list CSS definitions from the document's