コード例 #1
0
        public NumericTextbox(string name, NumericTheme theme = null, HtmlParsingMode parsingMode = HtmlParsingMode.Auto, HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default,
                              DocType docType = DocType.Default)
            : base(HtmlTag.Div, parsingMode, parsingOptions, docType)
        {
            if (theme == null)
            {
                theme = DefaultTheme;
            }
            Target = name.StartsWith("#") ? name : "#" + name;
            Attr("data-toggle", "numeric");
            AddClass(theme.Wrapper);
            _displayInput = new TextBox();
            Append(_displayInput.AddClass(theme.Input));
            _valueInput = new HiddenField {
                Name = name, Id = name
            };
            Append(_valueInput);

            _increaseButton = new Button();
            _increaseIcon   = new CommonElement(HtmlTag.I);
            _increaseButton.AddClass(theme.IncreaseButton).Append(_increaseIcon.AddClass(theme.IncreaseIcon));

            _decreaseButton = new Button();
            _decreaseIcon   = new CommonElement(HtmlTag.I);
            _decreaseButton.AddClass(theme.DecreaseButton).Append(_decreaseIcon.AddClass(theme.DecreaseIcon));

            _addon = new CommonElement(HtmlTag.Span);
            _addon.AddClass(theme.Addon).Append(_increaseButton).Append(_decreaseButton);
            Append(_addon);
        }
コード例 #2
0
ファイル: ElementFactory.cs プロジェクト: TheX/CsQuery
        /// <summary>
        /// Creates a new document from a Stream of HTML using the options passed.
        /// </summary>
        ///
        /// <param name="html">
        /// The HTML input.
        /// </param>
        /// <param name="parsingMode">
        /// (optional) the parsing mode.
        /// </param>
        /// <param name="parsingOptions">
        /// (optional) options for controlling the parsing.
        /// </param>
        /// <param name="docType">
        /// (optional) type of the document.
        /// </param>
        ///
        /// <returns>
        /// A new document.
        /// </returns>

        public static IDomDocument Create(TextReader html, 
            HtmlParsingMode parsingMode = HtmlParsingMode.Auto,
            HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default,
            DocType docType = DocType.Default)
        {
            return GetNewParser(parsingMode, parsingOptions, docType).Parse(html);
        }
コード例 #3
0
ファイル: ElementFactory.cs プロジェクト: Vitallium/CsQuery
 public static IDomDocument Create(Stream html, HtmlParsingMode mode = HtmlParsingMode.Content)
 {
     using (var reader = new StreamReader(html))
     {
         return Parser.Parse(reader, mode);
     }
 }
コード例 #4
0
ファイル: Create.cs プロジェクト: asmboom/HtmlRenderer
        /// <summary>
        /// Create a new CQ object from a TextReader containg HTML
        /// </summary>
        ///
        /// <param name="html">
        /// A string of HTML.
        /// </param>
        /// <param name="parsingMode">
        /// (optional) the mode.
        /// </param>
        /// <param name="parsingOptions">
        /// (optional) options for controlling the parsing.
        /// </param>
        /// <param name="docType">
        /// (optional) type of the document.
        /// </param>
        ///
        /// <returns>
        /// The new fragment.
        /// </returns>

        public static CQ Create(TextReader html,
                                HtmlParsingMode parsingMode       = HtmlParsingMode.Auto,
                                HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default,
                                DocType docType = DocType.Default)
        {
            return(new CQ(html, parsingMode, parsingOptions, docType));
        }
コード例 #5
0
 public DataGrid(string name, string href, bool autoGenerateColumns = true, bool hasFooter = true,
                 IEnumerable <int> pageSizes = null, GridTheme theme = null,
                 HtmlParsingMode parsingMode = HtmlParsingMode.Auto, HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default, DocType docType = DocType.Default)
     : base(parsingMode, parsingOptions, docType)
 {
     Initialize(name, href, autoGenerateColumns, hasFooter, pageSizes, theme);
 }
コード例 #6
0
ファイル: PreMailer.cs プロジェクト: granstel/PreMailer.Net
	    /// <summary>
	    /// Constructor for the PreMailer class
	    /// </summary>
	    /// <param name="html">The HTML input.</param>
        /// <param name="parsingMode">(optional) the mode.</param>
	    public PreMailer(string html,HtmlParsingMode parsingMode)
		{
            _document = CQ.Create(html, parsingMode);
			_warnings = new List<string>();
			_cssParser = new CssParser();
			_cssSelectorParser = new CssSelectorParser();
		}
コード例 #7
0
 public GridCommand(string href, HtmlParsingMode parsingMode = HtmlParsingMode.Auto, HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default, DocType docType = DocType.Default)
     : base(href, parsingMode, parsingOptions, docType)
 {
     Attr("data-command-type", "default");
     _icon = new CommonElement(HtmlTag.I);
     Append(_icon);
 }
コード例 #8
0
 /// <summary>
 /// Constructor for the PreMailer class
 /// </summary>
 /// <param name="html">The HTML input.</param>
 /// <param name="parsingMode">(optional) the mode.</param>
 public PreMailer(string html, HtmlParsingMode parsingMode)
 {
     _document          = CQ.Create(html, parsingMode);
     _warnings          = new List <string>();
     _cssParser         = new CssParser();
     _cssSelectorParser = new CssSelectorParser();
 }
