Пример #1
0
        /// <summary>
        /// Converts FB2 Title object to XHTML Title
        /// </summary>
        /// <param name="titleItem">title item to convert</param>
        /// <param name="titleConverterParams"></param>
        /// <returns></returns>
        public Div Convert(TitleItem titleItem, TitleConverterParamsV2 titleConverterParams)
        {
            if (titleItem == null)
            {
                throw new ArgumentNullException("titleItem");
            }
            _level = titleConverterParams.TitleLevel;
            var title = new Div(HTMLElementType.XHTML11);

            foreach (var fb2TextItem in titleItem.TitleData)
            {
                if (fb2TextItem is ParagraphItem)
                {
                    var paragraphStyle     = GetParagraphStyleByLevel(_level);
                    var paragraphConverter = new ParagraphConverterV2();
                    title.Add(paragraphConverter.Convert(fb2TextItem as ParagraphItem,
                                                         new ParagraphConverterParamsV2 {
                        ResultType = paragraphStyle, Settings = titleConverterParams.Settings, StartSection = false
                    }));
                }
                else if (fb2TextItem is EmptyLineItem)
                {
                    var emptyLineConverter = new EmptyLineConverterV2();
                    title.Add(emptyLineConverter.Convert());
                }
                else
                {
                    Debug.WriteLine("invalid type in Title - {0}", fb2TextItem.GetType());
                }
            }
            SetClassType(title, string.Format(ElementStylesV2.TitleItemFormat, _level));
            return(title);
        }
Пример #2
0
 /// <summary>
 /// Converts FB2 Title object to XHTML Title 
 /// </summary>
 /// <param name="titleItem">title item to convert</param>
 /// <param name="titleConverterParams"></param>
 /// <returns></returns>
 public Div Convert(TitleItem titleItem,TitleConverterParamsV2 titleConverterParams)
 {
     if (titleItem == null)
     {
         throw new ArgumentNullException("titleItem");
     }
     _level = titleConverterParams.TitleLevel;
     var title = new Div(HTMLElementType.XHTML11);
     foreach (var fb2TextItem in titleItem.TitleData)
     {
         if (fb2TextItem is ParagraphItem)
         {
             var paragraphStyle = GetParagraphStyleByLevel(_level);
             var paragraphConverter = new ParagraphConverterV2();
             title.Add(paragraphConverter.Convert(fb2TextItem as ParagraphItem,
                 new ParagraphConverterParamsV2 { ResultType = paragraphStyle, Settings = titleConverterParams.Settings, StartSection = false}));
         }
         else if (fb2TextItem is EmptyLineItem)
         {
             var emptyLineConverter = new EmptyLineConverterV2();
             title.Add(emptyLineConverter.Convert());
         }
         else
         {
             Debug.WriteLine("invalid type in Title - {0}", fb2TextItem.GetType());
         }
     }
     SetClassType(title, string.Format(ElementStylesV2.TitleItemFormat, _level));
     return title;
 }