Function parse_hyperlinks::parser::restructured_text::rst_label2dest
source · [−]Expand description
Parse a reStructuredText link reference definition.
This parser consumes until the end of the line. As rst does not know about link titles,
the parser always returns an empty link_title as Cow::Borrowed("").
use parse_hyperlinks::parser::Link;
use parse_hyperlinks::parser::restructured_text::rst_label2dest;
use std::borrow::Cow;
assert_eq!(
rst_label2dest(" .. _`label`: destination\nabc"),
Ok(("\nabc", (Cow::from("label"), Cow::from("destination"), Cow::from(""))))
);
assert_eq!(
rst_label2dest(" .. __: destination\nabc"),
Ok(("\nabc", (Cow::from("_"), Cow::from("destination"), Cow::from(""))))
);
assert_eq!(
rst_label2dest(" __ destination\nabc"),
Ok(("\nabc", (Cow::from("_"), Cow::from("destination"), Cow::from(""))))
);Here some examples for link references:
.. _Python home page: http://www.python.org
.. _`Python: home page`: http://www.python.orgSee unit test test_rst_label2dest() for more examples.