コード例 #9
0
 public Combobox(string name, HtmlParsingMode parsingMode = HtmlParsingMode.Auto, HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default, DocType docType = DocType.Default)
     : base(parsingMode, parsingOptions, docType)
 {
     Attr("data-toggle", "select");
     Id   = name;
     Name = name;
 }
コード例 #10
0
        /// <summary>
        /// Bind this instance to a new DomDocument created from HTML using the specified parsing mode.
        /// </summary>
        ///
        /// <param name="html">
        /// The HTML.
        /// </param>
        /// <param name="htmlParsingMode">
        /// The HTML parsing mode.
        /// </param>

        protected void CreateNewDocument(char[] html, HtmlParsingMode htmlParsingMode)
        {
            Document = new DomDocument(html, htmlParsingMode);
            HtmlElementFactory.ReorganizeStrandedTextNodes(Document);
            AddSelection(Document.ChildNodes);
            FinishCreatingNewDocument();
        }
コード例 #11
0
ファイル: ElementFactory.cs プロジェクト: mermich/CsQuery
  private static ElementFactory GetNewParser(HtmlParsingMode parsingMode, HtmlParsingOptions parsingOptions, DocType docType)
  {
      var parser = new ElementFactory();
      parser.HtmlParsingMode = parsingMode;
      parser.DocType = GetDocType(docType);
      parser.HtmlParsingOptions = MergeOptions(parsingOptions);
      return parser;
 }
コード例 #12
0
ファイル: _Constructors.cs プロジェクト: jeiea/osuDownloader
        /// <summary>
        /// Create a new CQ object from an HTML stream.
        /// <see cref="CQ.Create(char[])"/>
        /// </summary>
        ///
        /// <param name="html">
        /// The html source of the new document.
        /// </param>
        /// <param name="encoding">
        /// The character set encoding.
        /// </param>
        /// <param name="parsingMode">
        /// The HTML parsing mode.
        /// </param>
        /// <param name="parsingOptions">
        /// (optional) options for controlling the parsing.
        /// </param>
        /// <param name="docType">
        /// (optional) type of the document.
        /// </param>

        public CQ(Stream html,
                  Encoding encoding,
                  HtmlParsingMode parsingMode       = HtmlParsingMode.Auto,
                  HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default,
                  DocType docType = DocType.Default)
        {
            CreateNew(this, html, encoding, parsingMode, parsingOptions, docType);
        }
コード例 #13
0
        /// <summary>
        /// Creates a new DomDocument (or derived) object.
        /// </summary>
        ///
        /// <param name="html">
        /// The HTML source for the document.
        /// </param>
        /// <param name="encoding">
        /// (optional) the character set encoding.
        /// </param>
        /// <param name="parsingMode">
        /// (optional) the HTML parsing mode.
        /// </param>
        /// <param name="parsingOptions">
        /// (optional) options for controlling the parsing.
        /// </param>
        /// <param name="docType">
        /// The DocType for this document.
        /// </param>
        ///
        /// <returns>
        /// A new IDomDocument object.
        /// </returns>

        public static IDomDocument Create(Stream html,
                                          Encoding encoding                 = null,
                                          HtmlParsingMode parsingMode       = HtmlParsingMode.Content,
                                          HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default,
                                          DocType docType = DocType.Default)
        {
            return(ElementFactory.Create(html, encoding, parsingMode, parsingOptions, docType));
        }
コード例 #14
0
ファイル: Create.cs プロジェクト: asmboom/HtmlRenderer
        /// <summary>
        /// Create a new CQ object from a stream of HTML, treating the HTML as a content document.
        /// </summary>
        ///
        /// <param name="html">
        /// An open Stream.
        /// </param>
        /// <param name="encoding">
        /// The character set encoding.
        /// </param>
        /// <param name="parsingMode">
        /// (optional) the mode.
        /// </param>
        /// <param name="parsingOptions">
        /// (optional) options for controlling the parsing.
        /// </param>
        /// <param name="docType">
        /// (optional) type of the document.
        /// </param>
        ///
        /// <returns>
        /// A new CQ object.
        /// </returns>

        public static CQ Create(Stream html,
                                Encoding encoding                 = null,
                                HtmlParsingMode parsingMode       = HtmlParsingMode.Auto,
                                HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default,
                                DocType docType = DocType.Default)
        {
            return(new CQ(html, encoding, parsingMode, parsingOptions, docType));
        }
コード例 #15
0
        /// <summary>
        /// Creates a new document from a Stream of HTML using the options passed.
        /// </summary>
        ///
        /// <param name="html">
        /// The HTML input.
        /// </param>
        /// <param name="streamEncoding">
        /// The character set encoding used by the stream. If null, the BOM will be inspected, and it
        /// will default to UTF8 if no encoding can be identified.
        /// </param>
        /// <param name="parsingMode">
        /// (optional) the parsing mode.
        /// </param>
        /// <param name="parsingOptions">
        /// (optional) options for controlling the parsing.
        /// </param>
        /// <param name="docType">
        /// (optional) type of the document.
        /// </param>
        ///
        /// <returns>
        /// A new document.
        /// </returns>

        public static IDomDocument Create(Stream html,
                                          Encoding streamEncoding,
                                          HtmlParsingMode parsingMode       = HtmlParsingMode.Auto,
                                          HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default,
                                          DocType docType = DocType.Default)
        {
            return(GetNewParser(parsingMode, parsingOptions, docType)
                   .Parse(html, streamEncoding));
        }
コード例 #16
0
        private static ElementFactory GetNewParser(HtmlParsingMode parsingMode, HtmlParsingOptions parsingOptions, DocType docType)
        {
            var parser = new ElementFactory();

            parser.HtmlParsingMode    = parsingMode;
            parser.DocType            = GetDocType(docType);
            parser.HtmlParsingOptions = MergeOptions(parsingOptions);
            return(parser);
        }
コード例 #17
0
ファイル: DomDocHelper.cs プロジェクト: prepare/HTML-Renderer
        /// <summary>
        /// Creates a new DomDocument (or derived) object.
        /// </summary>
        ///
        /// <param name="html">
        /// The HTML source for the document.
        /// </param>
        /// <param name="encoding">
        /// (optional) the character set encoding.
        /// </param>
        /// <param name="parsingMode">
        /// (optional) the HTML parsing mode.
        /// </param>
        /// <param name="parsingOptions">
        /// (optional) options for controlling the parsing.
        /// </param>
        /// <param name="docType">
        /// The DocType for this document.
        /// </param>
        ///
        /// <returns>
        /// A new IDomDocument object.
        /// </returns>
        public static IDomDocument Create(Stream html,
            Encoding encoding = null,
            HtmlParsingMode parsingMode = HtmlParsingMode.Content,
            HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default,
            DocType docType = DocType.Default)
        {

            return ElementFactory.Create(html, encoding, parsingMode, parsingOptions, docType);
        }
コード例 #18
0
ファイル: _Constructors.cs プロジェクト: TheX/CsQuery
        /// <summary>
        /// Create a new CQ object from an HTML stream.
        /// <see cref="CQ.Create(char[])"/>
        /// </summary>
        ///
        /// <param name="html">
        /// The html source of the new document.
        /// </param>
        /// <param name="parsingMode">
        /// The HTML parsing mode.
        /// </param>
        /// <param name="parsingOptions">
        /// (optional) options for controlling the parsing.
        /// </param>
        /// <param name="docType">
        /// (optional) type of the document.
        /// </param>

        public CQ(Stream html, 
            HtmlParsingMode parsingMode = HtmlParsingMode.Auto, 
            HtmlParsingOptions parsingOptions =HtmlParsingOptions.Default,
            DocType docType = DocType.Default)
        {
            using (var reader = new StreamReader(html))
            {
                CreateNew(this, reader, parsingMode, parsingOptions, docType);
            }
        }
コード例 #19
0
        /// <summary>
        /// Bind this instance to a new DomFragment created from HTML using the specified parsing mode.
        /// </summary>
        ///
        /// <param name="html">
        /// The HTML.
        /// </param>
        /// <param name="htmlParsingMode">
        /// The HTML parsing mode.
        /// </param>

        protected void CreateNewFragment(char[] html, HtmlParsingMode htmlParsingMode)
        {
            Document = new DomFragment(html, htmlParsingMode);

            //  enumerate ChildNodes when creating a new fragment to be sure the selection set only
            //  reflects the original document.

            SetSelection(Document.ChildNodes.ToList(), SelectionSetOrder.Ascending);
            FinishCreatingNewDocument();
        }
コード例 #20
0
ファイル: _Constructors.cs プロジェクト: emrahoner/CsQuery
        /// <summary>
        /// Create a new CQ object from an HTML stream.
        /// <see cref="CQ.Create(char[])"/>
        /// </summary>
        ///
        /// <param name="html">
        /// The html source of the new document.
        /// </param>
        /// <param name="encoding">
        /// The character set encoding.
        /// </param>
        /// <param name="parsingMode">
        /// The HTML parsing mode.
        /// </param>
        /// <param name="parsingOptions">
        /// (optional) options for controlling the parsing.
        /// </param>
        /// <param name="docType">
        /// (optional) type of the document.
        /// </param>

        public CQ(Stream html, 
            Encoding encoding,
            HtmlParsingMode parsingMode = HtmlParsingMode.Auto, 
            HtmlParsingOptions parsingOptions =HtmlParsingOptions.Default,
            DocType docType = DocType.Default)
        {

            CreateNew(this, html, encoding, parsingMode, parsingOptions, docType);
            
        }
コード例 #21
0
ファイル: ElementFactory.cs プロジェクト: mermich/CsQuery
        /// <summary>
        /// Creates a new document from a Stream of HTML using the options passed.
        /// </summary>
        ///
        /// <param name="html">
        /// The HTML input.
        /// </param>
        /// <param name="streamEncoding">
        /// The character set encoding used by the stream. If null, the BOM will be inspected, and it
        /// will default to UTF8 if no encoding can be identified.
        /// </param>
        /// <param name="parsingMode">
        /// (optional) the parsing mode.
        /// </param>
        /// <param name="parsingOptions">
        /// (optional) options for controlling the parsing.
        /// </param>
        /// <param name="docType">
        /// (optional) type of the document.
        /// </param>
        ///
        /// <returns>
        /// A new document.
        /// </returns>

        public static IDomDocument Create(Stream html, 
            Encoding streamEncoding,
            HtmlParsingMode parsingMode = HtmlParsingMode.Auto,
            HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default,
            DocType docType = DocType.Default)
        {
            
            return GetNewParser(parsingMode, parsingOptions, docType)
                .Parse(html, streamEncoding);
            
        }
コード例 #22
0
ファイル: _Constructors.cs プロジェクト: jeiea/osuDownloader
        /// <summary>
        /// Create a new CQ object from an HTML string.
        /// </summary>
        ///
        /// <param name="html">
        /// The html source of the new document.
        /// </param>
        /// <param name="parsingMode">
        /// The HTML parsing mode.
        /// </param>
        /// <param name="parsingOptions">
        /// (optional) options for controlling the parsing.
        /// </param>
        /// <param name="docType">
        /// (optional) type of the document.
        /// </param>

        public CQ(TextReader html,
                  HtmlParsingMode parsingMode       = HtmlParsingMode.Auto,
                  HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default,
                  DocType docType = DocType.Default)
        {
            Encoding encoding = Encoding.UTF8;

            var stream = new MemoryStream(encoding.GetBytes(html.ReadToEnd()));

            CreateNew(this, stream, encoding, parsingMode, parsingOptions, docType);
        }
コード例 #23
0
ファイル: DomDocument.cs プロジェクト: mburgman101/CsQuery
        private void Populate(char[] html, HtmlParsingMode htmlParsingMode)
        {
            if (html != null && html.Length > 0)
            {
                SourceHtml = html;
            }

            HtmlElementFactory factory = new HtmlParser.HtmlElementFactory(this);

            Populate(factory.Parse(htmlParsingMode));
        }
コード例 #24
0
ファイル: _Constructors.cs プロジェクト: emrahoner/CsQuery
        /// <summary>
        /// Create a new CQ object from an HTML string.
        /// </summary>
        ///
        /// <param name="html">
        /// The HTML source.
        /// </param>
        /// <param name="parsingMode">
        /// The HTML parsing mode.
        /// </param>
        /// <param name="parsingOptions">
        /// (optional) options for controlling the parsing.
        /// </param>
        /// <param name="docType">
        /// (optional) type of the document.
        /// </param>

        public CQ(string html, 
            HtmlParsingMode parsingMode = HtmlParsingMode.Auto,
            HtmlParsingOptions parsingOptions=HtmlParsingOptions.Default,
            DocType docType = DocType.Default)
        {
            var encoding = new UTF8Encoding(false);
            using (var stream = Support.GetEncodedStream(html ?? "", encoding))
            {
                CreateNew(this, stream, encoding, parsingMode, parsingOptions, docType);
            }
        }
コード例 #25
0
ファイル: _Constructors.cs プロジェクト: jeiea/osuDownloader
        /// <summary>
        /// Create a new CQ object from an HTML string.
        /// </summary>
        ///
        /// <param name="html">
        /// The HTML source.
        /// </param>
        /// <param name="parsingMode">
        /// The HTML parsing mode.
        /// </param>
        /// <param name="parsingOptions">
        /// (optional) options for controlling the parsing.
        /// </param>
        /// <param name="docType">
        /// (optional) type of the document.
        /// </param>

        public CQ(string html,
                  HtmlParsingMode parsingMode       = HtmlParsingMode.Auto,
                  HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default,
                  DocType docType = DocType.Default)
        {
            var encoding = new UTF8Encoding(false);

            using (var stream = Support.GetEncodedStream(html ?? "", encoding))
            {
                CreateNew(this, stream, encoding, parsingMode, parsingOptions, docType);
            }
        }
コード例 #26
0
ファイル: _Constructors.cs プロジェクト: TheX/CsQuery
        /// <summary>
        /// Create a new CQ object from an HTML string.
        /// </summary>
        ///
        /// <param name="html">
        /// The HTML source.
        /// </param>
        /// <param name="parsingMode">
        /// The HTML parsing mode.
        /// </param>
        /// <param name="parsingOptions">
        /// (optional) options for controlling the parsing.
        /// </param>
        /// <param name="docType">
        /// (optional) type of the document.
        /// </param>

        public CQ(string html, 
            HtmlParsingMode parsingMode = HtmlParsingMode.Auto,
            HtmlParsingOptions parsingOptions=HtmlParsingOptions.Default,
            DocType docType = DocType.Default)
        {
            //CreateNew(this, html, parsingMode,parsingOptions, docType);

            using (var reader = new StringReader(html ?? ""))
            {
                CreateNew(this,reader, parsingMode, parsingOptions, docType);
            }
        }
コード例 #27
0
        /// <summary>
        /// Creates a new DomDocument (or derived) object
        /// </summary>
        ///
        /// <param name="html">
        /// The HTML source for the document
        /// </param>
        /// <param name="parsingMode">
        /// (optional) the parsing mode.
        /// </param>
        /// <param name="parsingOptions">
        /// (optional) options for controlling the parsing.
        /// </param>
        /// <param name="docType">
        /// The DocType for this document.
        /// </param>
        ///
        /// <returns>
        /// A new IDomDocument object
        /// </returns>

        public static IDomDocument Create(string html,
                                          HtmlParsingMode parsingMode       = HtmlParsingMode.Auto,
                                          HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default,
                                          DocType docType = DocType.Default)
        {
            var encoding = Encoding.UTF8;

            using (var stream = new MemoryStream(encoding.GetBytes(html)))
            {
                return(ElementFactory.Create(stream, encoding, parsingMode, parsingOptions, docType));
            }
        }
コード例 #28
0
ファイル: DomDocHelper.cs プロジェクト: prepare/HTML-Renderer
        /// <summary>
        /// Creates a new DomDocument (or derived) object
        /// </summary>
        ///
        /// <param name="html">
        /// The HTML source for the document
        /// </param>
        /// <param name="parsingMode">
        /// (optional) the parsing mode.
        /// </param>
        /// <param name="parsingOptions">
        /// (optional) options for controlling the parsing.
        /// </param>
        /// <param name="docType">
        /// The DocType for this document.
        /// </param>
        ///
        /// <returns>
        /// A new IDomDocument object
        /// </returns>

        public static IDomDocument Create(string html,
            HtmlParsingMode parsingMode = HtmlParsingMode.Auto,
            HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default,
            DocType docType = DocType.Default)
        {

            var encoding = Encoding.UTF8; 
            using (var stream = new MemoryStream(encoding.GetBytes(html)))
            {
                return ElementFactory.Create(stream, encoding, parsingMode, parsingOptions, docType);
            }
        }
コード例 #29
0
ファイル: ElementFactory.cs プロジェクト: Vitallium/CsQuery
        public IDomDocument Parse(TextReader reader, HtmlParsingMode mode=HtmlParsingMode.Auto)
        {
            if (reader.Peek() < 0)
            {
                return new DomFragment();
            }

            HtmlParsingMode = mode;
            Reset();
            Tokenize(reader);

            return treeBuilder.Document;
        }
コード例 #30
0
ファイル: _Constructors.cs プロジェクト: jeiea/osuDownloader
        /// <summary>
        /// Bind this instance to a new DomFragment created from HTML in a specific HTML tag context.
        /// </summary>
        ///
        /// <param name="target">
        /// The target.
        /// </param>
        /// <param name="html">
        /// The HTML.
        /// </param>
        /// <param name="encoding">
        /// The character set encoding.
        /// </param>
        /// <param name="parsingMode">
        /// The HTML parsing mode.
        /// </param>
        /// <param name="parsingOptions">
        /// (optional) options for controlling the parsing.
        /// </param>
        /// <param name="docType">
        /// (optional) type of the document.
        /// </param>

        protected void CreateNew(CQ target,
                                 Stream html,
                                 Encoding encoding,
                                 HtmlParsingMode parsingMode,
                                 HtmlParsingOptions parsingOptions,
                                 DocType docType)
        {
            target.Document = DomDocument.Create(html, encoding, parsingMode, parsingOptions, docType);

            //  enumerate ChildNodes when creating a new fragment to be sure the selection set only
            //  reflects the original document.

            target.SetSelection(Document.ChildNodes.ToList(), SelectionSetOrder.Ascending);
        }
コード例 #31
0
        public static CommonElement CreateElement(HtmlTag tag, HtmlParsingMode parsingMode = HtmlParsingMode.Auto, HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default,
                                                  DocType docType = DocType.Default)
        {
            switch (tag)
            {
            case HtmlTag.A:
                return(new AElement(parsingMode, parsingOptions, docType));

            case HtmlTag.Area:
                return(new AreaElement(parsingMode, parsingOptions, docType));

            default:
                return(new CommonElement(tag, parsingMode, parsingOptions, docType));
            }
        }
コード例 #32
0
        /// <summary>
        /// Parse the HTML, and return it, based on options set.
        /// </summary>
        ///
        /// <exception cref="NotImplementedException">
        /// Thrown when the requested parsing mode is unknown.
        /// </exception>
        ///
        /// <param name="htmlParsingMode">
        /// The HTML parsing mode.
        /// </param>
        ///
        /// <returns>
        /// A List of IDomObject elements; the topmost sequence of the document.
        /// </returns>

        public List <IDomObject> Parse(HtmlParsingMode htmlParsingMode)
        {
            switch (htmlParsingMode)
            {
            case HtmlParsingMode.Content:
                return(ParseAsContent());

            case HtmlParsingMode.Document:
                return(ParseAsDocument());

            case HtmlParsingMode.Fragment:
                return(ParseAsFragment());

            default:
                throw new NotImplementedException("Unknown HTML parsing mode");
            }
        }
コード例 #33
0
        /// <summary>
        /// Creates a new DomDocument (or derived object) using the options specified.
        /// </summary>
        ///
        /// <param name="elements">
        /// The elements that are the source for the new document.
        /// </param>
        /// <param name="parsingMode">
        /// (optional) the parsing mode.
        /// </param>
        /// <param name="docType">
        /// The DocType for this document.
        /// </param>
        ///
        /// <returns>
        /// A new IDomDocument object
        /// </returns>

        public static IDomDocument Create(IEnumerable <IDomObject> elements,
                                          HtmlParsingMode parsingMode = HtmlParsingMode.Content,
                                          DocType docType             = DocType.Default)
        {
            DomDocument doc = parsingMode == HtmlParsingMode.Document ?
                              new DomDocument() :
                              new DomFragment();

            // only set a DocType node for documents.

            if (parsingMode == HtmlParsingMode.Document)
            {
                doc.DocType = docType;
            }
            doc.Populate(elements);
            return(doc);
        }
コード例 #34
0
ファイル: DomDocument.cs プロジェクト: mburgman101/CsQuery
        /// <summary>
        /// Creates an IDomDocument that is derived from this one. The new type can also be a derived type,
        /// such as IDomFragment. The new object will inherit DomRenderingOptions from this one.
        /// </summary>
        ///
        /// <exception cref="ArgumentException">
        /// Thrown when one or more arguments have unsupported or illegal values.
        /// </exception>
        ///
        /// <typeparam name="T">
        /// The type of object to create that is IDomDocument.
        /// </typeparam>
        /// <param name="html">
        /// The HTML source for the new document.
        /// </param>
        /// <param name="htmlParsingMode">
        /// The HTML parsing mode.
        /// </param>
        ///
        /// <returns>
        /// A new, empty concrete class that is represented by the interface T, configured with the same
        /// options as the current object.
        /// </returns>

        public IDomDocument CreateNew <T>(char[] html, HtmlParsingMode htmlParsingMode) where T : IDomDocument
        {
            IDomDocument newDoc;

            if (typeof(T) == typeof(IDomDocument))
            {
                newDoc = new DomDocument(html, htmlParsingMode);
            }
            else if (typeof(T) == typeof(IDomFragment))
            {
                newDoc = new DomFragment(html, htmlParsingMode);
            }

            else
            {
                throw new ArgumentException(String.Format("I don't know about an IDomDocument subclass \"{1}\"",
                                                          typeof(T).ToString()));
            }

            FinishConfiguringNew(newDoc);
            return(newDoc);
        }
コード例 #35
0
ファイル: Create.cs プロジェクト: prepare/HTML-Renderer
        /// <summary>
        /// Create a new CQ object from a stream of HTML, treating the HTML as a content document.
        /// </summary>
        ///
        /// <param name="html">
        /// An open Stream.
        /// </param>
        /// <param name="encoding">
        /// The character set encoding.
        /// </param>
        /// <param name="parsingMode">
        /// (optional) the mode.
        /// </param>
        /// <param name="parsingOptions">
        /// (optional) options for controlling the parsing.
        /// </param>
        /// <param name="docType">
        /// (optional) type of the document.
        /// </param>
        ///
        /// <returns>
        /// A new CQ object.
        /// </returns>

        public static CQ Create(Stream html, 
            Encoding encoding = null,
            HtmlParsingMode parsingMode=HtmlParsingMode.Auto, 
            HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default,
            DocType docType = DocType.Default)
        {
            return new CQ(html, encoding,parsingMode,parsingOptions, docType);
        }
コード例 #36
0
 public CheckBox(HtmlParsingMode parsingMode = HtmlParsingMode.Auto, HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default, DocType docType = DocType.Default)
     : base(InputType.CheckBox, parsingMode, parsingOptions, docType)
 {
 }
コード例 #37
0
ファイル: _Constructors.cs プロジェクト: emrahoner/CsQuery
        /// <summary>
        /// Create a new CQ object from an HTML string.
        /// </summary>
        ///
        /// <param name="html">
        /// The html source of the new document.
        /// </param>
        /// <param name="parsingMode">
        /// The HTML parsing mode.
        /// </param>
        /// <param name="parsingOptions">
        /// (optional) options for controlling the parsing.
        /// </param>
        /// <param name="docType">
        /// (optional) type of the document.
        /// </param>

        public CQ(TextReader html,
            HtmlParsingMode parsingMode = HtmlParsingMode.Auto,
            HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default,
            DocType docType = DocType.Default)
        {
            Encoding encoding = Encoding.UTF8;

            var stream = new MemoryStream(encoding.GetBytes(html.ReadToEnd()));
            CreateNew(this, stream, encoding,parsingMode, parsingOptions, docType);
        }
コード例 #38
0
ファイル: ElementFactory.cs プロジェクト: Vitallium/CsQuery
        private void ConfigureTreeBuilderForParsingMode()
        {
            
            switch (HtmlParsingMode)
            {

                case HtmlParsingMode.Document:
                    treeBuilder.DoctypeExpectation = DoctypeExpectation.Auto;
                    break;
                case HtmlParsingMode.Content:
                    treeBuilder.SetFragmentContext("body");
                    treeBuilder.DoctypeExpectation = DoctypeExpectation.Html;
                    break;
                case HtmlParsingMode.Fragment:
                    treeBuilder.DoctypeExpectation = DoctypeExpectation.Html;
                    HtmlParsingMode = HtmlParsingMode.Auto;
                    break;
            }
        }
コード例 #39
0
ファイル: _Constructors.cs プロジェクト: Vitallium/CsQuery
        /// <summary>
        /// Bind this instance to a new DomFragment created from HTML using the specified parsing mode.
        /// </summary>
        ///
        /// <param name="html">
        /// The HTML.
        /// </param>
        /// <param name="htmlParsingMode">
        /// The HTML parsing mode.
        /// </param>

        protected void CreateNewFragment(string html, HtmlParsingMode htmlParsingMode)
        {
            //Document = new DomFragment(html,htmlParsingMode);
            Document = DomDocument.Create(html,htmlParsingMode);
             
            //  enumerate ChildNodes when creating a new fragment to be sure the selection set only
            //  reflects the original document. 
            
            SetSelection(Document.ChildNodes.ToList(),SelectionSetOrder.Ascending);
        }
コード例 #40
0
 public Table(HtmlParsingMode parsingMode = HtmlParsingMode.Auto, HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default, DocType docType = DocType.Default)
     : base(parsingMode, parsingOptions, docType)
 {
 }
コード例 #41
0
 public OptGroupElement(HtmlParsingMode parsingMode = HtmlParsingMode.Auto, HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default, DocType docType = DocType.Default)
     : base(HtmlTag.Optgroup, parsingMode, parsingOptions, docType)
 {
 }
コード例 #42
0
ファイル: HtmlElementFactory.cs プロジェクト: kaleb/CsQuery
        /// <summary>
        /// Parse the HTML, and return it, based on options set.
        /// </summary>
        ///
        /// <exception cref="NotImplementedException">
        /// Thrown when the requested parsing mode is unknown.
        /// </exception>
        ///
        /// <param name="htmlParsingMode">
        /// The HTML parsing mode.
        /// </param>
        ///
        /// <returns>
        /// A List of IDomObject elements; the topmost sequence of the document.
        /// </returns>

        public List<IDomObject> Parse(HtmlParsingMode htmlParsingMode)
        {
            switch (htmlParsingMode)
            {
                case HtmlParsingMode.Content:
                    return ParseAsContent();
                case HtmlParsingMode.Document:
                    return ParseAsDocument();
                case HtmlParsingMode.Fragment:
                    return ParseAsFragment();
                default:
                    throw new NotImplementedException("Unknown HTML parsing mode");
            }

        }
コード例 #43
0
 public AjaxCommand(string href, HtmlParsingMode parsingMode = HtmlParsingMode.Auto, HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default, DocType docType = DocType.Default)
     : base(href, parsingMode, parsingOptions, docType)
 {
     Attr("data-command-type", "ajax");
 }
コード例 #44
0
ファイル: _Constructors.cs プロジェクト: sahilpopli/CsQuery
        /// <summary>
        /// Bind this instance to a new DomFragment created from HTML using the specified parsing mode.
        /// </summary>
        ///
        /// <param name="html">
        /// The HTML.
        /// </param>
        /// <param name="htmlParsingMode">
        /// The HTML parsing mode.
        /// </param>

        protected void CreateNewFragment(char[] html, HtmlParsingMode htmlParsingMode)
        {
            Document = new DomFragment(html,htmlParsingMode);
            SetSelection(Document.ChildNodes,SelectionSetOrder.Ascending);
            FinishCreatingNewDocument();
        }
コード例 #45
0
ファイル: _Constructors.cs プロジェクト: kaleb/CsQuery
        /// <summary>
        /// Bind this instance to a new DomDocument created from HTML using the specified parsing mode.
        /// </summary>
        ///
        /// <param name="html">
        /// The HTML.
        /// </param>
        /// <param name="htmlParsingMode">
        /// The HTML parsing mode.
        /// </param>

        protected void CreateNewDocument(char[] html, HtmlParsingMode htmlParsingMode)
        {
            Document = new DomDocument(html,htmlParsingMode);
            HtmlElementFactory.ReorganizeStrandedTextNodes(Document);
            AddSelection(Document.ChildNodes);
            FinishCreatingNewDocument();
        }
コード例 #46
0
ファイル: PreMailer.cs プロジェクト: granstel/PreMailer.Net
	    /// <summary>
	    /// In-lines the CSS within the HTML given.
	    /// </summary>
	    /// <param name="html">The HTML input.</param>
	    /// <param name="removeStyleElements">If set to <c>true</c> the style elements are removed.</param>
	    /// <param name="ignoreElements">CSS selector for STYLE elements to ignore (e.g. mobile-specific styles etc.)</param>
	    /// <param name="css">A string containing a style-sheet for inlining.</param>
	    /// <param name="stripIdAndClassAttributes">True to strip ID and class attributes</param>
	    /// <param name="removeComments">True to remove comments, false to leave them intact</param>
        /// <param name="parsingMode">(optional) the mode.</param>
	    /// <returns>Returns the html input, with styles moved to inline attributes.</returns>
	    public static InlineResult MoveCssInline(string html, bool removeStyleElements = false, string ignoreElements = null, string css = null, bool stripIdAndClassAttributes = false, bool removeComments = false, HtmlParsingMode parsingMode = HtmlParsingMode.Auto)
		{
            return new PreMailer(html, parsingMode).MoveCssInline(removeStyleElements, ignoreElements, css, stripIdAndClassAttributes, removeComments);
		}
コード例 #47
0
ファイル: _Constructors.cs プロジェクト: TheX/CsQuery
        /// <summary>
        /// Create a new CQ object from an HTML string.
        /// </summary>
        ///
        /// <param name="html">
        /// The html source of the new document.
        /// </param>
        /// <param name="parsingMode">
        /// The HTML parsing mode.
        /// </param>
        /// <param name="parsingOptions">
        /// (optional) options for controlling the parsing.
        /// </param>
        /// <param name="docType">
        /// (optional) type of the document.
        /// </param>

        public CQ(TextReader html,
            HtmlParsingMode parsingMode = HtmlParsingMode.Auto,
            HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default,
            DocType docType = DocType.Default)
        {
            CreateNew(this, html, parsingMode, parsingOptions, docType);
        }
コード例 #48
0
ファイル: Create.cs プロジェクト: prepare/HTML-Renderer
        /// <summary>
        /// Create a new CQ object from a TextReader containg HTML
        /// </summary>
        ///
        /// <param name="html">
        /// A string of HTML.
        /// </param>
        /// <param name="parsingMode">
        /// (optional) the mode.
        /// </param>
        /// <param name="parsingOptions">
        /// (optional) options for controlling the parsing.
        /// </param>
        /// <param name="docType">
        /// (optional) type of the document.
        /// </param>
        ///
        /// <returns>
        /// The new fragment.
        /// </returns>

        public static CQ Create(TextReader html,
           HtmlParsingMode parsingMode = HtmlParsingMode.Auto,
           HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default,
           DocType docType = DocType.Default)
        {
            return new CQ(html, parsingMode, parsingOptions, docType);
        }
コード例 #49
0
 public InputElement(InputType type, HtmlParsingMode parsingMode = HtmlParsingMode.Auto, HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default, DocType docType = DocType.Default)
     : base(HtmlTag.Input, parsingMode, parsingOptions, docType)
 {
     Type = type;
 }
コード例 #50
0
 public Image(string src, HtmlParsingMode parsingMode = HtmlParsingMode.Auto, HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default, DocType docType = DocType.Default)
     : base(parsingMode, parsingOptions, docType)
 {
     Src = src;
 }
