11//! A 100% [CommonMark](http://commonmark.org/) and [GFM](https://github.github.com/gfm/)
2- //! compatible Markdown parser. Source repository is at <https://github.com/kivikakk/comrak>.
2+ //! compatible Markdown parser.
33//!
4- //! The design is based on [cmark-gfm](https://github.com/github/cmark-gfm), so
5- //! familiarity with that will help.
4+ //! Source repository and detailed `README` is at <https://github.com/kivikakk/comrak>.
65//!
76//! You can use `comrak::markdown_to_html` directly:
87//!
2019//! use comrak::nodes::{AstNode, NodeValue};
2120//!
2221//! # fn main() {
23- //! // The returned nodes are created in the supplied Arena, and are bound by its lifetime.
2422//! let arena = Arena::new();
2523//!
2624//! let root = parse_document(
2725//! &arena,
28- //! "This is my input.\n\n1. Also my input.\n2. Certainly my input.\n",
26+ //! "This is my input.\n\n1. Also [my](#) input.\n2. Certainly *my* input.\n",
2927//! &Options::default());
3028//!
31- //! fn iter_nodes<'a, F>(node: &'a AstNode<'a>, f: &F)
32- //! where F : Fn(&'a AstNode<'a>) {
33- //! f(node);
34- //! for c in node.children() {
35- //! iter_nodes(c, f);
29+ //! for node in root.descendants() {
30+ //! if let NodeValue::Text(ref mut text) = node.data.borrow_mut().value {
31+ //! *text = text.replace("my", "your");
3632//! }
3733//! }
3834//!
39- //! iter_nodes(root, &|node| {
40- //! match &mut node.data.borrow_mut().value {
41- //! &mut NodeValue::Text(ref mut text) => {
42- //! let orig = std::mem::replace(text, String::new());
43- //! *text = orig.replace("my", "your");
44- //! }
45- //! _ => (),
46- //! }
47- //! });
48- //!
4935//! let mut html = vec![];
5036//! format_html(root, &Options::default(), &mut html).unwrap();
5137//!
5238//! assert_eq!(
5339//! String::from_utf8(html).unwrap(),
5440//! "<p>This is your input.</p>\n\
5541//! <ol>\n\
56- //! <li>Also your input.</li>\n\
57- //! <li>Certainly your input.</li>\n\
42+ //! <li>Also <a href=\"#\"> your</a> input.</li>\n\
43+ //! <li>Certainly <em> your</em> input.</li>\n\
5844//! </ol>\n");
5945//! # }
6046//! ```
@@ -98,11 +84,15 @@ pub use cm::format_document as format_commonmark;
9884pub use cm:: format_document_with_plugins as format_commonmark_with_plugins;
9985pub use html:: format_document as format_html;
10086pub use html:: format_document_with_plugins as format_html_with_plugins;
87+ #[ doc( inline) ]
10188pub use html:: Anchorizer ;
89+ #[ allow( deprecated) ]
90+ pub use parser:: parse_document_with_broken_link_callback;
10291pub use parser:: {
103- parse_document, parse_document_with_broken_link_callback , ExtensionOptions ,
92+ parse_document, BrokenLinkCallback , BrokenLinkReference , ExtensionOptions ,
10493 ExtensionOptionsBuilder , ListStyleType , Options , ParseOptions , ParseOptionsBuilder , Plugins ,
10594 PluginsBuilder , RenderOptions , RenderOptionsBuilder , RenderPlugins , RenderPluginsBuilder ,
95+ ResolvedReference ,
10696} ;
10797pub use typed_arena:: Arena ;
10898pub use xml:: format_document as format_xml;
@@ -111,9 +101,9 @@ pub use xml::format_document_with_plugins as format_xml_with_plugins;
111101/// Legacy naming of [`ExtensionOptions`]
112102pub type ComrakExtensionOptions = ExtensionOptions ;
113103/// Legacy naming of [`Options`]
114- pub type ComrakOptions = Options ;
104+ pub type ComrakOptions < ' c > = Options < ' c > ;
115105/// Legacy naming of [`ParseOptions`]
116- pub type ComrakParseOptions = ParseOptions ;
106+ pub type ComrakParseOptions < ' c > = ParseOptions < ' c > ;
117107/// Legacy naming of [`Plugins`]
118108pub type ComrakPlugins < ' a > = Plugins < ' a > ;
119109/// Legacy naming of [`RenderOptions`]
0 commit comments