From 692101146c5a23a0d33dbe45d23ee248b7c07ec0 Mon Sep 17 00:00:00 2001
From: Titus Wormer ".to_string());
}
-fn on_exit_label(context: &mut CompileContext, _event: &Event) {
+/// Handle [`Exit`][EventType::Exit]:[`Label`][TokenType::Label].
+fn on_exit_label(context: &mut CompileContext) {
let buf = context.resume();
let media = context.media_stack.last_mut().unwrap();
media.label = Some(buf);
}
-fn on_exit_label_text(context: &mut CompileContext, _event: &Event) {
+/// Handle [`Exit`][EventType::Exit]:[`LabelText`][TokenType::LabelText].
+fn on_exit_label_text(context: &mut CompileContext) {
let media = context.media_stack.last_mut().unwrap();
media.label_id = Some(serialize(
context.codes,
@@ -675,7 +697,8 @@ fn on_exit_label_text(context: &mut CompileContext, _event: &Event) {
));
}
-fn on_exit_reference_string(context: &mut CompileContext, _event: &Event) {
+/// Handle [`Exit`][EventType::Exit]:[`ReferenceString`][TokenType::ReferenceString].
+fn on_exit_reference_string(context: &mut CompileContext) {
// Drop stuff.
context.resume();
let media = context.media_stack.last_mut().unwrap();
@@ -686,20 +709,23 @@ fn on_exit_reference_string(context: &mut CompileContext, _event: &Event) {
));
}
-fn on_exit_resource_destination_string(context: &mut CompileContext, _event: &Event) {
+/// Handle [`Exit`][EventType::Exit]:[`ResourceDestinationString`][TokenType::ResourceDestinationString].
+fn on_exit_resource_destination_string(context: &mut CompileContext) {
let buf = context.resume();
let media = context.media_stack.last_mut().unwrap();
media.destination = Some(buf);
context.ignore_encode = false;
}
-fn on_exit_resource_title_string(context: &mut CompileContext, _event: &Event) {
+/// Handle [`Exit`][EventType::Exit]:[`ResourceTitleString`][TokenType::ResourceTitleString].
+fn on_exit_resource_title_string(context: &mut CompileContext) {
let buf = context.resume();
let media = context.media_stack.last_mut().unwrap();
media.title = Some(buf);
}
-fn on_exit_media(context: &mut CompileContext, _event: &Event) {
+/// Handle [`Exit`][EventType::Exit]:{[`Image`][TokenType::Image],[`Link`][TokenType::Link]}.
+fn on_exit_media(context: &mut CompileContext) {
let mut is_in_image = false;
let mut index = 0;
// Skip current.
@@ -762,7 +788,8 @@ fn on_exit_media(context: &mut CompileContext, _event: &Event) {
context.push(result);
}
-fn on_exit_push(context: &mut CompileContext, _event: &Event) {
+/// 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(
@@ -772,7 +799,8 @@ fn on_exit_push(context: &mut CompileContext, _event: &Event) {
)));
}
-fn on_exit_autolink_email(context: &mut CompileContext, _event: &Event) {
+/// Handle [`Exit`][EventType::Exit]:[`AutolinkEmail`][TokenType::AutolinkEmail].
+fn on_exit_autolink_email(context: &mut CompileContext) {
let slice = serialize(
context.codes,
&from_exit_event(context.events, context.index),
@@ -785,7 +813,8 @@ fn on_exit_autolink_email(context: &mut CompileContext, _event: &Event) {
));
}
-fn on_exit_autolink_protocol(context: &mut CompileContext, _event: &Event) {
+/// Handle [`Exit`][EventType::Exit]:[`AutolinkProtocol`][TokenType::AutolinkProtocol].
+fn on_exit_autolink_protocol(context: &mut CompileContext) {
let slice = serialize(
context.codes,
&from_exit_event(context.events, context.index),
@@ -798,19 +827,23 @@ fn on_exit_autolink_protocol(context: &mut CompileContext, _event: &Event) {
));
}
-fn on_exit_character_reference_marker(context: &mut CompileContext, _event: &Event) {
+/// Handle [`Exit`][EventType::Exit]:[`CharacterReferenceMarker`][TokenType::CharacterReferenceMarker].
+fn on_exit_character_reference_marker(context: &mut CompileContext) {
context.character_reference_kind = Some(CharacterReferenceKind::Named);
}
-fn on_exit_character_reference_marker_numeric(context: &mut CompileContext, _event: &Event) {
+/// Handle [`Exit`][EventType::Exit]:[`CharacterReferenceMarkerNumeric`][TokenType::CharacterReferenceMarkerNumeric].
+fn on_exit_character_reference_marker_numeric(context: &mut CompileContext) {
context.character_reference_kind = Some(CharacterReferenceKind::Decimal);
}
-fn on_exit_character_reference_marker_hexadecimal(context: &mut CompileContext, _event: &Event) {
+/// Handle [`Exit`][EventType::Exit]:[`CharacterReferenceMarkerHexadecimal`][TokenType::CharacterReferenceMarkerHexadecimal].
+fn on_exit_character_reference_marker_hexadecimal(context: &mut CompileContext) {
context.character_reference_kind = Some(CharacterReferenceKind::Hexadecimal);
}
-fn on_exit_character_reference_value(context: &mut CompileContext, _event: &Event) {
+/// Handle [`Exit`][EventType::Exit]:[`CharacterReferenceValue`][TokenType::CharacterReferenceValue].
+fn on_exit_character_reference_value(context: &mut CompileContext) {
let kind = context
.character_reference_kind
.take()
@@ -830,7 +863,8 @@ fn on_exit_character_reference_value(context: &mut CompileContext, _event: &Even
context.push(context.encode_opt(&value));
}
-fn on_exit_code_flow(context: &mut CompileContext, _event: &Event) {
+/// Handle [`Exit`][EventType::Exit]:{[`CodeFenced`][TokenType::CodeFenced],[`CodeIndented`][TokenType::CodeIndented]}.
+fn on_exit_code_flow(context: &mut CompileContext) {
let seen_data = context
.code_flow_seen_data
.take()
@@ -863,7 +897,8 @@ fn on_exit_code_flow(context: &mut CompileContext, _event: &Event) {
context.slurp_one_line_ending = false;
}
-fn on_exit_code_fenced_fence(context: &mut CompileContext, _event: &Event) {
+/// Handle [`Exit`][EventType::Exit]:[`CodeFencedFence`][TokenType::CodeFencedFence].
+fn on_exit_code_fenced_fence(context: &mut CompileContext) {
let count = if let Some(count) = context.code_fenced_fences_count {
count
} else {
@@ -879,17 +914,22 @@ fn on_exit_code_fenced_fence(context: &mut CompileContext, _event: &Event) {
context.code_fenced_fences_count = Some(count + 1);
}
-fn on_exit_code_fenced_fence_info(context: &mut CompileContext, _event: &Event) {
+/// 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;
}
-fn on_exit_resume(context: &mut CompileContext, _event: &Event) {
+/// Handle [`Exit`][EventType::Exit]:*.
+///
+/// Resumes, and ignores what was resumed.
+fn on_exit_drop(context: &mut CompileContext) {
context.resume();
}
-fn on_exit_code_flow_chunk(context: &mut CompileContext, _event: &Event) {
+/// Handle [`Exit`][EventType::Exit]:[`CodeFlowChunk`][TokenType::CodeFlowChunk].
+fn on_exit_code_flow_chunk(context: &mut CompileContext) {
context.code_flow_seen_data = Some(true);
context.push(context.encode_opt(&serialize(
context.codes,
@@ -898,7 +938,8 @@ fn on_exit_code_flow_chunk(context: &mut CompileContext, _event: &Event) {
)));
}
-fn on_exit_code_text(context: &mut CompileContext, _event: &Event) {
+/// Handle [`Exit`][EventType::Exit]:[`CodeText`][TokenType::CodeText].
+fn on_exit_code_text(context: &mut CompileContext) {
let result = context.resume();
let mut chars = result.chars();
let mut trim = false;
@@ -921,15 +962,18 @@ fn on_exit_code_text(context: &mut CompileContext, _event: &Event) {
context.push("".to_string());
}
-fn on_enter_code_fenced(context: &mut CompileContext, _event: &Event) {
+/// Handle [`Enter`][EventType::Enter]:[`CodeFenced`][TokenType::CodeFenced].
+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.
@@ -602,25 +614,29 @@ fn on_enter_code_fenced(context: &mut CompileContext, _event: &Event) {
context.code_fenced_fences_count = Some(0);
}
-fn on_enter_code_text(context: &mut CompileContext, _event: &Event) {
+/// Handle [`Enter`][EventType::Enter]:[`CodeText`][TokenType::CodeText].
+fn on_enter_code_text(context: &mut CompileContext) {
context.push("
".to_string());
context.buffer();
}
-fn on_enter_html_flow(context: &mut CompileContext, _event: &Event) {
+/// Handle [`Enter`][EventType::Enter]:[`HtmlFlow`][TokenType::HtmlFlow].
+fn on_enter_html_flow(context: &mut CompileContext) {
context.line_ending_if_needed();
if context.allow_dangerous_html {
context.ignore_encode = true;
}
}
-fn on_enter_html_text(context: &mut CompileContext, _event: &Event) {
+/// Handle [`Enter`][EventType::Enter]:[`HtmlText`][TokenType::HtmlText].
+fn on_enter_html_text(context: &mut CompileContext) {
if context.allow_dangerous_html {
context.ignore_encode = true;
}
}
-fn on_enter_image(context: &mut CompileContext, _event: &Event) {
+/// Handle [`Enter`][EventType::Enter]:[`Image`][TokenType::Image].
+fn on_enter_image(context: &mut CompileContext) {
context.media_stack.push(Media {
image: true,
label_id: None,
@@ -632,7 +648,8 @@ fn on_enter_image(context: &mut CompileContext, _event: &Event) {
// tags = undefined // Disallow tags.
}
-fn on_enter_link(context: &mut CompileContext, _event: &Event) {
+/// Handle [`Enter`][EventType::Enter]:[`Link`][TokenType::Link].
+fn on_enter_link(context: &mut CompileContext) {
context.media_stack.push(Media {
image: false,
label_id: None,
@@ -643,30 +660,35 @@ fn on_enter_link(context: &mut CompileContext, _event: &Event) {
});
}
-fn on_enter_resource(context: &mut CompileContext, _event: &Event) {
+/// Handle [`Enter`][EventType::Enter]:[`Resource`][TokenType::Resource].
+fn on_enter_resource(context: &mut CompileContext) {
context.buffer(); // We can have line endings in the resource, ignore them.
let media = context.media_stack.last_mut().unwrap();
media.destination = Some("".to_string());
}
-fn on_enter_destination_string(context: &mut CompileContext, _event: &Event) {
+/// Handle [`Enter`][EventType::Enter]:[`ResourceDestinationString`][TokenType::ResourceDestinationString].
+fn on_enter_resource_destination_string(context: &mut CompileContext) {
context.buffer();
// Ignore encoding the result, as we’ll first percent encode the url and
// encode manually after.
context.ignore_encode = true;
}
-fn on_enter_paragraph(context: &mut CompileContext, _event: &Event) {
+/// Handle [`Enter`][EventType::Enter]:[`Paragraph`][TokenType::Paragraph].
+fn on_enter_paragraph(context: &mut CompileContext) {
context.buf_tail_mut().push("
".to_string());
}
-fn on_exit_code_text_line_ending(context: &mut CompileContext, _event: &Event) {
+/// Handle [`Exit`][EventType::Exit]:[`CodeTextLineEnding`][TokenType::CodeTextLineEnding].
+fn on_exit_code_text_line_ending(context: &mut CompileContext) {
context.push(" ".to_string());
}
-fn on_exit_break(context: &mut CompileContext, _event: &Event) {
+/// Handle [`Exit`][EventType::Exit]:{[`HardBreakEscape`][TokenType::HardBreakEscape],[`HardBreakTrailing`][TokenType::HardBreakTrailing]}.
+fn on_exit_break(context: &mut CompileContext) {
context.push("
".to_string());
}
-fn on_exit_heading_atx(context: &mut CompileContext, _event: &Event) {
+/// Handle [`Exit`][EventType::Exit]:[`HeadingAtx`][TokenType::HeadingAtx].
+fn on_exit_heading_atx(context: &mut CompileContext) {
let rank = context
.atx_opening_sequence_size
.take()
@@ -938,7 +982,8 @@ fn on_exit_heading_atx(context: &mut CompileContext, _event: &Event) {
context.push(format!("", rank));
}
-fn on_exit_heading_atx_sequence(context: &mut CompileContext, _event: &Event) {
+/// Handle [`Exit`][EventType::Exit]:[`HeadingAtxSequence`][TokenType::HeadingAtxSequence].
+fn on_exit_heading_atx_sequence(context: &mut CompileContext) {
// First fence we see.
if context.atx_opening_sequence_size.is_none() {
let rank = serialize(
@@ -952,18 +997,21 @@ fn on_exit_heading_atx_sequence(context: &mut CompileContext, _event: &Event) {
}
}
-fn on_exit_heading_atx_text(context: &mut CompileContext, _event: &Event) {
+/// Handle [`Exit`][EventType::Exit]:[`HeadingAtxText`][TokenType::HeadingAtxText].
+fn on_exit_heading_atx_text(context: &mut CompileContext) {
let value = context.resume();
context.push(value);
}
-fn on_exit_heading_setext_text(context: &mut CompileContext, _event: &Event) {
+/// Handle [`Exit`][EventType::Exit]:[`HeadingSetextText`][TokenType::HeadingSetextText].
+fn on_exit_heading_setext_text(context: &mut CompileContext) {
let buf = context.resume();
context.heading_setext_buffer = Some(buf);
context.slurp_one_line_ending = true;
}
-fn on_exit_heading_setext_underline(context: &mut CompileContext, _event: &Event) {
+/// Handle [`Exit`][EventType::Exit]:[`HeadingSetextUnderline`][TokenType::HeadingSetextUnderline].
+fn on_exit_heading_setext_underline(context: &mut CompileContext) {
let text = context
.heading_setext_buffer
.take()
@@ -977,11 +1025,13 @@ fn on_exit_heading_setext_underline(context: &mut CompileContext, _event: &Event
context.push(format!("