예제 #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, TitleConverterParamsV3 titleConverterParams)
        {
            if (titleItem == null)
            {
                throw new ArgumentNullException("titleItem");
            }
            _level = titleConverterParams.TitleLevel;
            var title = new Div(HTMLElementType.HTML5);

            foreach (var fb2TextItem in titleItem.TitleData)
            {
                if (fb2TextItem is ParagraphItem)
                {
                    var paragraphStyle     = GetParagraphStyleByLevel(_level);
                    var paragraphConverter = new ParagraphConverterV3();
                    title.Add(paragraphConverter.Convert(fb2TextItem as ParagraphItem,
                                                         new ParagraphConverterParamsV3 {
                        ResultType = paragraphStyle, Settings = titleConverterParams.Settings, StartSection = false
                    }));
                }
                else if (fb2TextItem is EmptyLineItem)
                {
                    var emptyLineConverter = new EmptyLineConverterV3();
                    title.Add(emptyLineConverter.Convert());
                }
                else
                {
                    Debug.WriteLine("invalid type in Title - {0}", fb2TextItem.GetType());
                }
            }
            SetClassType(title, string.Format(ElementStylesV3.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, TitleConverterParamsV3 titleConverterParams)
 {
     if (titleItem == null)
     {
         throw new ArgumentNullException("titleItem");
     }
     _level = titleConverterParams.TitleLevel;
     var title = new Div(HTMLElementType.HTML5);
     foreach (var fb2TextItem in titleItem.TitleData)
     {
         if (fb2TextItem is ParagraphItem)
         {
             var paragraphStyle = GetParagraphStyleByLevel(_level);
             var paragraphConverter = new ParagraphConverterV3();
             title.Add(paragraphConverter.Convert(fb2TextItem as ParagraphItem,
                 new ParagraphConverterParamsV3 { ResultType = paragraphStyle, Settings = titleConverterParams.Settings, StartSection = false }));
         }
         else if (fb2TextItem is EmptyLineItem)
         {
             var emptyLineConverter = new EmptyLineConverterV3();
             title.Add(emptyLineConverter.Convert());
         }
         else
         {
             Debug.WriteLine("invalid type in Title - {0}", fb2TextItem.GetType());
         }
     }
     SetClassType(title, string.Format(ElementStylesV3.TitleItemFormat, _level));
     return title;
 }