1 // Copyright 2015 Google Inc. All rights reserved.
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 //! Pull parser for [CommonMark](https://commonmark.org). This crate provides a [Parser](struct.Parser.html) struct
22 //! which is an iterator over [Event](enum.Event.html)s. This iterator can be used
23 //! directly, or to output HTML using the [HTML module](html/index.html).
25 //! By default, only CommonMark features are enabled. To use extensions like tables,
26 //! footnotes or task lists, enable them by setting the corresponding flags in the
27 //! [Options](struct.Options.html) struct.
31 //! use pulldown_cmark::{Parser, Options, html};
33 //! let markdown_input = "Hello world, this is a ~~complicated~~ *very simple* example.";
35 //! // Set up options and parser. Strikethroughs are not part of the CommonMark standard
36 //! // and we therefore must enable it explicitly.
37 //! let mut options = Options::empty();
38 //! options.insert(Options::ENABLE_STRIKETHROUGH);
39 //! let parser = Parser::new_ext(markdown_input, options);
41 //! // Write to String buffer.
42 //! let mut html_output = String::new();
43 //! html::push_html(&mut html_output, parser);
45 //! // Check that the output is what we expected.
46 //! let expected_html = "<p>Hello world, this is a <del>complicated</del> <em>very simple</em> example.</p>\n";
47 //! assert_eq!(expected_html, &html_output);
50 // When compiled for the rustc compiler itself we want to make sure that this is
52 #![cfg_attr(rustbuild, feature(staged_api, rustc_private))]
53 #![cfg_attr(rustbuild, unstable(feature = "rustc_private", issue = "27812"))]
58 extern crate bitflags
;
70 #[cfg(all(target_arch = "x86_64", feature = "simd"))]
73 pub use crate::parse
::{Alignment, Event, LinkType, OffsetIter, Options, Parser, Tag}
;
74 pub use crate::strings
::{CowStr, InlineStr}
;