private void ProcessHeading(HtmlEnumerator en)
        {
            char level = en.Current[2];

            AlternateProcessHtmlChunks(en, "</h" + level + ">");
            Paragraph p = new Paragraph(elements);
            p.InsertInProperties(
                new ParagraphStyleId() { Val = htmlStyles.GetStyle("heading " + level, false) });

            this.elements.Clear();
            AddParagraph(p);
            AddParagraph(currentParagraph = htmlStyles.Paragraph.NewParagraph());
        }
        private void ProcessTableCaption(HtmlEnumerator en)
        {
            if (!tables.HasContext) return;

            string att = en.StyleAttributes["text-align"];
            if (att == null) att = en.Attributes["align"];

            ProcessHtmlChunks(en, "</caption>");

            var runStyleId = htmlStyles.GetStyle("Subtle Reference", true);
            var legend = new Paragraph(
                    new ParagraphProperties(
                        new ParagraphStyleId() { Val = htmlStyles.GetStyle("caption", false) },
                        new ParagraphMarkRunProperties(
                            new RunStyle() { Val = runStyleId })),
                    new Run(
                        new RunProperties(
                            new RunStyle() { Val = runStyleId }),
                        new FieldChar() { FieldCharType = FieldCharValues.Begin }),
                    new Run(
                        new RunProperties(
                            new RunStyle() { Val = runStyleId }),
                        new FieldCode(" SEQ Tableau \\* ARABIC ") { Space = SpaceProcessingModeValues.Preserve }),
                    new Run(
                        new RunProperties(
                            new RunStyle() { Val = runStyleId }),
                        new FieldChar() { FieldCharType = FieldCharValues.End })
                );
            legend.Append(elements);
            elements.Clear();

            if (att != null)
            {
                JustificationValues? align = ConverterUtility.FormatParagraphAlign(att);
                if (align.HasValue)
                {
                    legend.InsertInProperties(new Justification { Val = align });
                }
            }
            else
            {
                // If no particular alignement has been specified for the legend, we will align the legend
                // relative to the owning table
                TableProperties props = tables.CurrentTable.GetFirstChild<TableProperties>();
                if (props != null)
                {
                    TableJustification justif = props.GetFirstChild<TableJustification>();
                    if (justif != null) legend.InsertInProperties(new Justification { Val = justif.Val.Value.ToJustification() });
                }
            }

            if (this.TableCaptionPosition == CaptionPositionValues.Above)
            {
                this.paragraphs.Insert(this.paragraphs.Count - 1, legend);
            }
            else
            {
                this.paragraphs.Add(legend);
            }

            EnsureCaptionStyle();
        }
        private void ProcessHeading(HtmlEnumerator en)
        {
            char level = en.Current[2];
            string clsName = "heading " + level;

            // ensure style exists or the heading will be displayed as a normal text
            if (!htmlStyles.DoesStyleExists(clsName))
            {
                String normalStyleName = htmlStyles.GetStyle("Normal", StyleValues.Paragraph);
                htmlStyles.AddStyle(clsName, new Style(
                    new StyleName() { Val = clsName },
                    new BasedOn() { Val = normalStyleName },
                    new NextParagraphStyle() { Val = normalStyleName },
                    new UnhideWhenUsed(),
                    new PrimaryStyle(),
                    new StyleParagraphProperties()
                    {
                        KeepNext = new KeepNext(),
                        KeepLines = new KeepLines(),
                        SpacingBetweenLines = new SpacingBetweenLines() { Before = "200", After = "0" },
                        OutlineLevel = new OutlineLevel() { Val = (int)Char.GetNumericValue(level) - 1 /* outline starts at 0 */ }
                    },
                    new StyleRunProperties(PredefinedStyles.ResourceManager.GetString(clsName))
                ) { Type = StyleValues.Paragraph, StyleId = clsName });
            }

            // support also style attributes for heading (in case of theme override)
            List<OpenXmlElement> styleAttributes = new List<OpenXmlElement>();
            htmlStyles.Paragraph.ProcessCommonAttributes(en, styleAttributes);

            AlternateProcessHtmlChunks(en, "</h" + level + ">");
            Paragraph p = new Paragraph(elements);
            p.InsertInProperties(prop =>
                prop.ParagraphStyleId = new ParagraphStyleId() { Val = htmlStyles.GetStyle(clsName, StyleValues.Paragraph) });

            htmlStyles.Paragraph.ApplyTags(p);
            htmlStyles.Paragraph.EndTag("<h" + level + ">");

            this.elements.Clear();
            AddParagraph(p);
            AddParagraph(currentParagraph = htmlStyles.Paragraph.NewParagraph());
        }