/// <summary>
        /// Converts FB2 annotation element
        /// </summary>
        /// <param name="annotationItem">item to convert</param>
        /// <param name="converterParams"></param>
        /// <returns>XHTML representation</returns>
        public HTMLItem Convert(AnnotationType annotationItem, AnnotationConverterParamsV3 converterParams)
        {
            if (annotationItem == null)
            {
                throw new ArgumentNullException("annotationItem");
            }
            var resAnnotation = new Div(HTMLElementType.HTML5);

            foreach (var element in annotationItem.Content)
            {
                if (element is SubTitleItem)
                {
                    var subtitleConverter = new SubtitleConverterV3();
                    resAnnotation.Add(subtitleConverter.Convert(element as SubTitleItem,
                        new SubtitleConverterParamsV3 { Settings = converterParams.Settings }));
                }
                else if (element is ParagraphItem)
                {
                    var paragraphConverter = new ParagraphConverterV3();
                    resAnnotation.Add(paragraphConverter.Convert(element as ParagraphItem,
                        new ParagraphConverterParamsV3 { Settings = converterParams.Settings, ResultType = ParagraphConvTargetEnumV3.Paragraph, StartSection = false }));
                }
                else if (element is PoemItem)
                {
                    var poemConverter = new PoemConverterV3();
                    resAnnotation.Add(poemConverter.Convert(element as PoemItem,
                        new PoemConverterParamsV3 { Level = converterParams.Level + 1, Settings = converterParams.Settings }));
                }
                else if (element is CiteItem)
                {
                    var citationConverter = new CitationConverterV3();
                    resAnnotation.Add(citationConverter.Convert(element as CiteItem,
                        new CitationConverterParamsV3 { Level = converterParams.Level + 1, Settings = converterParams.Settings }));
                }
                else if (element is TableItem)
                {
                    var tableConverter = new TableConverterV3();
                    resAnnotation.Add(tableConverter.Convert(element as TableItem,
                        new TableConverterParamsV3 { Settings = converterParams.Settings }
                        ));
                }
                else if (element is EmptyLineItem)
                {
                    var emptyLineConverter = new EmptyLineConverterV3();
                    resAnnotation.Add(emptyLineConverter.Convert());
                }
            }

            resAnnotation.GlobalAttributes.ID.Value = converterParams.Settings.ReferencesManager.AddIdUsed(annotationItem.ID, resAnnotation);

            SetClassType(resAnnotation, ElementStylesV3.Annotation);
            return resAnnotation;
        }
 private ulong ConvertSimpleSubItem(IFb2TextItem item, SectionItem sectionItem, Div content, List<IHTMLItem> resList, ref bool startSection, ulong documentSize)
 {
     ulong docSize = documentSize;
     IHTMLItem newItem = null;
     var subtitleItem = item as SubTitleItem;
     if (subtitleItem != null)
     {
         var subtitleConverter = new SubtitleConverterV3();
         newItem = subtitleConverter.Convert(subtitleItem, new SubtitleConverterParamsV3 { Settings = Settings });
     }
     else if (item is ParagraphItem)
     {
         var paragraphConverter = new ParagraphConverterV3();
         newItem = paragraphConverter.Convert((ParagraphItem) item,
             new ParagraphConverterParamsV3 { ResultType = ParagraphConvTargetEnumV3.Paragraph, StartSection = startSection, Settings = Settings });
         startSection = false;
     }
     else if (item is PoemItem)
     {
         var poemConverter = new PoemConverterV3();
         newItem = poemConverter.Convert((PoemItem) item,
             new PoemConverterParamsV3 { Settings = Settings, Level = RecursionLevel + 1 });
     }
     else if (item is CiteItem)
     {
         var citationConverter = new CitationConverterV3();
         newItem = citationConverter.Convert((CiteItem) item,
             new CitationConverterParamsV3 { Level = RecursionLevel + 1, Settings = Settings });
     }
     else if (item is EmptyLineItem)
     {
         var emptyLineConverter = new EmptyLineConverterV3();
         newItem = emptyLineConverter.Convert();
     }
     else if (item is TableItem)
     {
         var tableConverter = new TableConverterV3();
         newItem = tableConverter.Convert((TableItem) item,
             new TableConverterParamsV3 { Settings = Settings });
     }
     else if ((item is ImageItem) && Settings.Images.HasRealImages())
     {
         var fb2Img = item as ImageItem;
         // if it's not section image and it's used
         if ((sectionItem.SectionImages.Find(x => x == fb2Img) == null) && (fb2Img.HRef != null))
         {
             if (Settings.Images.IsImageIdReal(fb2Img.HRef))
             {
                 var enclosing = new Div(HTMLElementType.HTML5); // we use the enclosing so the user can style center it
                 var imageConverter = new ImageConverterV3();
                 enclosing.Add(imageConverter.Convert(fb2Img, new ImageConverterParamsV3 { Settings = Settings }));
                 SetClassType(enclosing, ElementStylesV3.NormalImage);
                 newItem = enclosing;
             }
         }
     }
     if (newItem != null)
     {
         docSize = SplitBlockHTMLItem(newItem, content, resList, docSize);
     }
     return docSize;
 }
        /// <summary>
        /// Converts FB2 annotation element
        /// </summary>
        /// <param name="annotationItem">item to convert</param>
        /// <param name="converterParams"></param>
        /// <returns>XHTML representation</returns>
        public HTMLItem Convert(AnnotationType annotationItem, AnnotationConverterParamsV3 converterParams)
        {
            if (annotationItem == null)
            {
                throw new ArgumentNullException("annotationItem");
            }
            var resAnnotation = new Div(HTMLElementType.HTML5);

            foreach (var element in annotationItem.Content)
            {
                if (element is SubTitleItem)
                {
                    var subtitleConverter = new SubtitleConverterV3();
                    resAnnotation.Add(subtitleConverter.Convert(element as SubTitleItem,
                                                                new SubtitleConverterParamsV3 {
                        Settings = converterParams.Settings
                    }));
                }
                else if (element is ParagraphItem)
                {
                    var paragraphConverter = new ParagraphConverterV3();
                    resAnnotation.Add(paragraphConverter.Convert(element as ParagraphItem,
                                                                 new ParagraphConverterParamsV3 {
                        Settings = converterParams.Settings, ResultType = ParagraphConvTargetEnumV3.Paragraph, StartSection = false
                    }));
                }
                else if (element is PoemItem)
                {
                    var poemConverter = new PoemConverterV3();
                    resAnnotation.Add(poemConverter.Convert(element as PoemItem,
                                                            new PoemConverterParamsV3 {
                        Level = converterParams.Level + 1, Settings = converterParams.Settings
                    }));
                }
                else if (element is CiteItem)
                {
                    var citationConverter = new CitationConverterV3();
                    resAnnotation.Add(citationConverter.Convert(element as CiteItem,
                                                                new CitationConverterParamsV3 {
                        Level = converterParams.Level + 1, Settings = converterParams.Settings
                    }));
                }
                else if (element is TableItem)
                {
                    var tableConverter = new TableConverterV3();
                    resAnnotation.Add(tableConverter.Convert(element as TableItem,
                                                             new TableConverterParamsV3 {
                        Settings = converterParams.Settings
                    }
                                                             ));
                }
                else if (element is EmptyLineItem)
                {
                    var emptyLineConverter = new EmptyLineConverterV3();
                    resAnnotation.Add(emptyLineConverter.Convert());
                }
            }

            resAnnotation.GlobalAttributes.ID.Value = converterParams.Settings.ReferencesManager.AddIdUsed(annotationItem.ID, resAnnotation);

            SetClassType(resAnnotation, ElementStylesV3.Annotation);
            return(resAnnotation);
        }
        private ulong ConvertSimpleSubItem(IFb2TextItem item, SectionItem sectionItem, Div content, List <IHTMLItem> resList, ref bool startSection, ulong documentSize)
        {
            ulong     docSize      = documentSize;
            IHTMLItem newItem      = null;
            var       subtitleItem = item as SubTitleItem;

            if (subtitleItem != null)
            {
                var subtitleConverter = new SubtitleConverterV3();
                newItem = subtitleConverter.Convert(subtitleItem, new SubtitleConverterParamsV3 {
                    Settings = Settings
                });
            }
            else if (item is ParagraphItem)
            {
                var paragraphConverter = new ParagraphConverterV3();
                newItem = paragraphConverter.Convert((ParagraphItem)item,
                                                     new ParagraphConverterParamsV3 {
                    ResultType = ParagraphConvTargetEnumV3.Paragraph, StartSection = startSection, Settings = Settings
                });
                startSection = false;
            }
            else if (item is PoemItem)
            {
                var poemConverter = new PoemConverterV3();
                newItem = poemConverter.Convert((PoemItem)item,
                                                new PoemConverterParamsV3 {
                    Settings = Settings, Level = RecursionLevel + 1
                });
            }
            else if (item is CiteItem)
            {
                var citationConverter = new CitationConverterV3();
                newItem = citationConverter.Convert((CiteItem)item,
                                                    new CitationConverterParamsV3 {
                    Level = RecursionLevel + 1, Settings = Settings
                });
            }
            else if (item is EmptyLineItem)
            {
                var emptyLineConverter = new EmptyLineConverterV3();
                newItem = emptyLineConverter.Convert();
            }
            else if (item is TableItem)
            {
                var tableConverter = new TableConverterV3();
                newItem = tableConverter.Convert((TableItem)item,
                                                 new TableConverterParamsV3 {
                    Settings = Settings
                });
            }
            else if ((item is ImageItem) && Settings.Images.HasRealImages())
            {
                var fb2Img = item as ImageItem;
                // if it's not section image and it's used
                if ((sectionItem.SectionImages.Find(x => x == fb2Img) == null) && (fb2Img.HRef != null))
                {
                    if (Settings.Images.IsImageIdReal(fb2Img.HRef))
                    {
                        var enclosing      = new Div(HTMLElementType.HTML5); // we use the enclosing so the user can style center it
                        var imageConverter = new ImageConverterV3();
                        enclosing.Add(imageConverter.Convert(fb2Img, new ImageConverterParamsV3 {
                            Settings = Settings
                        }));
                        SetClassType(enclosing, ElementStylesV3.NormalImage);
                        newItem = enclosing;
                    }
                }
            }
            if (newItem != null)
            {
                docSize = SplitBlockHTMLItem(newItem, content, resList, docSize);
            }
            return(docSize);
        }