diff --git a/README.md b/README.md index f537df00..d85e9869 100644 --- a/README.md +++ b/README.md @@ -144,8 +144,8 @@ the file does not exist. And there's a Rust interface. You can use `comrak::markdown_to_html` directly: ``` rust -use comrak::{markdown_to_html, ComrakOptions}; -assert_eq!(markdown_to_html("Hello, **世界**!", &ComrakOptions::default()), +use comrak::{markdown_to_html, Options}; +assert_eq!(markdown_to_html("Hello, **世界**!", &Options::default()), "
Hello, 世界!
\n"); ``` @@ -153,7 +153,7 @@ Or you can parse the input into an AST yourself, manipulate it, and then use you ``` rust extern crate comrak; -use comrak::{parse_document, format_html, Arena, ComrakOptions}; +use comrak::{parse_document, format_html, Arena, Options}; use comrak::nodes::{AstNode, NodeValue}; // The returned nodes are created in the supplied Arena, and are bound by its lifetime. @@ -162,7 +162,7 @@ let arena = Arena::new(); let root = parse_document( &arena, "This is my input.\n\n1. Also my input.\n2. Certainly my input.\n", - &ComrakOptions::default()); + &Options::default()); fn iter_nodes<'a, F>(node: &'a AstNode<'a>, f: &F) where F : Fn(&'a AstNode<'a>) { @@ -183,7 +183,7 @@ iter_nodes(root, &|node| { }); let mut html = vec![]; -format_html(root, &ComrakOptions::default(), &mut html).unwrap(); +format_html(root, &Options::default(), &mut html).unwrap(); assert_eq!( String::from_utf8(html).unwrap(), @@ -224,7 +224,7 @@ Comrak additionally supports its own extensions, which are yet to be specced out - Shortcodes By default none are enabled; they are individually enabled with each parse by setting the appropriate values in the -[`ComrakOptions` struct](https://docs.rs/comrak/newest/comrak/struct.ComrakOptions.html). +[`Options` struct](https://docs.rs/comrak/newest/comrak/struct.Options.html). ## Plugins @@ -233,7 +233,7 @@ By default none are enabled; they are individually enabled with each parse by se At the moment syntax highlighting of codefence blocks is the only feature that can be enhanced with plugins. Create an implementation of the `SyntaxHighlighterAdapter` trait, and then provide an instance of such adapter to -`ComrakPlugins.render.codefence_syntax_highlighter`. For formatting a markdown document with plugins, use the +`Plugins.render.codefence_syntax_highlighter`. For formatting a markdown document with plugins, use the `markdown_to_html_with_plugins` function, which accepts your plugin as a parameter. See the `syntax_highlighter.rs` and `syntect.rs` examples for more details. @@ -242,7 +242,7 @@ See the `syntax_highlighter.rs` and `syntect.rs` examples for more details. [`syntect`](https://github.com/trishume/syntect) is a syntax highlighting library for Rust. By default, `comrak` offers a plugin for it. In order to utilize it, create an instance of `plugins::syntect::SyntectAdapter` and use it as your -`ComrakPlugins` option. +`Plugins` option. ## Related projects diff --git a/benches/progit.rs b/benches/progit.rs index 79963d86..b35cb695 100644 --- a/benches/progit.rs +++ b/benches/progit.rs @@ -2,7 +2,7 @@ extern crate test; -use comrak::{format_html, parse_document, Arena, ComrakOptions}; +use comrak::{format_html, parse_document, Arena, Options}; use test::Bencher; #[bench] @@ -15,8 +15,8 @@ fn bench_progit(b: &mut Bencher) { file.read_to_string(&mut s).unwrap(); b.iter(|| { let arena = Arena::new(); - let root = parse_document(&arena, &s, &ComrakOptions::default()); + let root = parse_document(&arena, &s, &Options::default()); let mut output = vec![]; - format_html(root, &ComrakOptions::default(), &mut output).unwrap() + format_html(root, &Options::default(), &mut output).unwrap() }); } diff --git a/examples/custom_headings.rs b/examples/custom_headings.rs index 7020cc09..2e4dc9ae 100644 --- a/examples/custom_headings.rs +++ b/examples/custom_headings.rs @@ -2,14 +2,14 @@ use comrak::{ adapters::{HeadingAdapter, HeadingMeta}, markdown_to_html_with_plugins, nodes::Sourcepos, - ComrakOptions, ComrakPlugins, + Options, Plugins, }; use std::io::{self, Write}; fn main() { let adapter = CustomHeadingAdapter; - let mut options = ComrakOptions::default(); - let mut plugins = ComrakPlugins::default(); + let mut options = Options::default(); + let mut plugins = Plugins::default(); plugins.render.heading_adapter = Some(&adapter); print_html( @@ -62,7 +62,7 @@ impl HeadingAdapter for CustomHeadingAdapter { } } -fn print_html(document: &str, options: &ComrakOptions, plugins: &ComrakPlugins) { +fn print_html(document: &str, options: &Options, plugins: &Plugins) { let html = markdown_to_html_with_plugins(document, options, plugins); println!("{}", html); } diff --git a/examples/headers.rs b/examples/headers.rs index 69b8df3d..d1cadfb4 100644 --- a/examples/headers.rs +++ b/examples/headers.rs @@ -2,7 +2,7 @@ use comrak::{ nodes::{AstNode, NodeCode, NodeValue}, - parse_document, Arena, ComrakOptions, + parse_document, Arena, Options, }; fn main() { @@ -13,7 +13,7 @@ fn main() { fn get_document_title(document: &str) -> String { let arena = Arena::new(); - let root = parse_document(&arena, document, &ComrakOptions::default()); + let root = parse_document(&arena, document, &Options::default()); for node in root.children() { let header = match node.data.clone().into_inner().value { diff --git a/examples/s-expr.rs b/examples/s-expr.rs index fa7af0cf..c8a1341b 100644 --- a/examples/s-expr.rs +++ b/examples/s-expr.rs @@ -14,7 +14,7 @@ const INDENT: usize = 4; const CLOSE_NEWLINE: bool = false; use comrak::nodes::{AstNode, NodeValue}; -use comrak::{parse_document, Arena, ComrakExtensionOptions, ComrakOptions}; +use comrak::{parse_document, Arena, ExtensionOptions, Options}; use std::env; use std::error::Error; use std::fs::File; @@ -74,8 +74,8 @@ fn iter_nodes<'a, W: Write>( fn dump(source: &str) -> io::Result<()> { let arena = Arena::new(); - let opts = ComrakOptions { - extension: ComrakExtensionOptions { + let opts = Options { + extension: ExtensionOptions { strikethrough: true, tagfilter: true, table: true, @@ -84,9 +84,9 @@ fn dump(source: &str) -> io::Result<()> { superscript: true, footnotes: true, description_lists: true, - ..ComrakExtensionOptions::default() + ..ExtensionOptions::default() }, - ..ComrakOptions::default() + ..Options::default() }; let doc = parse_document(&arena, source, &opts); diff --git a/examples/sample.rs b/examples/sample.rs index 552a5781..fb7b8148 100644 --- a/examples/sample.rs +++ b/examples/sample.rs @@ -1,17 +1,17 @@ // Samples used in the README. Wanna make sure they work as advertised. fn small() { - use comrak::{markdown_to_html, ComrakOptions}; + use comrak::{markdown_to_html, Options}; assert_eq!( - markdown_to_html("Hello, **世界**!", &ComrakOptions::default()), + markdown_to_html("Hello, **世界**!", &Options::default()), "Hello, 世界!
\n" ); } fn large() { use comrak::nodes::{AstNode, NodeValue}; - use comrak::{format_html, parse_document, Arena, ComrakOptions}; + use comrak::{format_html, parse_document, Arena, Options}; // The returned nodes are created in the supplied Arena, and are bound by its lifetime. let arena = Arena::new(); @@ -19,7 +19,7 @@ fn large() { let root = parse_document( &arena, "This is my input.\n\n1. Also my input.\n2. Certainly my input.\n", - &ComrakOptions::default(), + &Options::default(), ); fn iter_nodes<'a, F>(node: &'a AstNode<'a>, f: &F) @@ -40,7 +40,7 @@ fn large() { }); let mut html = vec![]; - format_html(root, &ComrakOptions::default(), &mut html).unwrap(); + format_html(root, &Options::default(), &mut html).unwrap(); assert_eq!( String::from_utf8(html).unwrap(), diff --git a/examples/syntax_highlighter.rs b/examples/syntax_highlighter.rs index 84a41ba2..f95806c9 100644 --- a/examples/syntax_highlighter.rs +++ b/examples/syntax_highlighter.rs @@ -1,7 +1,7 @@ //! This example shows how to implement a syntax highlighter plugin. use comrak::adapters::SyntaxHighlighterAdapter; -use comrak::{markdown_to_html_with_plugins, ComrakOptions, ComrakPlugins}; +use comrak::{markdown_to_html_with_plugins, Options, Plugins}; use std::collections::HashMap; use std::io::{self, Write}; @@ -59,8 +59,8 @@ impl SyntaxHighlighterAdapter for PotatoSyntaxAdapter { fn main() { let adapter = PotatoSyntaxAdapter::new(42); - let options = ComrakOptions::default(); - let mut plugins = ComrakPlugins::default(); + let options = Options::default(); + let mut plugins = Plugins::default(); plugins.render.codefence_syntax_highlighter = Some(&adapter); diff --git a/examples/syntect.rs b/examples/syntect.rs index 90222cd4..bf6e8c38 100644 --- a/examples/syntect.rs +++ b/examples/syntect.rs @@ -1,12 +1,12 @@ //! This example shows how to use the bundled syntect plugin. use comrak::plugins::syntect::SyntectAdapter; -use comrak::{markdown_to_html_with_plugins, ComrakOptions, ComrakPlugins}; +use comrak::{markdown_to_html_with_plugins, Options, Plugins}; fn main() { let adapter = SyntectAdapter::new("base16-ocean.dark"); - let options = ComrakOptions::default(); - let mut plugins = ComrakPlugins::default(); + let options = Options::default(); + let mut plugins = Plugins::default(); plugins.render.codefence_syntax_highlighter = Some(&adapter); diff --git a/examples/update-readme.rs b/examples/update-readme.rs index 483e7ec9..36316cb6 100644 --- a/examples/update-readme.rs +++ b/examples/update-readme.rs @@ -4,7 +4,7 @@ use std::fmt::Write; use std::str; use comrak::nodes::{AstNode, NodeValue}; -use comrak::{format_commonmark, parse_document, Arena, ComrakOptions}; +use comrak::{format_commonmark, parse_document, Arena, Options}; const DEPENDENCIES: &str = "[dependencies]\ncomrak = "; const HELP: &str = "$ comrak --help\n"; @@ -13,7 +13,7 @@ fn main() -> Result<(), BoxHello, 世界!
\n"); //! ``` //! @@ -16,7 +16,7 @@ //! formatter: //! //! ``` -//! use comrak::{Arena, parse_document, format_html, ComrakOptions}; +//! use comrak::{Arena, parse_document, format_html, Options}; //! use comrak::nodes::{AstNode, NodeValue}; //! //! # fn main() { @@ -26,7 +26,7 @@ //! let root = parse_document( //! &arena, //! "This is my input.\n\n1. Also my input.\n2. Certainly my input.\n", -//! &ComrakOptions::default()); +//! &Options::default()); //! //! fn iter_nodes<'a, F>(node: &'a AstNode<'a>, f: &F) //! where F : Fn(&'a AstNode<'a>) { @@ -47,7 +47,7 @@ //! }); //! //! let mut html = vec![]; -//! format_html(root, &ComrakOptions::default(), &mut html).unwrap(); +//! format_html(root, &Options::default(), &mut html).unwrap(); //! //! assert_eq!( //! String::from_utf8(html).unwrap(), @@ -100,29 +100,37 @@ pub use html::format_document as format_html; pub use html::format_document_with_plugins as format_html_with_plugins; pub use html::Anchorizer; pub use parser::{ - parse_document, parse_document_with_broken_link_callback, ComrakExtensionOptions, - ComrakOptions, ComrakParseOptions, ComrakPlugins, ComrakRenderOptions, ComrakRenderPlugins, - ListStyleType, + parse_document, parse_document_with_broken_link_callback, ExtensionOptions, ListStyleType, + Options, ParseOptions, Plugins, RenderOptions, RenderPlugins, }; pub use typed_arena::Arena; pub use xml::format_document as format_xml; pub use xml::format_document_with_plugins as format_xml_with_plugins; +/// Legacy naming of [`ExtensionOptions`] +pub type ComrakExtensionOptions = ExtensionOptions; +/// Legacy naming of [`Options`] +pub type ComrakOptions = Options; +/// Legacy naming of [`ParseOptions`] +pub type ComrakParseOptions = ParseOptions; +/// Legacy naming of [`Plugins`] +pub type ComrakPlugins<'a> = Plugins<'a>; +/// Legacy naming of [`RenderOptions`] +pub type ComrakRenderOptions = RenderOptions; +/// Legacy naming of [`RenderPlugins`] +pub type ComrakRenderPlugins<'a> = RenderPlugins<'a>; + /// Render Markdown to HTML. /// /// See the documentation of the crate root for an example. -pub fn markdown_to_html(md: &str, options: &ComrakOptions) -> String { - markdown_to_html_with_plugins(md, options, &ComrakPlugins::default()) +pub fn markdown_to_html(md: &str, options: &Options) -> String { + markdown_to_html_with_plugins(md, options, &Plugins::default()) } /// Render Markdown to HTML using plugins. /// /// See the documentation of the crate root for an example. -pub fn markdown_to_html_with_plugins( - md: &str, - options: &ComrakOptions, - plugins: &ComrakPlugins, -) -> String { +pub fn markdown_to_html_with_plugins(md: &str, options: &Options, plugins: &Plugins) -> String { let arena = Arena::new(); let root = parse_document(&arena, md, options); let mut bw = BufWriter::new(Vec::new()); @@ -136,7 +144,7 @@ pub fn version() -> &'static str { } /// Render Markdown back to CommonMark. -pub fn markdown_to_commonmark(md: &str, options: &ComrakOptions) -> String { +pub fn markdown_to_commonmark(md: &str, options: &Options) -> String { let arena = Arena::new(); let root = parse_document(&arena, md, options); let mut bw = BufWriter::new(Vec::new()); @@ -146,16 +154,16 @@ pub fn markdown_to_commonmark(md: &str, options: &ComrakOptions) -> String { /// Render Markdown to CommonMark XML. /// See https://github.com/commonmark/commonmark-spec/blob/master/CommonMark.dtd. -pub fn markdown_to_commonmark_xml(md: &str, options: &ComrakOptions) -> String { - markdown_to_commonmark_xml_with_plugins(md, options, &ComrakPlugins::default()) +pub fn markdown_to_commonmark_xml(md: &str, options: &Options) -> String { + markdown_to_commonmark_xml_with_plugins(md, options, &Plugins::default()) } /// Render Markdown to CommonMark XML using plugins. /// See https://github.com/commonmark/commonmark-spec/blob/master/CommonMark.dtd. pub fn markdown_to_commonmark_xml_with_plugins( md: &str, - options: &ComrakOptions, - plugins: &ComrakPlugins, + options: &Options, + plugins: &Plugins, ) -> String { let arena = Arena::new(); let root = parse_document(&arena, md, options); diff --git a/src/main.rs b/src/main.rs index 0fa92fbd..8595f8bc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,8 @@ //! The `comrak` binary. use comrak::{ - adapters::SyntaxHighlighterAdapter, plugins::syntect::SyntectAdapter, Arena, - ComrakExtensionOptions, ComrakOptions, ComrakParseOptions, ComrakPlugins, ComrakRenderOptions, - ListStyleType, + adapters::SyntaxHighlighterAdapter, plugins::syntect::SyntectAdapter, Arena, ExtensionOptions, + ListStyleType, Options, ParseOptions, Plugins, RenderOptions, }; use std::boxed::Box; use std::env; @@ -195,8 +194,8 @@ fn main() -> Result<(), BoxWow look at this cool \
/// link. \
@@ -93,7 +93,7 @@ pub fn parse_document<'a>(
pub fn parse_document_with_broken_link_callback<'a, 'c>(
arena: &'a Arena Hello Hello www.github.com. e = mc2. Hi1. A greeting. ↩ Definition Happy Friday! :smile: 'Hello,' "world" ... Hello.\nWorld.world there.\n\n
\n \n\n\
@@ -198,8 +198,8 @@ pub struct ComrakExtensionOptions {
/// from the GFM spec.
///
/// ```
- /// # use comrak::{markdown_to_html, ComrakOptions};
- /// let mut options = ComrakOptions::default();
+ /// # use comrak::{markdown_to_html, Options};
+ /// let mut options = Options::default();
/// options.extension.autolink = true;
/// assert_eq!(markdown_to_html("Hello www.github.com.\n", &options),
/// "a \nb \nREADME
\n");
@@ -252,8 +252,8 @@ pub struct ComrakExtensionOptions {
/// [Kramdown](https://kramdown.gettalong.org/syntax.html#footnotes).
///
/// ```
- /// # use comrak::{markdown_to_html, ComrakOptions};
- /// let mut options = ComrakOptions::default();
+ /// # use comrak::{markdown_to_html, Options};
+ /// let mut options = Options::default();
/// options.extension.footnotes = true;
/// assert_eq!(markdown_to_html("Hi[^x].\n\n[^x]: A greeting.\n", &options),
/// "\n
\n
\n");
@@ -306,18 +306,18 @@ pub struct ComrakExtensionOptions {
/// ```
///
/// ```
- /// # use comrak::{markdown_to_html, ComrakOptions};
- /// let mut options = ComrakOptions::default();
+ /// # use comrak::{markdown_to_html, Options};
+ /// let mut options = Options::default();
/// options.extension.front_matter_delimiter = Some("---".to_owned());
/// assert_eq!(
/// markdown_to_html("---\nlayout: post\n---\nText\n", &options),
- /// markdown_to_html("Text\n", &ComrakOptions::default()));
+ /// markdown_to_html("Text\n", &Options::default()));
/// ```
///
/// ```
- /// # use comrak::{format_commonmark, Arena, ComrakOptions};
+ /// # use comrak::{format_commonmark, Arena, Options};
/// use comrak::parse_document;
- /// let mut options = ComrakOptions::default();
+ /// let mut options = Options::default();
/// options.extension.front_matter_delimiter = Some("---".to_owned());
/// let arena = Arena::new();
/// let input ="---\nlayout: post\n---\nText\n";
@@ -333,8 +333,8 @@ pub struct ComrakExtensionOptions {
/// Phrases wrapped inside of ':' blocks will be replaced with emojis.
///
/// ```
- /// # use comrak::{markdown_to_html, ComrakOptions};
- /// let mut options = ComrakOptions::default();
+ /// # use comrak::{markdown_to_html, Options};
+ /// let mut options = Options::default();
/// assert_eq!(markdown_to_html("Happy Friday! :smile:", &options),
/// "
\n");
///
@@ -384,13 +384,13 @@ pub struct ComrakParseOptions {
#[derive(Default, Debug, Clone, Copy)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
/// Options for formatter functions.
-pub struct ComrakRenderOptions {
+pub struct RenderOptions {
/// [Soft line breaks](http://spec.commonmark.org/0.27/#soft-line-breaks) in the input
/// translate into hard line breaks in the output.
///
/// ```
- /// # use comrak::{markdown_to_html, ComrakOptions};
- /// let mut options = ComrakOptions::default();
+ /// # use comrak::{markdown_to_html, Options};
+ /// let mut options = Options::default();
/// assert_eq!(markdown_to_html("Hello.\nWorld.\n", &options),
/// "fn hello();\n` is used for fenced code blocks with info tags.
///
/// ```
- /// # use comrak::{markdown_to_html, ComrakOptions};
- /// let mut options = ComrakOptions::default();
+ /// # use comrak::{markdown_to_html, Options};
+ /// let mut options = Options::default();
/// assert_eq!(markdown_to_html("``` rust\nfn hello();\n```\n", &options),
/// "\n"
);
- let mut plugins = ComrakPlugins::default();
+ let mut plugins = Plugins::default();
let adapter = MockAdapter {};
plugins.render.codefence_syntax_highlighter = Some(&adapter);
@@ -68,7 +68,7 @@ fn heading_adapter_plugin() {
}
}
- let mut plugins = ComrakPlugins::default();
+ let mut plugins = Plugins::default();
let adapter = MockAdapter {};
plugins.render.heading_adapter = Some(&adapter);
@@ -99,7 +99,7 @@ fn syntect_plugin() {
"\n"
);
- let mut plugins = ComrakPlugins::default();
+ let mut plugins = Plugins::default();
plugins.render.codefence_syntax_highlighter = Some(&adapter);
html_plugins(input, expected, &plugins);
diff --git a/src/tests/propfuzz.rs b/src/tests/propfuzz.rs
index f9693cca..f38d8735 100644
--- a/src/tests/propfuzz.rs
+++ b/src/tests/propfuzz.rs
@@ -6,8 +6,8 @@ use propfuzz::prelude::*;
#[cfg(not(target_arch = "wasm32"))]
#[propfuzz]
fn propfuzz_doesnt_crash(md: String) {
- let options = ComrakOptions {
- extension: ComrakExtensionOptions {
+ let options = Options {
+ extension: ExtensionOptions {
strikethrough: true,
tagfilter: true,
table: true,
@@ -21,12 +21,12 @@ fn propfuzz_doesnt_crash(md: String) {
#[cfg(feature = "shortcodes")]
shortcodes: true,
},
- parse: ComrakParseOptions {
+ parse: ParseOptions {
smart: true,
default_info_string: Some("Rust".to_string()),
relaxed_tasklist_matching: true,
},
- render: ComrakRenderOptions {
+ render: RenderOptions {
hardbreaks: true,
github_pre_lang: true,
full_info_string: true,
diff --git a/src/tests/regressions.rs b/src/tests/regressions.rs
index 71950461..dc8a0809 100644
--- a/src/tests/regressions.rs
+++ b/src/tests/regressions.rs
@@ -81,18 +81,18 @@ fn no_panic_on_empty_bookended_atx_headers() {
fn no_stack_smash_html() {
let s: String = ">".repeat(150_000);
let arena = Arena::new();
- let root = parse_document(&arena, &s, &ComrakOptions::default());
+ let root = parse_document(&arena, &s, &Options::default());
let mut output = vec![];
- html::format_document(root, &ComrakOptions::default(), &mut output).unwrap()
+ html::format_document(root, &Options::default(), &mut output).unwrap()
}
#[test]
fn no_stack_smash_cm() {
let s: String = ">".repeat(150_000);
let arena = Arena::new();
- let root = parse_document(&arena, &s, &ComrakOptions::default());
+ let root = parse_document(&arena, &s, &Options::default());
let mut output = vec![];
- cm::format_document(root, &ComrakOptions::default(), &mut output).unwrap()
+ cm::format_document(root, &Options::default(), &mut output).unwrap()
}
#[test]
diff --git a/src/xml.rs b/src/xml.rs
index 35f80400..c73e30db 100644
--- a/src/xml.rs
+++ b/src/xml.rs
@@ -1,5 +1,5 @@
use crate::nodes::{AstNode, ListType, NodeCode, NodeValue};
-use crate::parser::{ComrakOptions, ComrakPlugins};
+use crate::parser::{Options, Plugins};
use once_cell::sync::Lazy;
use std::io::{self, Write};
@@ -8,18 +8,18 @@ use crate::nodes::NodeHtmlBlock;
/// Formats an AST as HTML, modified by the given options.
pub fn format_document<'a>(
root: &'a AstNode<'a>,
- options: &ComrakOptions,
+ options: &Options,
output: &mut dyn Write,
) -> io::Result<()> {
- format_document_with_plugins(root, options, output, &ComrakPlugins::default())
+ format_document_with_plugins(root, options, output, &Plugins::default())
}
/// Formats an AST as HTML, modified by the given options. Accepts custom plugins.
pub fn format_document_with_plugins<'a>(
root: &'a AstNode<'a>,
- options: &ComrakOptions,
+ options: &Options,
output: &mut dyn Write,
- plugins: &ComrakPlugins,
+ plugins: &Plugins,
) -> io::Result<()> {
output.write_all(b"\n")?;
output.write_all(b"\n")?;
@@ -29,17 +29,13 @@ pub fn format_document_with_plugins<'a>(
struct XmlFormatter<'o> {
output: &'o mut dyn Write,
- options: &'o ComrakOptions,
- _plugins: &'o ComrakPlugins<'o>,
+ options: &'o Options,
+ _plugins: &'o Plugins<'o>,
indent: u32,
}
impl<'o> XmlFormatter<'o> {
- fn new(
- options: &'o ComrakOptions,
- output: &'o mut dyn Write,
- plugins: &'o ComrakPlugins,
- ) -> Self {
+ fn new(options: &'o Options, output: &'o mut dyn Write, plugins: &'o Plugins) -> Self {
XmlFormatter {
options,
output,
\n");
///
@@ -417,8 +417,8 @@ pub struct ComrakRenderOptions {
/// Enable full info strings for code blocks
///
/// ```
- /// # use comrak::{markdown_to_html, ComrakOptions};
- /// let mut options = ComrakOptions::default();
+ /// # use comrak::{markdown_to_html, Options};
+ /// let mut options = Options::default();
/// assert_eq!(markdown_to_html("``` rust extra info\nfn hello();\n```\n", &options),
/// "fn hello();\n
\n");
///
@@ -432,10 +432,10 @@ pub struct ComrakRenderOptions {
/// The wrap column when outputting CommonMark.
///
/// ```
- /// # use comrak::{parse_document, ComrakOptions, format_commonmark};
+ /// # use comrak::{parse_document, Options, format_commonmark};
/// # fn main() {
/// # let arena = typed_arena::Arena::new();
- /// let mut options = ComrakOptions::default();
+ /// let mut options = Options::default();
/// let node = parse_document(&arena, "hello hello hello hello hello hello", &options);
/// let mut output = vec![];
/// format_commonmark(node, &options, &mut output).unwrap();
@@ -454,8 +454,8 @@ pub struct ComrakRenderOptions {
/// Allow rendering of raw HTML and potentially dangerous links.
///
/// ```
- /// # use comrak::{markdown_to_html, ComrakOptions};
- /// let mut options = ComrakOptions::default();
+ /// # use comrak::{markdown_to_html, Options};
+ /// let mut options = Options::default();
/// let input = "\n\n\
/// Possibly .\n\n\
/// [Dangerous](javascript:alert(document.cookie)).\n\n\
@@ -478,8 +478,8 @@ pub struct ComrakRenderOptions {
/// Escape raw HTML instead of clobbering it.
/// ```
- /// # use comrak::{markdown_to_html, ComrakOptions};
- /// let mut options = ComrakOptions::default();
+ /// # use comrak::{markdown_to_html, Options};
+ /// let mut options = Options::default();
/// let input = "italic text";
///
/// assert_eq!(markdown_to_html(input, &options),
@@ -498,8 +498,8 @@ pub struct ComrakRenderOptions {
/// * `ListStyleType::Star` to use `*`
///
/// ```rust
- /// # use comrak::{markdown_to_commonmark, ComrakOptions, ListStyleType};
- /// let mut options = ComrakOptions::default();
+ /// # use comrak::{markdown_to_commonmark, Options, ListStyleType};
+ /// let mut options = Options::default();
/// let input = "- one\n- two\n- three";
/// assert_eq!(markdown_to_commonmark(input, &options),
/// "- one\n- two\n- three\n"); // default is Dash
@@ -519,8 +519,8 @@ pub struct ComrakRenderOptions {
/// Not yet compatible with extension.description_lists.
///
/// ```rust
- /// # use comrak::{markdown_to_commonmark_xml, ComrakOptions};
- /// let mut options = ComrakOptions::default();
+ /// # use comrak::{markdown_to_commonmark_xml, Options};
+ /// let mut options = Options::default();
/// options.render.sourcepos = true;
/// let input = "Hello *world*!";
/// let xml = markdown_to_commonmark_xml(input, &options);
@@ -531,23 +531,23 @@ pub struct ComrakRenderOptions {
#[derive(Default, Debug)]
/// Umbrella plugins struct.
-pub struct ComrakPlugins<'p> {
+pub struct Plugins<'p> {
/// Configure render-time plugins.
- pub render: ComrakRenderPlugins<'p>,
+ pub render: RenderPlugins<'p>,
}
#[derive(Default)]
/// Plugins for alternative rendering.
-pub struct ComrakRenderPlugins<'p> {
+pub struct RenderPlugins<'p> {
/// Provide a syntax highlighter adapter implementation for syntax
/// highlighting of codefence blocks.
/// ```
- /// # use comrak::{markdown_to_html, ComrakOptions, ComrakPlugins, markdown_to_html_with_plugins};
+ /// # use comrak::{markdown_to_html, Options, Plugins, markdown_to_html_with_plugins};
/// # use comrak::adapters::SyntaxHighlighterAdapter;
/// use std::collections::HashMap;
/// use std::io::{self, Write};
- /// let options = ComrakOptions::default();
- /// let mut plugins = ComrakPlugins::default();
+ /// let options = Options::default();
+ /// let mut plugins = Plugins::default();
/// let input = "```rust\nfn main<'a>();\n```";
///
/// assert_eq!(markdown_to_html_with_plugins(input, &options, &plugins),
@@ -580,9 +580,9 @@ pub struct ComrakRenderPlugins<'p> {
pub heading_adapter: Option<&'p dyn HeadingAdapter>,
}
-impl Debug for ComrakRenderPlugins<'_> {
+impl Debug for RenderPlugins<'_> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
- f.debug_struct("ComrakRenderPlugins")
+ f.debug_struct("RenderPlugins")
.field(
"codefence_syntax_highlighter",
&"impl SyntaxHighlighterAdapter",
@@ -608,7 +608,7 @@ impl<'a, 'o, 'c> Parser<'a, 'o, 'c> {
fn new(
arena: &'a Arenafn hello();\n