コード例 #51
0
ファイル: _Constructors.cs プロジェクト: Vitallium/CsQuery
        /// <summary>
        /// Bind this instance to a new DomDocument created from HTML using the specified parsing mode.
        /// </summary>
        ///
        /// <param name="html">
        /// The HTML.
        /// </param>
        /// <param name="htmlParsingMode">
        /// The HTML parsing mode.
        /// </param>

        protected void CreateNewDocument(string html, HtmlParsingMode htmlParsingMode)
        {
            //Document = new DomDocument(html,htmlParsingMode);
            Document = DomDocument.Create(html,HtmlParsingMode.Document);
            HtmlParser.Obsolete.HtmlElementFactory.ReorganizeStrandedTextNodes(Document);
            AddSelection(Document.ChildNodes);
        }
コード例 #52
0
 public LabelElement(HtmlParsingMode parsingMode = HtmlParsingMode.Auto, HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default, DocType docType = DocType.Default)
     : base(HtmlTag.Label, parsingMode, parsingOptions, docType)
 {
 }
コード例 #53
0
ファイル: _Constructors.cs プロジェクト: emrahoner/CsQuery
        /// <summary>
        /// Bind this instance to a new DomFragment created from HTML in a specific HTML tag context.
        /// </summary>
        ///
        /// <param name="target">
        /// The target.
        /// </param>
        /// <param name="html">
        /// The HTML.
        /// </param>
        /// <param name="encoding">
        /// The character set encoding.
        /// </param>
        /// <param name="parsingMode">
        /// The HTML parsing mode.
        /// </param>
        /// <param name="parsingOptions">
        /// (optional) options for controlling the parsing.
        /// </param>
        /// <param name="docType">
        /// (optional) type of the document.
        /// </param>

        protected void CreateNew(CQ target,
          Stream html,
          Encoding encoding,
          HtmlParsingMode parsingMode,
          HtmlParsingOptions parsingOptions,
          DocType docType)
        {
            target.Document = DomDocument.Create(html, encoding, parsingMode,parsingOptions, docType);

            //  enumerate ChildNodes when creating a new fragment to be sure the selection set only
            //  reflects the original document. 

            target.SetSelection(Document.ChildNodes.ToList(), SelectionSetOrder.Ascending);
        }
コード例 #54
0
ファイル: ElementFactory.cs プロジェクト: Vitallium/CsQuery
        private void Tokenize(TextReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader was null.");
            }

            if (HtmlParsingMode != HtmlParsingMode.Auto)
            {
                ConfigureTreeBuilderForParsingMode();
                tokenizer.Start();
            }

            bool swallowBom = true;


            try
            {
                char[] buffer = new char[2048];
                UTF16Buffer bufr = new UTF16Buffer(buffer, 0, 0);
                bool lastWasCR = false;
                int len = -1;
                if ((len = reader.Read(buffer, 0, buffer.Length)) != 0)
                {
                    if (HtmlParsingMode == HtmlParser.HtmlParsingMode.Auto)
                    {
                        string ctx = GetContext(buffer);
                        switch (ctx)
                        {
                            case "*document":
                                HtmlParsingMode = HtmlParsingMode.Document;
                                break;
                            case "*content":
                                HtmlParsingMode = HtmlParsingMode.Content;
                                break;
                            default:
                                HtmlParsingMode = HtmlParsingMode.Fragment;
                                treeBuilder.SetFragmentContext(ctx);
                                break;
                        }
                        ConfigureTreeBuilderForParsingMode();
                        tokenizer.Start();
                    }

                    int streamOffset = 0;
                    int offset = 0;
                    int length = len;
                    if (swallowBom)
                    {
                        if (buffer[0] == '\uFEFF')
                        {
                            streamOffset = -1;
                            offset = 1;
                            length--;
                        }
                    }
                    if (length > 0)
                    {
                        tokenizer.SetTransitionBaseOffset(streamOffset);
                        bufr.Start = offset;
                        bufr.End = offset + length;
                        while (bufr.HasMore)
                        {
                            bufr.Adjust(lastWasCR);
                            lastWasCR = false;
                            if (bufr.HasMore)
                            {
                                lastWasCR = tokenizer.TokenizeBuffer(bufr);
                            }
                        }
                    }
                    streamOffset = length;
                    while ((len = reader.Read(buffer, 0, buffer.Length)) != 0)
                    {
                        tokenizer.SetTransitionBaseOffset(streamOffset);
                        bufr.Start = 0;
                        bufr.End = len;
                        while (bufr.HasMore)
                        {
                            bufr.Adjust(lastWasCR);
                            lastWasCR = false;
                            if (bufr.HasMore)
                            {
                                lastWasCR = tokenizer.TokenizeBuffer(bufr);
                            }
                        }
                        streamOffset += len;
                    }
                }
                tokenizer.Eof();
            }
            finally
            {
                tokenizer.End();
            }
        }
コード例 #55
0
 public GridColumn(HtmlParsingMode parsingMode = HtmlParsingMode.Auto, HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default, DocType docType = DocType.Default)
     : base(true, parsingMode, parsingOptions, docType)
 {
     Sortable = true;
 }
コード例 #56
0
ファイル: DomFragment.cs プロジェクト: kaleb/CsQuery
 public DomFragment(char[] html, HtmlParsingMode htmlParsingMode)
     : base(html, htmlParsingMode)
 {
     
 }