RemoveHtmlMarkup() public static method

Removes all HTML tags from a text.
public static RemoveHtmlMarkup ( string html ) : string
html string The input HTML.
return string
Exemplo n.º 1
0
        /// <summary>
        /// Indexes the page.
        /// </summary>
        /// <param name="page">The page page to be intexed.</param>
        /// <returns><c>true</c> if the page has been indexed succesfully, <c>false</c> otherwise.</returns>
        public static bool IndexPage(PageContent page)
        {
            IIndexDirectoryProviderV60 indexDirectoryProvider = Collectors.CollectorsBox.GetIndexDirectoryProvider(page.Provider.CurrentWiki);

            Analyzer    analyzer = new SimpleAnalyzer();
            IndexWriter writer   = new IndexWriter(indexDirectoryProvider.GetDirectory(), analyzer, IndexWriter.MaxFieldLength.UNLIMITED);

            try {
                string[] linkedPages;
                string   contentWithHtml = FormattingPipeline.FormatWithPhase1And2(page.Provider.CurrentWiki, page.Content, true, FormattingContext.PageContent, page.FullName, out linkedPages);
                string   content         = Tools.RemoveHtmlMarkup(contentWithHtml);

                Document doc = new Document();
                doc.Add(new Field(SearchField.Key.AsString(), (DocumentTypeToString(DocumentType.Page) + "|" + page.Provider.CurrentWiki + "|" + page.FullName).Replace(" ", ""), Field.Store.NO, Field.Index.NOT_ANALYZED_NO_NORMS));
                doc.Add(new Field(SearchField.DocumentType.AsString(), DocumentTypeToString(DocumentType.Page), Field.Store.YES, Field.Index.NOT_ANALYZED));
                doc.Add(new Field(SearchField.Wiki.AsString(), page.Provider.CurrentWiki, Field.Store.YES, Field.Index.NOT_ANALYZED));
                doc.Add(new Field(SearchField.PageFullName.AsString(), page.FullName, Field.Store.YES, Field.Index.ANALYZED));
                doc.Add(new Field(SearchField.Title.AsString(), page.Title, Field.Store.YES, Field.Index.ANALYZED));
                doc.Add(new Field(SearchField.Content.AsString(), content, Field.Store.YES, Field.Index.ANALYZED));
                writer.AddDocument(doc);
                writer.Commit();
            }
            finally {
                writer.Dispose();
            }
            return(true);
        }