Skip to content

Commit 8446dd5

Browse files
committed
rework inlines to use append_value.
1 parent 06726cf commit 8446dd5

File tree

2 files changed

+297
-227
lines changed

2 files changed

+297
-227
lines changed

src/parser/autolink.rs

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,7 @@ fn validate_protocol(protocol: &str, contents: &[u8], cursor: usize) -> bool {
226226
&& &contents[cursor - rewind..cursor] == protocol.as_bytes()
227227
}
228228

229-
pub fn www_match<'a>(
230-
subject: &mut Subject,
231-
// arena: &'a mut Arena<Ast>,
232-
// contents: &[u8],
233-
// i: usize,
234-
// relaxed_autolinks: bool,
235-
) -> Option<(AstNode, usize, usize)> {
229+
pub fn www_match<'a>(subject: &mut Subject, node: AstNode) -> Option<(AstNode, usize, usize)> {
236230
const WWW_DELIMS: [bool; 256] = character_set!(b"*_~([");
237231

238232
let i = subject.pos;
@@ -265,13 +259,15 @@ pub fn www_match<'a>(
265259
let mut url = "http://".to_string();
266260
url.push_str(str::from_utf8(&subject.input[i..link_end + i]).unwrap());
267261

268-
let inl = make_inline_node(
262+
let inl = node.append_value(
269263
subject.arena,
270-
NodeValue::Link(NodeLink {
271-
url,
272-
title: String::new(),
273-
}),
274-
(0, 1, 0, 1).into(),
264+
make_inline(
265+
NodeValue::Link(NodeLink {
266+
url,
267+
title: String::new(),
268+
}),
269+
(0, 1, 0, 1).into(),
270+
),
275271
);
276272

277273
inl.append_value(
@@ -392,13 +388,7 @@ fn autolink_delim(data: &[u8], mut link_end: usize, relaxed_autolinks: bool) ->
392388
link_end
393389
}
394390

395-
pub fn url_match<'a>(
396-
subject: &mut Subject,
397-
// arena: &'a mut Arena<Ast>,
398-
// contents: &[u8],
399-
// i: usize,
400-
// relaxed_autolinks: bool,
401-
) -> Option<(AstNode, usize, usize)> {
391+
pub fn url_match<'a>(subject: &mut Subject, node: AstNode) -> Option<(AstNode, usize, usize)> {
402392
const SCHEMES: [&[u8]; 3] = [b"http", b"https", b"ftp"];
403393

404394
let i = subject.pos;
@@ -441,13 +431,15 @@ pub fn url_match<'a>(
441431
let url = str::from_utf8(&subject.input[i - rewind..i + link_end])
442432
.unwrap()
443433
.to_string();
444-
let inl = make_inline_node(
434+
let inl = node.append_value(
445435
subject.arena,
446-
NodeValue::Link(NodeLink {
447-
url: url.clone(),
448-
title: String::new(),
449-
}),
450-
(0, 1, 0, 1).into(),
436+
make_inline(
437+
NodeValue::Link(NodeLink {
438+
url: url.clone(),
439+
title: String::new(),
440+
}),
441+
(0, 1, 0, 1).into(),
442+
),
451443
);
452444

453445
inl.append_value(

0 commit comments

Comments
 (0)