(
fontAttrsXml: string,
themeFonts?: { major: string; minor: string }
)
| 127 | } |
| 128 | |
| 129 | function parseFontAttrs( |
| 130 | fontAttrsXml: string, |
| 131 | themeFonts?: { major: string; minor: string } |
| 132 | ): { font?: string; themeFont?: string } { |
| 133 | const asciiLit = /\bw:ascii="([^"]+)"/.exec(fontAttrsXml) |
| 134 | // LibreOffice DOCX files may put a semicolon-separated fallback list in w:ascii — take the first |
| 135 | if (asciiLit) return { font: asciiLit[1].split(';')[0].trim() || asciiLit[1] } |
| 136 | const themeRef = /\bw:asciiTheme="([^"]+)"/.exec(fontAttrsXml) |
| 137 | if (!themeRef) return {} |
| 138 | // Resolve immediately if theme fonts are available, otherwise defer |
| 139 | if (themeFonts) return { font: resolveThemeFont(themeRef[1], themeFonts) } |
| 140 | return { themeFont: themeRef[1] } |
| 141 | } |
| 142 | |
| 143 | function parseDocxStyles( |
| 144 | xml: string, |
no test coverage detected