feat: update Event::Text
This commit is contained in:
parent
e82adf92b7
commit
0d8ef46a38
4 changed files with 5 additions and 5 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -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/>",
|
||||
|
|
|
|||
|
|
@ -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!();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue