Skip to content

Commit 90b5aef

Browse files
authored
Merge branch 'main' into test/unordered-and-ordered-list
Signed-off-by: Titus <[email protected]>
2 parents 3080f45 + eea185e commit 90b5aef

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+164
-182
lines changed

Untitled.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ micromark.js: `atLineEnding` in html (text) should always eat arbitrary whitespa
66
```rs
77
// ---------------------
88
// Useful helper:
9-
extern crate std;
109
use std::println;
1110
use alloc::string::String;
1211

benches/bench.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#[macro_use]
2-
extern crate criterion;
3-
use criterion::{BenchmarkId, Criterion};
1+
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
42
use std::fs;
53

64
fn readme(c: &mut Criterion) {

build.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
extern crate reqwest;
21
use regex::Regex;
32
use std::fs;
43

@@ -67,7 +66,6 @@ async fn commonmark() {
6766
// > 👉 **Important**: this module is generated by `build.rs`.
6867
// > It is generate from the latest CommonMark website.
6968
70-
extern crate markdown;
7169
use markdown::{{to_html_with_options, CompileOptions, Options}};
7270
use pretty_assertions::assert_eq;
7371

examples/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
extern crate markdown;
2-
31
fn main() -> Result<(), String> {
42
// Turn on debugging.
53
// You can show it with `RUST_LOG=debug cargo run --example lib`

fuzz/fuzz_targets/markdown.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
#![no_main]
22
use libfuzzer_sys::fuzz_target;
3-
extern crate markdown;
43

54
fuzz_target!(|data: &[u8]| {
65
if let Ok(s) = std::str::from_utf8(data) {
76
let _ = markdown::to_html(s);
8-
let _ = markdown::to_html_with_options(
9-
s,
10-
&markdown::Options::gfm()
11-
);
7+
let _ = markdown::to_html_with_options(s, &markdown::Options::gfm());
128
let _ = markdown::to_mdast(s, &markdown::ParseOptions::default());
139
let _ = markdown::to_mdast(s, &markdown::ParseOptions::gfm());
1410
}

readme.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,6 @@ cargo add [email protected]
9090
## Use
9191

9292
```rs
93-
extern crate markdown;
94-
9593
fn main() {
9694
println!("{}", markdown::to_html("## Hello, *world*!"));
9795
}
@@ -106,8 +104,6 @@ Yields:
106104
Extensions (in this case GFM):
107105

108106
```rs
109-
extern crate markdown;
110-
111107
fn main() -> Result<(), String> {
112108
println!(
113109
"{}",
@@ -136,8 +132,6 @@ Yields:
136132
Syntax tree ([mdast][]):
137133

138134
```rs
139-
extern crate markdown;
140-
141135
fn main() -> Result<(), String> {
142136
println!(
143137
"{:?}",

src/configuration.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1236,7 +1236,6 @@ impl Options {
12361236

12371237
#[cfg(test)]
12381238
mod tests {
1239-
extern crate std;
12401239
use super::*;
12411240
use crate::util::mdx::Signal;
12421241
use alloc::format;

src/construct/attention.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,10 @@ use alloc::{vec, vec::Vec};
9292
struct Sequence {
9393
/// Marker as a byte (`u8`) used in this sequence.
9494
marker: u8,
95-
/// The depth in events where this sequence resides.
96-
balance: usize,
95+
/// We track whether sequences are in balanced events, and where those
96+
/// events start, so that one attention doesn’t start in say, one link, and
97+
/// end in another.
98+
stack: Vec<usize>,
9799
/// The index into events where this sequence’s `Enter` currently resides.
98100
index: usize,
99101
/// The (shifted) point where this sequence starts.
@@ -172,7 +174,7 @@ pub fn resolve(tokenizer: &mut Tokenizer) -> Option<Subresult> {
172174
// An opener matching our closer:
173175
if sequence_open.open
174176
&& sequence_close.marker == sequence_open.marker
175-
&& sequence_close.balance == sequence_open.balance
177+
&& sequence_close.stack == sequence_open.stack
176178
{
177179
// If the opening can close or the closing can open,
178180
// and the close size *is not* a multiple of three,
@@ -219,23 +221,20 @@ pub fn resolve(tokenizer: &mut Tokenizer) -> Option<Subresult> {
219221
}
220222

221223
tokenizer.map.consume(&mut tokenizer.events);
222-
223224
None
224225
}
225226

226227
/// Get sequences.
227228
fn get_sequences(tokenizer: &mut Tokenizer) -> Vec<Sequence> {
228229
let mut index = 0;
229-
let mut balance = 0;
230+
let mut stack = vec![];
230231
let mut sequences = vec![];
231232

232233
while index < tokenizer.events.len() {
233234
let enter = &tokenizer.events[index];
234235

235-
if enter.kind == Kind::Enter {
236-
balance += 1;
237-
238-
if enter.name == Name::AttentionSequence {
236+
if enter.name == Name::AttentionSequence {
237+
if enter.kind == Kind::Enter {
239238
let end = index + 1;
240239
let exit = &tokenizer.events[end];
241240

@@ -255,7 +254,7 @@ fn get_sequences(tokenizer: &mut Tokenizer) -> Vec<Sequence> {
255254

256255
sequences.push(Sequence {
257256
index,
258-
balance,
257+
stack: stack.clone(),
259258
start_point: enter.point.clone(),
260259
end_point: exit.point.clone(),
261260
size: exit.point.index - enter.point.index,
@@ -272,8 +271,10 @@ fn get_sequences(tokenizer: &mut Tokenizer) -> Vec<Sequence> {
272271
marker,
273272
});
274273
}
274+
} else if enter.kind == Kind::Enter {
275+
stack.push(index);
275276
} else {
276-
balance -= 1;
277+
stack.pop();
277278
}
278279

279280
index += 1;

src/construct/document.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ pub fn flow_end(tokenizer: &mut Tokenizer) -> State {
423423
if !document_lazy_continuation_current && !child.events.is_empty() {
424424
let before = skip::opt_back(&child.events, child.events.len() - 1, &[Name::LineEnding]);
425425
let name = &child.events[before].name;
426-
if name == &Name::Content {
426+
if name == &Name::Content || name == &Name::HeadingSetextUnderline {
427427
document_lazy_continuation_current = true;
428428
}
429429
}

src/construct/gfm_autolink_literal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ pub fn www_prefix_inside(tokenizer: &mut Tokenizer) -> State {
334334
/// ```
335335
pub fn www_prefix_after(tokenizer: &mut Tokenizer) -> State {
336336
// If there is *anything*, we can link.
337-
if tokenizer.current == None {
337+
if tokenizer.current.is_none() {
338338
State::Nok
339339
} else {
340340
State::Ok

0 commit comments

Comments
 (0)