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); }
/// <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); }
public static IDomDocument Create(Stream html, HtmlParsingMode mode = HtmlParsingMode.Content) { using (var reader = new StreamReader(html)) { return Parser.Parse(reader, mode); } }
/// <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)); }
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); }
/// <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(); }
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); }
/// <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(); }
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; }
/// <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(); }
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; }
/// <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); }
/// <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)); }
/// <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)); }
/// <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)); }
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); }
/// <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); }
/// <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); } }
/// <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(); }
/// <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); }
/// <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); }
/// <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); }
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)); }
/// <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); } }
/// <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); } }
/// <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); } }
/// <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)); } }
/// <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); } }
public IDomDocument Parse(TextReader reader, HtmlParsingMode mode=HtmlParsingMode.Auto) { if (reader.Peek() < 0) { return new DomFragment(); } HtmlParsingMode = mode; Reset(); Tokenize(reader); return treeBuilder.Document; }
/// <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); }
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)); } }
/// <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"); } }
/// <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); }
/// <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); }
/// <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); }
public CheckBox(HtmlParsingMode parsingMode = HtmlParsingMode.Auto, HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default, DocType docType = DocType.Default) : base(InputType.CheckBox, parsingMode, parsingOptions, docType) { }
/// <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); }
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; } }
/// <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); }
public Table(HtmlParsingMode parsingMode = HtmlParsingMode.Auto, HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default, DocType docType = DocType.Default) : base(parsingMode, parsingOptions, docType) { }
public OptGroupElement(HtmlParsingMode parsingMode = HtmlParsingMode.Auto, HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default, DocType docType = DocType.Default) : base(HtmlTag.Optgroup, parsingMode, parsingOptions, docType) { }
/// <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"); } }
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"); }
/// <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(); }
/// <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(); }
/// <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); }
/// <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); }
/// <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); }
public InputElement(InputType type, HtmlParsingMode parsingMode = HtmlParsingMode.Auto, HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default, DocType docType = DocType.Default) : base(HtmlTag.Input, parsingMode, parsingOptions, docType) { Type = type; }
public Image(string src, HtmlParsingMode parsingMode = HtmlParsingMode.Auto, HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default, DocType docType = DocType.Default) : base(parsingMode, parsingOptions, docType) { Src = src; }
/// <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); }
public LabelElement(HtmlParsingMode parsingMode = HtmlParsingMode.Auto, HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default, DocType docType = DocType.Default) : base(HtmlTag.Label, parsingMode, parsingOptions, docType) { }
/// <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); }
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(); } }
public GridColumn(HtmlParsingMode parsingMode = HtmlParsingMode.Auto, HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default, DocType docType = DocType.Default) : base(true, parsingMode, parsingOptions, docType) { Sortable = true; }
public DomFragment(char[] html, HtmlParsingMode htmlParsingMode) : base(html, htmlParsingMode) { }