pub struct Wikicode { /* private fields */ }
Expand description
Container for HTML, usually represents the entire page
Implementations§
source§impl Wikicode
impl Wikicode
sourcepub fn new_node(tag: &str) -> Self
pub fn new_node(tag: &str) -> Self
Create a new HTML node with the given tag
let node = Wikicode::new_node("b");
// Append your list items
node.append(&Wikicode::new_text("bolded text"));
assert_eq!(&node.to_string(), "<b>bolded text</b>")
sourcepub fn new_text(text: &str) -> Self
pub fn new_text(text: &str) -> Self
Create a text node with the given contents
let node = Wikicode::new_text("foo bar");
assert_eq!(&node.to_string(), "foo bar");
// Tags will be escaped
let weird_node = Wikicode::new_text("foo <bar>");
assert_eq!(&weird_node.to_string(), "foo <bar>");
sourcepub fn spec_version(&self) -> Option<String>
pub fn spec_version(&self) -> Option<String>
Get the HTML spec version for this document, if it’s available
sourcepub fn revision_id(&self) -> Option<u64>
pub fn revision_id(&self) -> Option<u64>
Get the revision id associated with the Parsoid HTML, if it has one.
sourcepub fn title(&self) -> Option<String>
pub fn title(&self) -> Option<String>
Get the title associated with the Parsoid HTML, if it has one.
pub fn redirect(&self) -> Option<Redirect>
sourcepub fn text_contents(&self) -> String
pub fn text_contents(&self) -> String
Get a plain text representation of the Parsoid HTML with all markup stripped.
pub fn into_immutable(self) -> ImmutableWikicode
Methods from Deref<Target = NodeRef>§
sourcepub fn inclusive_ancestors(&self) -> Ancestors
pub fn inclusive_ancestors(&self) -> Ancestors
Return an iterator of references to this node and its ancestors.
sourcepub fn ancestors(&self) -> Ancestors
pub fn ancestors(&self) -> Ancestors
Return an iterator of references to this node’s ancestors.
sourcepub fn inclusive_preceding_siblings(&self) -> Rev<Siblings>
pub fn inclusive_preceding_siblings(&self) -> Rev<Siblings>
Return an iterator of references to this node and the siblings before it.
sourcepub fn preceding_siblings(&self) -> Rev<Siblings>
pub fn preceding_siblings(&self) -> Rev<Siblings>
Return an iterator of references to this node’s siblings before it.
sourcepub fn inclusive_following_siblings(&self) -> Siblings
pub fn inclusive_following_siblings(&self) -> Siblings
Return an iterator of references to this node and the siblings after it.
sourcepub fn following_siblings(&self) -> Siblings
pub fn following_siblings(&self) -> Siblings
Return an iterator of references to this node’s siblings after it.
sourcepub fn inclusive_descendants(&self) -> Descendants
pub fn inclusive_descendants(&self) -> Descendants
Return an iterator of references to this node and its descendants, in tree order.
Parent nodes appear before the descendants.
Note: this is the NodeEdge::Start
items from traverse()
.
sourcepub fn descendants(&self) -> Descendants
pub fn descendants(&self) -> Descendants
Return an iterator of references to this node’s descendants, in tree order.
Parent nodes appear before the descendants.
Note: this is the NodeEdge::Start
items from traverse()
.
sourcepub fn traverse_inclusive(&self) -> Traverse
pub fn traverse_inclusive(&self) -> Traverse
Return an iterator of the start and end edges of this node and its descendants, in tree order.
sourcepub fn traverse(&self) -> Traverse
pub fn traverse(&self) -> Traverse
Return an iterator of the start and end edges of this node’s descendants, in tree order.
sourcepub fn select(
&self,
selectors: &str
) -> Result<Select<Elements<Descendants>>, ()>
pub fn select( &self, selectors: &str ) -> Result<Select<Elements<Descendants>>, ()>
Return an iterator of the inclusive descendants element that match the given selector list.
sourcepub fn select_first(
&self,
selectors: &str
) -> Result<NodeDataRef<ElementData>, ()>
pub fn select_first( &self, selectors: &str ) -> Result<NodeDataRef<ElementData>, ()>
Return the first inclusive descendants element that match the given selector list.
sourcepub fn serialize<W>(&self, writer: &mut W) -> Result<(), Error>where
W: Write,
pub fn serialize<W>(&self, writer: &mut W) -> Result<(), Error>where
W: Write,
Serialize this node and its descendants in HTML syntax to the given stream.
sourcepub fn serialize_to_file<P>(&self, path: P) -> Result<(), Error>
pub fn serialize_to_file<P>(&self, path: P) -> Result<(), Error>
Serialize this node and its descendants in HTML syntax to a new file at the given path.
sourcepub fn text_contents(&self) -> String
pub fn text_contents(&self) -> String
Return the concatenation of all text nodes in this subtree.
sourcepub fn append(&self, new_child: NodeRef)
pub fn append(&self, new_child: NodeRef)
Append a new child to this node, after existing children.
The new child is detached from its previous position.
sourcepub fn prepend(&self, new_child: NodeRef)
pub fn prepend(&self, new_child: NodeRef)
Prepend a new child to this node, before existing children.
The new child is detached from its previous position.
sourcepub fn insert_after(&self, new_sibling: NodeRef)
pub fn insert_after(&self, new_sibling: NodeRef)
Insert a new sibling after this node.
The new sibling is detached from its previous position.
sourcepub fn insert_before(&self, new_sibling: NodeRef)
pub fn insert_before(&self, new_sibling: NodeRef)
Insert a new sibling before this node.
The new sibling is detached from its previous position.
Methods from Deref<Target = Node>§
sourcepub fn as_element(&self) -> Option<&ElementData>
pub fn as_element(&self) -> Option<&ElementData>
If this node is an element, return a reference to element-specific data.
sourcepub fn as_text(&self) -> Option<&RefCell<String>>
pub fn as_text(&self) -> Option<&RefCell<String>>
If this node is a text node, return a reference to its contents.
sourcepub fn as_comment(&self) -> Option<&RefCell<String>>
pub fn as_comment(&self) -> Option<&RefCell<String>>
If this node is a comment, return a reference to its contents.
sourcepub fn as_doctype(&self) -> Option<&Doctype>
pub fn as_doctype(&self) -> Option<&Doctype>
If this node is a document, return a reference to doctype-specific data.
sourcepub fn as_document(&self) -> Option<&DocumentData>
pub fn as_document(&self) -> Option<&DocumentData>
If this node is a document, return a reference to document-specific data.
sourcepub fn parent(&self) -> Option<NodeRef>
pub fn parent(&self) -> Option<NodeRef>
Return a reference to the parent node, unless this node is the root of the tree.
sourcepub fn first_child(&self) -> Option<NodeRef>
pub fn first_child(&self) -> Option<NodeRef>
Return a reference to the first child of this node, unless it has no child.
sourcepub fn last_child(&self) -> Option<NodeRef>
pub fn last_child(&self) -> Option<NodeRef>
Return a reference to the last child of this node, unless it has no child.
sourcepub fn previous_sibling(&self) -> Option<NodeRef>
pub fn previous_sibling(&self) -> Option<NodeRef>
Return a reference to the previous sibling of this node, unless it is a first child.
sourcepub fn next_sibling(&self) -> Option<NodeRef>
pub fn next_sibling(&self) -> Option<NodeRef>
Return a reference to the next sibling of this node, unless it is a last child.
Trait Implementations§
source§impl From<ImmutableWikicode> for Wikicode
impl From<ImmutableWikicode> for Wikicode
source§fn from(immutable: ImmutableWikicode) -> Self
fn from(immutable: ImmutableWikicode) -> Self
source§impl From<Wikicode> for ImmutableWikicode
impl From<Wikicode> for ImmutableWikicode
source§impl PartialEq for Wikicode
impl PartialEq for Wikicode
source§impl WikinodeIterator for Wikicode
impl WikinodeIterator for Wikicode
fn as_node(&self) -> &NodeRef
source§fn filter_comments(&self) -> Vec<Comment>
fn filter_comments(&self) -> Vec<Comment>
<!-- example -->
)source§fn append<N: WikiMultinode>(&self, code: &N)
fn append<N: WikiMultinode>(&self, code: &N)
source§fn prepend<N: WikiMultinode>(&self, code: &N)
fn prepend<N: WikiMultinode>(&self, code: &N)
source§fn insert_after<N: WikiMultinode>(&self, code: &N)
fn insert_after<N: WikiMultinode>(&self, code: &N)
source§fn insert_before<N: WikiMultinode>(&self, code: &N)
fn insert_before<N: WikiMultinode>(&self, code: &N)
source§fn select_first(&self, selector: &str) -> Option<Wikinode>
fn select_first(&self, selector: &str) -> Option<Wikinode>
source§fn filter_links(&self) -> Vec<WikiLink>
fn filter_links(&self) -> Vec<WikiLink>
[[Foo|bar]]
)source§fn filter_external_links(&self) -> Vec<ExtLink>
fn filter_external_links(&self) -> Vec<ExtLink>
[https://example.org/ Example]
)source§fn filter_categories(&self) -> Vec<Category>
fn filter_categories(&self) -> Vec<Category>
source§fn filter_images(&self) -> Vec<Image>
fn filter_images(&self) -> Vec<Image>
fn iter_sections(&self) -> Vec<Section>
fn filter_noinclude(&self) -> Vec<NoInclude>
fn filter_onlyinclude(&self) -> Vec<OnlyInclude>
source§fn next_sibling(&self) -> Option<Wikinode>
fn next_sibling(&self) -> Option<Wikinode>
source§fn previous_sibling(&self) -> Option<Wikinode>
fn previous_sibling(&self) -> Option<Wikinode>
source§fn inclusive_ancestors(&self) -> WikinodeMap<Ancestors>
fn inclusive_ancestors(&self) -> WikinodeMap<Ancestors>
source§fn ancestors(&self) -> WikinodeMap<Ancestors>
fn ancestors(&self) -> WikinodeMap<Ancestors>
source§fn inclusive_preceding_siblings(&self) -> WikinodeMap<Rev<Siblings>>
fn inclusive_preceding_siblings(&self) -> WikinodeMap<Rev<Siblings>>
source§fn preceding_siblings(&self) -> WikinodeMap<Rev<Siblings>>
fn preceding_siblings(&self) -> WikinodeMap<Rev<Siblings>>
source§fn preceding_simblings(&self) -> WikinodeMap<Rev<Siblings>>
fn preceding_simblings(&self) -> WikinodeMap<Rev<Siblings>>
source§fn inclusive_following_siblings(&self) -> WikinodeMap<Siblings>
fn inclusive_following_siblings(&self) -> WikinodeMap<Siblings>
source§fn following_siblings(&self) -> WikinodeMap<Siblings>
fn following_siblings(&self) -> WikinodeMap<Siblings>
source§fn children(&self) -> WikinodeMap<Siblings>
fn children(&self) -> WikinodeMap<Siblings>
source§fn inclusive_descendants(&self) -> WikinodeMap<Descendants>
fn inclusive_descendants(&self) -> WikinodeMap<Descendants>
source§fn descendants(&self) -> WikinodeMap<Descendants>
fn descendants(&self) -> WikinodeMap<Descendants>
impl Eq for Wikicode
impl StructuralEq for Wikicode
impl StructuralPartialEq for Wikicode
Auto Trait Implementations§
impl !RefUnwindSafe for Wikicode
impl !Send for Wikicode
impl !Sync for Wikicode
impl Unpin for Wikicode
impl !UnwindSafe for Wikicode
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.