code housekeeping
This commit is contained in:
parent
e1b6578b2a
commit
d3c3ff8e4e
10 changed files with 108 additions and 100 deletions
|
|
@ -5,9 +5,6 @@ use std::fmt::Write;
|
|||
use std::ops::Range;
|
||||
|
||||
use codespan_reporting::diagnostic::Diagnostic;
|
||||
use codespan_reporting::diagnostic::Label;
|
||||
use codespan_reporting::diagnostic::LabelStyle;
|
||||
use codespan_reporting::diagnostic::Severity;
|
||||
use jotdown::Alignment;
|
||||
use jotdown::Container;
|
||||
use jotdown::Event;
|
||||
|
|
@ -103,7 +100,7 @@ impl<'a> Writer<'a> {
|
|||
fn render_event(
|
||||
&mut self,
|
||||
e: &Event<'a>,
|
||||
range: Range<usize>,
|
||||
#[expect(unused)] range: Range<usize>,
|
||||
out: &mut String,
|
||||
) -> std::fmt::Result {
|
||||
if matches!(&e, Event::Start(Container::LinkDefinition { .. }, ..)) {
|
||||
|
|
@ -302,13 +299,13 @@ impl<'a> Writer<'a> {
|
|||
class.parts().for_each(|part| write_attr(part, out));
|
||||
}
|
||||
// div class goes after classes from attrs
|
||||
if let Container::Div { class } = c {
|
||||
if !class.is_empty() {
|
||||
if first_written {
|
||||
out.push(' ');
|
||||
}
|
||||
out.push_str(class);
|
||||
if let Container::Div { class } = c
|
||||
&& !class.is_empty()
|
||||
{
|
||||
if first_written {
|
||||
out.push(' ');
|
||||
}
|
||||
out.push_str(class);
|
||||
}
|
||||
out.push('"');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use std::ops::Range;
|
||||
|
||||
use super::compiled::{CompiledSyntax, CompiledTokenTypes, TokenId, TOKEN_ID_DEFAULT};
|
||||
use super::compiled::{CompiledSyntax, CompiledTokenTypes, TOKEN_ID_DEFAULT, TokenId};
|
||||
|
||||
pub struct Token {
|
||||
pub id: TokenId,
|
||||
|
|
@ -71,10 +71,10 @@ impl CompiledSyntax {
|
|||
}
|
||||
|
||||
for token in &mut tokens {
|
||||
if let Some(keyword) = self.keywords.get(&text[token.range.clone()]) {
|
||||
if keyword.only_replaces.is_none() || Some(token.id) == keyword.only_replaces {
|
||||
token.id = keyword.into;
|
||||
}
|
||||
if let Some(keyword) = self.keywords.get(&text[token.range.clone()])
|
||||
&& (keyword.only_replaces.is_none() || Some(token.id) == keyword.only_replaces)
|
||||
{
|
||||
token.id = keyword.into;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -87,11 +87,11 @@ fn push_token(tokens: &mut Vec<Token>, id: TokenId, range: Range<usize>) {
|
|||
return;
|
||||
}
|
||||
|
||||
if let Some(previous_token) = tokens.last_mut() {
|
||||
if previous_token.id == id {
|
||||
previous_token.range.end = range.end;
|
||||
return;
|
||||
}
|
||||
if let Some(previous_token) = tokens.last_mut()
|
||||
&& previous_token.id == id
|
||||
{
|
||||
previous_token.range.end = range.end;
|
||||
return;
|
||||
}
|
||||
tokens.push(Token { id, range });
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue