Ejemplo n.º 1
0
        public static TextReader GetHtmlReader(Stream stream, string charset, AddLinkCallback link_handler)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            FilterHtml html_filter = new FilterHtml();

            html_filter.SnippetMode = false;
#if ENABLE_RDF_ADAPTER
            html_filter.SetAddLinkHandler(link_handler);
#endif

            html_filter.Indexable = new Indexable();              // fake an indexable
            html_filter.AddProperty(Property.NewUnsearched(StringFu.UnindexedNamespace + "encoding", charset));

            if (!html_filter.Open(stream, false))
            {
                throw new Exception("Cannot open html");
            }

            TextReader pr = html_filter.GetTextReader();
            return(pr);
        }
Ejemplo n.º 2
0
 public void SetAddLinkHandler(AddLinkCallback link_handler)
 {
     if (link_handler != null)
     {
         AddLink = link_handler;
     }
 }
Ejemplo n.º 3
0
        public FilterHtml(bool register_filter)
        {
            if (register_filter)
            {
                base.SetVersion(version);
                SnippetMode = true;
                SetFileType("document");

                AppendText            = new AppendTextCallback(base.AppendText);
                AppendWord            = new AppendTextCallback(base.AppendWord);
                AddProperty           = new AddPropertyCallback(base.AddProperty);
                AppendWhiteSpace      = new AppendSpaceCallback(base.AppendWhiteSpace);
                AppendStructuralBreak = new AppendSpaceCallback(base.AppendStructuralBreak);
                HotUp   = new HotCallback(base.HotUp);
                HotDown = new HotCallback(base.HotDown);
#if ENABLE_RDF_ADAPTER
                AddLink = new AddLinkCallback(base.AddLink);
#endif
            }

            ignore_level  = 0;
            building_text = false;
            builder       = new StringBuilder();
        }
Ejemplo n.º 4
0
		public FilterHtml (bool register_filter)
		{
			if (register_filter) {
				base.SetVersion (version);
				SnippetMode = true;
				SetFileType ("document");

				AppendText = new AppendTextCallback (base.AppendText);
				AppendWord = new AppendTextCallback (base.AppendWord);
				AddProperty = new AddPropertyCallback (base.AddProperty);
				AppendWhiteSpace = new AppendSpaceCallback (base.AppendWhiteSpace);
				AppendStructuralBreak = new AppendSpaceCallback (base.AppendStructuralBreak);
				HotUp = new HotCallback (base.HotUp);
				HotDown = new HotCallback (base.HotDown);
#if ENABLE_RDF_ADAPTER
				AddLink = new AddLinkCallback (base.AddLink);
#endif
			}

			ignore_level = 0;
			building_text = false;
			builder = new StringBuilder ();
		}
Ejemplo n.º 5
0
		public static TextReader GetHtmlReader (Stream stream, string charset, AddLinkCallback link_handler)
		{
			if (stream == null)
				throw new ArgumentNullException ("stream");

			FilterHtml html_filter = new FilterHtml ();
			html_filter.SnippetMode = false;
#if ENABLE_RDF_ADAPTER
			html_filter.SetAddLinkHandler (link_handler);
#endif

			html_filter.Indexable = new Indexable (); // fake an indexable
			html_filter.AddProperty (Property.NewUnsearched (StringFu.              UnindexedNamespace + "encoding", charset));

			if (! html_filter.Open (stream, false))
				throw new Exception ("Cannot open html");

			TextReader pr = html_filter.GetTextReader ();
			return pr;
		}
Ejemplo n.º 6
0
		public void SetAddLinkHandler (AddLinkCallback link_handler)
		{
			if (link_handler != null)
				AddLink = link_handler;
		}