Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ build-cmark-gfm:

build-markdown-it:
cd ${ROOT}/vendor/markdown-it && \
cargo build --release && \
cargo build --release --no-default-features && \
cp target/release/markdown-it ${ROOT}/benches/markdown-it

build-pulldown-cmark:
Expand Down
2 changes: 1 addition & 1 deletion examples/custom_formatter_alt_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fn main() {
formatter,
(),
)
.unwrap_or_else(|_| unreachable!("writing to Vec<u8> cannot fail"));
.unwrap_or_else(|_| unreachable!("writing to String cannot fail"));

println!("{out}");
}
7 changes: 4 additions & 3 deletions examples/iterator_replace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ fn replace_text(document: &str, orig_string: &str, replacement: &str) -> String
}

fn main() {
let doc = "This is my input.\n\n1. Also [my](#) input.\n2. Certainly *my* input.\n";
let orig = "my";
let repl = "your";
let doc =
"Hello, pretty world!\n\n1. Do you like [pretty](#) paintings?\n2. Or *pretty* music?\n";
let orig = "pretty";
let repl = "beautiful";
let html = replace_text(doc, orig, repl);

println!("{}", html);
Expand Down
16 changes: 8 additions & 8 deletions src/cm.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
use std::cmp::max;
use std::fmt;
use std::io::{self, Write};
use std::str;
pub use typed_arena::Arena;

use crate::ctype::{isalpha, isdigit, ispunct, isspace};
use crate::nodes::{
AstNode, ListDelimType, ListType, NodeAlert, NodeCodeBlock, NodeHeading, NodeHtmlBlock,
Expand All @@ -8,13 +14,7 @@ use crate::parser::shortcodes::NodeShortCode;
use crate::parser::{Options, WikiLinksMode};
use crate::scanners;
use crate::strings::trim_start_match;
use crate::{node_matches, nodes, Plugins};
pub use typed_arena::Arena;

use std::cmp::max;
use std::fmt;
use std::io::{self, Write};
use std::str;
use crate::{node_matches, Plugins};

/// Formats an AST as CommonMark, modified by the given options.
pub fn format_document<'a>(
Expand Down Expand Up @@ -292,7 +292,7 @@ impl<'a, 'o, 'c> CommonMarkFormatter<'a, 'o, 'c> {
}

fn get_in_tight_list_item(&self, node: &'a AstNode<'a>) -> bool {
let tmp = match nodes::containing_block(node) {
let tmp = match node.containing_block() {
Some(tmp) => tmp,
None => return false,
};
Expand Down
7 changes: 4 additions & 3 deletions src/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
mod anchorizer;
mod context;

use std::collections::HashMap;
use std::fmt::{self, Write};
use std::str;

use crate::adapters::HeadingMeta;
use crate::character_set::character_set;
use crate::ctype::isspace;
Expand All @@ -16,9 +20,6 @@ use crate::nodes::{
};
use crate::parser::{Options, Plugins};
use crate::{node_matches, scanners};
use std::collections::HashMap;
use std::fmt::{self, Write};
use std::str;

#[doc(hidden)]
pub use anchorizer::Anchorizer;
Expand Down
16 changes: 9 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
//!
//! ```
//! use comrak::{markdown_to_html, Options};
//! assert_eq!(markdown_to_html("Hello, **世界**!", &Options::default()),
//! "<p>Hello, <strong>世界</strong>!</p>\n");
//! assert_eq!(
//! markdown_to_html("Olá, **世界**!", &Options::default()),
//! "<p>Olá, <strong>世界</strong>!</p>\n"
//! );
//! ```
//!
//! Or you can parse the input into an AST yourself, manipulate it, and then use your desired
Expand All @@ -23,12 +25,12 @@
//!
//! let root = parse_document(
//! &arena,
//! "This is my input.\n\n1. Also [my](#) input.\n2. Certainly *my* input.\n",
//! "Hello, pretty world!\n\n1. Do you like [pretty](#) paintings?\n2. Or *pretty* music?\n",
//! &Options::default());
//!
//! for node in root.descendants() {
//! if let NodeValue::Text(ref mut text) = node.data.borrow_mut().value {
//! *text = text.replace("my", "your");
//! *text = text.replace("pretty", "beautiful");
//! }
//! }
//!
Expand All @@ -37,10 +39,10 @@
//!
//! assert_eq!(
//! &html,
//! "<p>This is your input.</p>\n\
//! "<p>Hello, beautiful world!</p>\n\
//! <ol>\n\
//! <li>Also <a href=\"#\">your</a> input.</li>\n\
//! <li>Certainly <em>your</em> input.</li>\n\
//! <li>Do you like <a href=\"#\">beautiful</a> paintings?</li>\n\
//! <li>Or <em>beautiful</em> music?</li>\n\
//! </ol>\n");
//! # }
//! ```
Expand Down
Loading