public static EnumSet<Tag> toTags(CharacterRun run) {
        EnumSet<Tag> tags = EnumSet.noneOf(Tag.class);
        if (run.isBold()) {
            tags.add(Tag.B);
        }
        if (run.isItalic()) {
            tags.add(Tag.I);
        }
        if (run.isStrikeThrough()) {
            tags.add(Tag.S);
        }
        if (run instanceof XWPFRun) {
            XWPFRun xwpfRun = (XWPFRun) run;
            if (xwpfRun.getUnderline() != UnderlinePatterns.NONE) {
                tags.add(Tag.U);
            }
        } else if (run instanceof org.apache.poi.hwpf.usermodel.CharacterRun) {
            org.apache.poi.hwpf.usermodel.CharacterRun hwpfRun =
                    (org.apache.poi.hwpf.usermodel.CharacterRun) run;
            if (hwpfRun.getUnderlineCode() != 0) {
                tags.add(Tag.U);
            }
        }
        return tags;
    }
Closes all formatting tags.

@param xhtml           handler
@param formattingState current formatting state (stack of open formatting tags)
@throws SAXException pass underlying handler exception
tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-microsoft-module/src/main/java/org/apache/tika/parser/microsoft/FormattingUtils.java