feat: update Event::Text

This commit is contained in:
PoiScript 2024-04-01 11:42:53 +08:00
parent e82adf92b7
commit 0d8ef46a38
No known key found for this signature in database
GPG key ID: 22C2B1249D99985E
4 changed files with 5 additions and 5 deletions

View file

@ -73,7 +73,7 @@ pub fn filter_token(
/// A simple wrapper of `Option<SyntaxToken>`
///
/// It acts like a `token.text()` when inner is `Some(token)`, and an empty string when `None`.
#[derive(Default, Eq)]
#[derive(Default, Eq, Clone)]
pub struct Token(pub(crate) Option<SyntaxToken>);
impl Token {

View file

@ -1,4 +1,4 @@
use crate::{ast::*, SyntaxToken};
use crate::ast::*;
#[non_exhaustive]
#[derive(Clone, PartialEq, Eq, Debug)]
@ -54,7 +54,7 @@ pub enum Event {
Enter(Container),
Leave(Container),
Text(SyntaxToken),
Text(Token),
Macros(Macros),
Cookie(Cookie),
InlineCall(InlineCall),

View file

@ -274,7 +274,7 @@ impl Traverser for HtmlExport {
Event::Leave(Container::Link(_)) => self.output += "</a>",
Event::Text(text) => {
let _ = write!(&mut self.output, "{}", HtmlEscape(text.text()));
let _ = write!(&mut self.output, "{}", HtmlEscape(text));
}
Event::LineBreak(_) => self.output += "<br/>",

View file

@ -216,7 +216,7 @@ pub trait Traverser {
}
SyntaxElement::Token(token) => {
if token.kind() == TEXT {
self.event(Event::Text(token), ctx);
self.event(Event::Text(Token(Some(token))), ctx);
take_control!();
}
}