pulldown_cmark_fork/
lib.rs

1// Copyright 2015 Google Inc. All rights reserved.
2//
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:
9//
10// The above copyright notice and this permission notice shall be included in
11// all copies or substantial portions of the Software.
12//
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
19// THE SOFTWARE.
20
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).
24//! 
25//! By default, only CommonMark features are enabled. To use extensions like tables,
26//! footnotes or task lists, enable by setting the corresponding flags in the
27//! [Options](struct.Options.html) struct.
28//!
29//! # Example
30//! ```rust
31//! use pulldown_cmark_fork::{Parser, Options, html};
32//!
33//! let markdown_input = "Hello world, this is a ~~complicated~~ *very simple* example.";
34//! 
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);
40//! 
41//! // Write to String buffer.
42//! let mut html_output = String::new();
43//! html::push_html(&mut html_output, parser);
44//!
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);
48//! ```
49
50// When compiled for the rustc compiler itself we want to make sure that this is
51// an unstable crate.
52#![cfg_attr(rustbuild, feature(staged_api, rustc_private))]
53#![cfg_attr(rustbuild, unstable(feature = "rustc_private", issue = "27812"))]
54
55pub mod html;
56
57#[macro_use]
58extern crate bitflags;
59extern crate unicase;
60
61mod scanners;
62mod entities;
63mod escape;
64mod puncttable;
65mod parse;
66mod tree;
67mod linklabel;
68mod strings;
69
70#[cfg(all(target_arch = "x86_64", feature="simd"))]
71mod simd;
72
73pub use crate::parse::{Parser, OffsetIter, Alignment, Event, Tag, Options, LinkType};
74pub use crate::strings::{CowStr, InlineStr};