Struct parsoid::node::WikiLink[][src]

pub struct WikiLink(_);

Represents an internal link ([[Foo|bar]])

let text = Wikicode::new_text("baz");
let link = WikiLink::new("Foo bar", &text);
assert_eq!(
    link.raw_target(),
    "./Foo_bar".to_string()
);
assert_eq!(
    link.target(),
    "Foo bar".to_string()
);
assert_eq!(
    link.text_contents(), "baz".to_string()
);
assert_eq!(
    link.to_string(),
    "<a href=\"./Foo_bar\" rel=\"mw:WikiLink\">baz</a>".to_string()
);

See the spec for more details.

Implementations

impl WikiLink[src]

pub fn new(target: &str, text: &NodeRef) -> Self[src]

Create a new wiki link

pub fn raw_target(&self) -> String[src]

Get the raw link target, usually prefixed with ./

pub fn target(&self) -> String[src]

Get the link target (basicall the page title)

pub fn set_target(&self, target: &str)[src]

Set the link target.

Methods from Deref<Target = NodeRef>

pub fn inclusive_ancestors(&self) -> Ancestors[src]

Return an iterator of references to this node and its ancestors.

pub fn ancestors(&self) -> Ancestors[src]

Return an iterator of references to this node’s ancestors.

pub fn inclusive_preceding_siblings(&self) -> Rev<Siblings>[src]

Return an iterator of references to this node and the siblings before it.

pub fn preceding_siblings(&self) -> Rev<Siblings>[src]

Return an iterator of references to this node’s siblings before it.

pub fn inclusive_following_siblings(&self) -> Siblings[src]

Return an iterator of references to this node and the siblings after it.

pub fn following_siblings(&self) -> Siblings[src]

Return an iterator of references to this node’s siblings after it.

pub fn children(&self) -> Siblings[src]

Return an iterator of references to this node’s children.

pub fn inclusive_descendants(&self) -> Descendants[src]

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().

pub fn descendants(&self) -> Descendants[src]

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().

pub fn traverse_inclusive(&self) -> Traverse[src]

Return an iterator of the start and end edges of this node and its descendants, in tree order.

pub fn traverse(&self) -> Traverse[src]

Return an iterator of the start and end edges of this node’s descendants, in tree order.

pub fn select(
    &self,
    selectors: &str
) -> Result<Select<Elements<Descendants>, Selectors>, ()>
[src]

Return an iterator of the inclusive descendants element that match the given selector list.

pub fn select_first(
    &self,
    selectors: &str
) -> Result<NodeDataRef<ElementData>, ()>
[src]

Return the first inclusive descendants element that match the given selector list.

pub fn serialize<W>(&self, writer: &mut W) -> Result<(), Error> where
    W: Write
[src]

Serialize this node and its descendants in HTML syntax to the given stream.

pub fn serialize_to_file<P>(&self, path: P) -> Result<(), Error> where
    P: AsRef<Path>, 
[src]

Serialize this node and its descendants in HTML syntax to a new file at the given path.

pub fn text_contents(&self) -> String[src]

Return the concatenation of all text nodes in this subtree.

pub fn append(&self, new_child: NodeRef)[src]

Append a new child to this node, after existing children.

The new child is detached from its previous position.

pub fn prepend(&self, new_child: NodeRef)[src]

Prepend a new child to this node, before existing children.

The new child is detached from its previous position.

pub fn insert_after(&self, new_sibling: NodeRef)[src]

Insert a new sibling after this node.

The new sibling is detached from its previous position.

pub fn insert_before(&self, new_sibling: NodeRef)[src]

Insert a new sibling before this node.

The new sibling is detached from its previous position.

Methods from Deref<Target = Node>

pub fn data(&self) -> &NodeData[src]

Return a reference to this node’s node-type-specific data.

pub fn as_element(&self) -> Option<&ElementData>[src]

If this node is an element, return a reference to element-specific data.

pub fn as_text(&self) -> Option<&RefCell<String>>[src]

If this node is a text node, return a reference to its contents.

pub fn as_comment(&self) -> Option<&RefCell<String>>[src]

If this node is a comment, return a reference to its contents.

pub fn as_doctype(&self) -> Option<&Doctype>[src]

If this node is a document, return a reference to doctype-specific data.

pub fn as_document(&self) -> Option<&DocumentData>[src]

If this node is a document, return a reference to document-specific data.

pub fn parent(&self) -> Option<NodeRef>[src]

Return a reference to the parent node, unless this node is the root of the tree.

pub fn first_child(&self) -> Option<NodeRef>[src]

Return a reference to the first child of this node, unless it has no child.

pub fn last_child(&self) -> Option<NodeRef>[src]

Return a reference to the last child of this node, unless it has no child.

pub fn previous_sibling(&self) -> Option<NodeRef>[src]

Return a reference to the previous sibling of this node, unless it is a first child.

pub fn next_sibling(&self) -> Option<NodeRef>[src]

Return a reference to the next sibling of this node, unless it is a last child.

pub fn detach(&self)[src]

Detach a node from its parent and siblings. Children are not affected.

To remove a node and its descendants, detach it and drop any strong reference to it.

Trait Implementations

impl Clone for WikiLink[src]

impl Debug for WikiLink[src]

impl Deref for WikiLink[src]

type Target = NodeRef

The resulting type after dereferencing.

impl From<WikiLink> for Wikinode[src]

impl WikinodeIterator for WikiLink[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.