Esempio n. 1
0
        public string InitializeTagFormatting(BaseHtmlCleaner.HtmlElement htmlElement, string innerText, out bool callFinalize)
        {
            callFinalize = false;
            switch (htmlElement.StartTag)
            {
            case "<ul":
                //  Adds line break (line should not contain only white
                //  spaces, otherwise it will be removed at next stages).
                return("\\\n" + innerText + "\\\n");

            case "<li":
                return("  * " + innerText);

            case "<pre":
                var indent = "\\  ";
                return(indent + innerText.Replace("\n", "\n" + indent));

            default:
                break;
            }
            return(innerText);
        }
Esempio n. 2
0
        public string InitializeTagFormatting(BaseHtmlCleaner.HtmlElement htmlElement, string innerText, out bool callFinalize)
        {
            callFinalize = false;
            switch (htmlElement.StartTag)
            {
            case "<ul":
                //  Creates list object.
                _list = new List()
                        .SetSymbolIndent(12)
                        .SetListSymbol("\u2022")
                        .SetFont(_font)
                        .SetFontSize(_defaultFontSize);
                callFinalize = true;
                break;

            case "<li":
                //  Creates list item.
                if (_list != null)
                {
                    _listItem    = true;
                    callFinalize = true;
                }
                break;

            case "<pre":
                _preformatted = true;
                _paragraph    = true;
                callFinalize  = true;
                break;

            case "<h1":
                _paragraphType = ParagraphType.H1;
                _paragraph     = true;
                callFinalize   = true;
                break;

            case "<h2":
                _paragraphType = ParagraphType.H2;
                _paragraph     = true;
                callFinalize   = true;
                break;

            case "<h3":
                _paragraphType = ParagraphType.H3;
                _paragraph     = true;
                callFinalize   = true;
                break;

            case "<h4":
                _paragraphType = ParagraphType.H4;
                _paragraph     = true;
                callFinalize   = true;
                break;

            case "<p":
                _paragraphType = ParagraphType.Simple;
                _paragraph     = true;
                callFinalize   = true;
                break;

            case "<a":
                _href          = htmlElement.GetAttribute("href");
                _paragraphType = ParagraphType.Hyperlink;
                _paragraph     = true;
                _hyperlink     = true;
                callFinalize   = true;
                break;

            case "<header":
                _paragraphType = ParagraphType.Header;
                _paragraph     = true;
                callFinalize   = true;
                break;

            case "<time":
                _paragraphType = ParagraphType.Time;
                _paragraph     = true;
                callFinalize   = true;
                break;

            default:
                break;
            }
            //  Text is always returned as is for subsequent parsing.
            //  This type of formatter doesn't touch it!
            return(innerText);
        }