From bf9460fddeec7366df117ddae13b7d31d3354313 Mon Sep 17 00:00:00 2001
From: Titus Wormer ".to_string());
+ context.tag(" ".to_string());
}
/// Handle [`Enter`][EventType::Enter]:[`Resource`][TokenType::Resource].
@@ -704,11 +710,16 @@ fn on_exit_autolink_email(context: &mut CompileContext) {
&from_exit_event(context.events, context.index),
false,
);
- context.push(format!(
- "{}",
- sanitize_uri(slice.as_str(), &context.protocol_href),
- context.encode_opt(&slice)
+ // To do:
+ context.tag(format!(
+ "",
+ sanitize_uri(
+ format!("mailto:{}", slice.as_str()).as_str(),
+ &context.protocol_href
+ )
));
+ context.push(context.encode_opt(&slice));
+ context.tag("".to_string());
}
/// Handle [`Exit`][EventType::Exit]:[`AutolinkProtocol`][TokenType::AutolinkProtocol].
@@ -718,16 +729,17 @@ fn on_exit_autolink_protocol(context: &mut CompileContext) {
&from_exit_event(context.events, context.index),
false,
);
- context.push(format!(
- "{}",
- sanitize_uri(slice.as_str(), &context.protocol_href),
- context.encode_opt(&slice)
+ context.tag(format!(
+ "",
+ sanitize_uri(slice.as_str(), &context.protocol_href)
));
+ context.push(context.encode_opt(&slice));
+ context.tag("".to_string());
}
/// Handle [`Exit`][EventType::Exit]:{[`HardBreakEscape`][TokenType::HardBreakEscape],[`HardBreakTrailing`][TokenType::HardBreakTrailing]}.
fn on_exit_break(context: &mut CompileContext) {
- context.push("".to_string());
+ context.tag("
".to_string());
+ context.tag("".to_string());
}
/// Handle [`Exit`][EventType::Exit]:[`CodeTextLineEnding`][TokenType::CodeTextLineEnding].
@@ -873,7 +883,6 @@ fn on_exit_drop(context: &mut CompileContext) {
/// Handle [`Exit`][EventType::Exit]:{[`CodeTextData`][TokenType::CodeTextData],[`Data`][TokenType::Data],[`CharacterEscapeValue`][TokenType::CharacterEscapeValue]}.
fn on_exit_data(context: &mut CompileContext) {
// Just output it.
- // last_was_tag = false;
context.push(context.encode_opt(&serialize(
context.codes,
&from_exit_event(context.events, context.index),
@@ -930,7 +939,7 @@ fn on_exit_heading_atx(context: &mut CompileContext) {
.take()
.expect("`atx_opening_sequence_size` must be set in headings");
- context.push(format!("", rank));
+ context.tag(format!("", rank));
}
/// Handle [`Exit`][EventType::Exit]:[`HeadingAtxSequence`][TokenType::HeadingAtxSequence].
@@ -944,7 +953,7 @@ fn on_exit_heading_atx_sequence(context: &mut CompileContext) {
)
.len();
context.atx_opening_sequence_size = Some(rank);
- context.push(format!("
".to_string());
if let Some(count) = context.code_fenced_fences_count.take() {
if count < 2 {
@@ -855,7 +865,7 @@ fn on_exit_code_text(context: &mut CompileContext) {
} else {
result
});
- context.push("".to_string());
}
/// Handle [`Enter`][EventType::Enter]:[`CodeFenced`][TokenType::CodeFenced].
@@ -608,13 +614,13 @@ fn on_enter_code_fenced(context: &mut CompileContext) {
context.code_flow_seen_data = Some(false);
context.line_ending_if_needed();
// Note that no `>` is used, which is added later.
- context.push("
".to_string());
+ context.tag("".to_string());
+ context.tag("
".to_string());
context.buffer();
}
@@ -662,7 +668,7 @@ fn on_enter_image(context: &mut CompileContext) {
destination: None,
title: None,
});
- // tags = undefined // Disallow tags.
+ context.tags = false; // Disallow tags.
}
/// Handle [`Enter`][EventType::Enter]:[`Link`][TokenType::Link].
@@ -679,7 +685,7 @@ fn on_enter_link(context: &mut CompileContext) {
/// Handle [`Enter`][EventType::Enter]:[`Paragraph`][TokenType::Paragraph].
fn on_enter_paragraph(context: &mut CompileContext) {
- context.buf_tail_mut().push("
".to_string());
+ context.tag("
".to_string());
}
/// Handle [`Exit`][EventType::Exit]:[`CharacterReferenceMarker`][TokenType::CharacterReferenceMarker].
@@ -785,8 +797,7 @@ fn on_exit_code_fenced_fence(context: &mut CompileContext) {
};
if count == 0 {
- context.push(">".to_string());
- // tag = true;
+ context.tag(">".to_string());
context.slurp_one_line_ending = true;
}
@@ -796,8 +807,7 @@ fn on_exit_code_fenced_fence(context: &mut CompileContext) {
/// Handle [`Exit`][EventType::Exit]:[`CodeFencedFenceInfo`][TokenType::CodeFencedFenceInfo].
fn on_exit_code_fenced_fence_info(context: &mut CompileContext) {
let value = context.resume();
- context.push(format!(" class=\"language-{}\"", value));
- // tag = true;
+ context.tag(format!(" class=\"language-{}\"", value));
}
/// Handle [`Exit`][EventType::Exit]:{[`CodeFenced`][TokenType::CodeFenced],[`CodeIndented`][TokenType::CodeIndented]}.
@@ -823,7 +833,7 @@ fn on_exit_code_flow(context: &mut CompileContext) {
context.line_ending_if_needed();
}
- context.push("