Skip to content

Commit 2857f3c

Browse files
authored
Merge pull request #625 from kivikakk/push-kqrmqkytywtw
improvements from #617.
2 parents d983fea + 8a13eee commit 2857f3c

File tree

13 files changed

+321
-324
lines changed

13 files changed

+321
-324
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ build-cmark-gfm:
2929

3030
build-markdown-it:
3131
cd ${ROOT}/vendor/markdown-it && \
32-
cargo build --release && \
32+
cargo build --release --no-default-features && \
3333
cp target/release/markdown-it ${ROOT}/benches/markdown-it
3434

3535
build-pulldown-cmark:

examples/custom_formatter_alt_text.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ fn main() {
5656
formatter,
5757
(),
5858
)
59-
.unwrap_or_else(|_| unreachable!("writing to Vec<u8> cannot fail"));
59+
.unwrap_or_else(|_| unreachable!("writing to String cannot fail"));
6060

6161
println!("{out}");
6262
}

examples/iterator_replace.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ fn replace_text(document: &str, orig_string: &str, replacement: &str) -> String
2424
}
2525

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

3233
println!("{}", html);

src/cm.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
use std::cmp::max;
2+
use std::fmt;
3+
use std::io::{self, Write};
4+
use std::str;
5+
pub use typed_arena::Arena;
6+
17
use crate::ctype::{isalpha, isdigit, ispunct, isspace};
28
use crate::nodes::{
39
AstNode, ListDelimType, ListType, NodeAlert, NodeCodeBlock, NodeHeading, NodeHtmlBlock,
@@ -8,13 +14,7 @@ use crate::parser::shortcodes::NodeShortCode;
814
use crate::parser::{Options, WikiLinksMode};
915
use crate::scanners;
1016
use crate::strings::trim_start_match;
11-
use crate::{node_matches, nodes, Plugins};
12-
pub use typed_arena::Arena;
13-
14-
use std::cmp::max;
15-
use std::fmt;
16-
use std::io::{self, Write};
17-
use std::str;
17+
use crate::{node_matches, Plugins};
1818

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

294294
fn get_in_tight_list_item(&self, node: &'a AstNode<'a>) -> bool {
295-
let tmp = match nodes::containing_block(node) {
295+
let tmp = match node.containing_block() {
296296
Some(tmp) => tmp,
297297
None => return false,
298298
};

src/html.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
mod anchorizer;
88
mod context;
99

10+
use std::collections::HashMap;
11+
use std::fmt::{self, Write};
12+
use std::str;
13+
1014
use crate::adapters::HeadingMeta;
1115
use crate::character_set::character_set;
1216
use crate::ctype::isspace;
@@ -16,9 +20,6 @@ use crate::nodes::{
1620
};
1721
use crate::parser::{Options, Plugins};
1822
use crate::{node_matches, scanners};
19-
use std::collections::HashMap;
20-
use std::fmt::{self, Write};
21-
use std::str;
2223

2324
#[doc(hidden)]
2425
pub use anchorizer::Anchorizer;

src/lib.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
//!
88
//! ```
99
//! use comrak::{markdown_to_html, Options};
10-
//! assert_eq!(markdown_to_html("Hello, **世界**!", &Options::default()),
11-
//! "<p>Hello, <strong>世界</strong>!</p>\n");
10+
//! assert_eq!(
11+
//! markdown_to_html("Olá, **世界**!", &Options::default()),
12+
//! "<p>Olá, <strong>世界</strong>!</p>\n"
13+
//! );
1214
//! ```
1315
//!
1416
//! Or you can parse the input into an AST yourself, manipulate it, and then use your desired
@@ -23,12 +25,12 @@
2325
//!
2426
//! let root = parse_document(
2527
//! &arena,
26-
//! "This is my input.\n\n1. Also [my](#) input.\n2. Certainly *my* input.\n",
28+
//! "Hello, pretty world!\n\n1. Do you like [pretty](#) paintings?\n2. Or *pretty* music?\n",
2729
//! &Options::default());
2830
//!
2931
//! for node in root.descendants() {
3032
//! if let NodeValue::Text(ref mut text) = node.data.borrow_mut().value {
31-
//! *text = text.replace("my", "your");
33+
//! *text = text.replace("pretty", "beautiful");
3234
//! }
3335
//! }
3436
//!
@@ -37,10 +39,10 @@
3739
//!
3840
//! assert_eq!(
3941
//! &html,
40-
//! "<p>This is your input.</p>\n\
42+
//! "<p>Hello, beautiful world!</p>\n\
4143
//! <ol>\n\
42-
//! <li>Also <a href=\"#\">your</a> input.</li>\n\
43-
//! <li>Certainly <em>your</em> input.</li>\n\
44+
//! <li>Do you like <a href=\"#\">beautiful</a> paintings?</li>\n\
45+
//! <li>Or <em>beautiful</em> music?</li>\n\
4446
//! </ol>\n");
4547
//! # }
4648
//! ```

0 commit comments

Comments
 (0)