Ejemplo n.º 1
0
        /// <summary>
        /// Converts FB2 Stanza element into XHTML representation
        /// </summary>
        /// <param name="stanzaItem">item to convert</param>
        /// <param name="stanzaConverterParams"></param>
        /// <returns>XHTML representation</returns>
        public IHTMLItem Convert(StanzaItem stanzaItem, StanzaConverterParamsV3 stanzaConverterParams)
        {
            if (stanzaItem == null)
            {
                throw new ArgumentNullException("stanzaItem");
            }
            var stanzaSection = new Div(HTMLElementType.HTML5);

            if (stanzaItem.Title != null)
            {
                var titleConverter = new TitleConverterV3();
                stanzaSection.Add(titleConverter.Convert(stanzaItem.Title, new TitleConverterParamsV3 { TitleLevel = stanzaConverterParams.Level, Settings = stanzaConverterParams.Settings }));
            }

            if (stanzaItem.SubTitle != null)
            {
                var subtitleConverter = new SubtitleConverterV3();
                stanzaSection.Add(subtitleConverter.Convert(stanzaItem.SubTitle, new SubtitleConverterParamsV3 { Settings = stanzaConverterParams.Settings }));
            }

            foreach (var line in stanzaItem.Lines)
            {
                var vElementConverter = new VElementConverterV3();
                stanzaSection.Add(vElementConverter.Convert(line, new VElementConverterParamsV3 { Settings = stanzaConverterParams.Settings }));
            }

            if (stanzaItem.Lang != null)
            {
                stanzaSection.GlobalAttributes.Language.Value = stanzaItem.Lang;
            }

            SetClassType(stanzaSection, ElementStylesV3.Stanza);
            return stanzaSection;
        }
Ejemplo n.º 2
0
        private List <FB2NotesPageSectionFile> AddV2StyleFbeNotesBody(BodyItem bodyItem)
        {
            List <FB2NotesPageSectionFile> documents = new List <FB2NotesPageSectionFile>();
            string docTitle = bodyItem.Name;

            Logger.Log.DebugFormat("Adding notes section : {0}", docTitle);
            var sectionDocument = new FB2NotesPageSectionFile
            {
                PageTitle            = docTitle,
                FileEPubInternalPath = EPubInternalPath.GetDefaultLocation(DefaultLocations.DefaultTextFolder),
                GuideRole            = GuideTypeEnum.Glossary,
                Content             = new Div(HTMLElementType.HTML5),
                NavigationParent    = null,
                NotPartOfNavigation = true,
                FileName            = BuildSectionFileName()
            };

            if (bodyItem.Title != null)
            {
                var converterSettings = new ConverterOptionsV3
                {
                    CapitalDrop       = false,
                    Images            = _images,
                    MaxSize           = _v3Settings.HTMLFileMaxSize,
                    ReferencesManager = _referencesManager,
                };
                var titleConverter = new TitleConverterV3();
                sectionDocument.Content.Add(titleConverter.Convert(bodyItem.Title,
                                                                   new TitleConverterParamsV3 {
                    Settings = converterSettings, TitleLevel = 1
                }));
            }
            documents.Add(sectionDocument);

            Logger.Log.Debug("Adding sub-sections");
            foreach (var section in bodyItem.Sections)
            {
                documents.AddRange(AddSection(section, sectionDocument));
            }
            return(documents);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Converts FB2 Stanza element into XHTML representation
        /// </summary>
        /// <param name="stanzaItem">item to convert</param>
        /// <param name="stanzaConverterParams"></param>
        /// <returns>XHTML representation</returns>
        public IHTMLItem Convert(StanzaItem stanzaItem, StanzaConverterParamsV3 stanzaConverterParams)
        {
            if (stanzaItem == null)
            {
                throw new ArgumentNullException("stanzaItem");
            }
            var stanzaSection = new Div(HTMLElementType.HTML5);

            if (stanzaItem.Title != null)
            {
                var titleConverter = new TitleConverterV3();
                stanzaSection.Add(titleConverter.Convert(stanzaItem.Title, new TitleConverterParamsV3 {
                    TitleLevel = stanzaConverterParams.Level, Settings = stanzaConverterParams.Settings
                }));
            }

            if (stanzaItem.SubTitle != null)
            {
                var subtitleConverter = new SubtitleConverterV3();
                stanzaSection.Add(subtitleConverter.Convert(stanzaItem.SubTitle, new SubtitleConverterParamsV3 {
                    Settings = stanzaConverterParams.Settings
                }));
            }

            foreach (var line in stanzaItem.Lines)
            {
                var vElementConverter = new VElementConverterV3();
                stanzaSection.Add(vElementConverter.Convert(line, new VElementConverterParamsV3 {
                    Settings = stanzaConverterParams.Settings
                }));
            }

            if (stanzaItem.Lang != null)
            {
                stanzaSection.GlobalAttributes.Language.Value = stanzaItem.Lang;
            }

            SetClassType(stanzaSection, ElementStylesV3.Stanza);
            return(stanzaSection);
        }