diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-11-19 23:12:23 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-11-19 23:12:23 +0100 |
| commit | 565b1977aef9db70aef29a1eb8747f42a7fe4a15 (patch) | |
| tree | 512587ff875c072fbcd498ff3b3f7c8d618980b4 /src/syntax | |
| parent | 1937d746abf19a5c1142db546912dbed0e6711fb (diff) | |
Rename `RawKind` to `RawFields`
Diffstat (limited to 'src/syntax')
| -rw-r--r-- | src/syntax/ast.rs | 8 | ||||
| -rw-r--r-- | src/syntax/highlight.rs | 2 | ||||
| -rw-r--r-- | src/syntax/kind.rs | 8 | ||||
| -rw-r--r-- | src/syntax/resolve.rs | 8 | ||||
| -rw-r--r-- | src/syntax/tokens.rs | 6 |
5 files changed, 16 insertions, 16 deletions
diff --git a/src/syntax/ast.rs b/src/syntax/ast.rs index 547545c7..381ba712 100644 --- a/src/syntax/ast.rs +++ b/src/syntax/ast.rs @@ -5,7 +5,7 @@ use std::num::NonZeroUsize; use std::ops::Deref; -use super::{NodeData, NodeKind, RawKind, Span, SyntaxNode, Unit}; +use super::{NodeData, NodeKind, RawFields, Span, SyntaxNode, Unit}; use crate::util::EcoString; /// A typed AST node. @@ -80,7 +80,7 @@ pub enum MarkupNode { Strong(Strong), /// Emphasized content: `_Emphasized_`. Emph(Emph), - /// A raw block with optional syntax highlighting: `` `...` ``. + /// Raw text with optional syntax highlighting: `` `...` ``. Raw(Raw), /// A hyperlink: `https://typst.org`. Link(Link), @@ -258,7 +258,7 @@ impl Emph { } node! { - /// A raw block with optional syntax highlighting: `` `...` ``. + /// Raw text with optional syntax highlighting: `` `...` ``. Raw } @@ -279,7 +279,7 @@ impl Raw { } /// The raw fields. - fn get(&self) -> &RawKind { + fn get(&self) -> &RawFields { match self.0.kind() { NodeKind::Raw(v) => v.as_ref(), _ => panic!("raw is of wrong kind"), diff --git a/src/syntax/highlight.rs b/src/syntax/highlight.rs index 34cce4c0..7c0b4ac1 100644 --- a/src/syntax/highlight.rs +++ b/src/syntax/highlight.rs @@ -147,7 +147,7 @@ pub enum Category { Emph, /// A hyperlink. Link, - /// Raw text or code. + /// Raw text. Raw, /// A label. Label, diff --git a/src/syntax/kind.rs b/src/syntax/kind.rs index 1282b592..b3948c66 100644 --- a/src/syntax/kind.rs +++ b/src/syntax/kind.rs @@ -150,8 +150,8 @@ pub enum NodeKind { Strong, /// Emphasized content: `_Emphasized_`. Emph, - /// A raw block with optional syntax highlighting: `` `...` ``. - Raw(Arc<RawKind>), + /// Raw text with optional syntax highlighting: `` `...` ``. + Raw(Arc<RawFields>), /// A hyperlink: `https://typst.org`. Link(EcoString), /// A label: `<label>`. @@ -254,9 +254,9 @@ pub enum NodeKind { Error(ErrorPos, EcoString), } -/// Fields of the node kind `Raw`. +/// Fields of a [`Raw`](NodeKind::Raw) node. #[derive(Debug, Clone, PartialEq, Hash)] -pub struct RawKind { +pub struct RawFields { /// An optional identifier specifying the language to syntax-highlight in. pub lang: Option<EcoString>, /// The raw text, determined as the raw string between the backticks trimmed diff --git a/src/syntax/resolve.rs b/src/syntax/resolve.rs index bbed3c5c..3ba9a252 100644 --- a/src/syntax/resolve.rs +++ b/src/syntax/resolve.rs @@ -1,6 +1,6 @@ use unscanny::Scanner; -use super::{is_ident, is_newline, RawKind}; +use super::{is_ident, is_newline, RawFields}; use crate::util::EcoString; /// Resolve all escape sequences in a string. @@ -44,17 +44,17 @@ pub fn resolve_hex(sequence: &str) -> Option<char> { } /// Resolve the language tag and trim the raw text. -pub fn resolve_raw(column: usize, backticks: usize, text: &str) -> RawKind { +pub fn resolve_raw(column: usize, backticks: usize, text: &str) -> RawFields { if backticks > 1 { let (tag, inner) = split_at_lang_tag(text); let (text, block) = trim_and_split_raw(column, inner); - RawKind { + RawFields { lang: is_ident(tag).then(|| tag.into()), text: text.into(), block, } } else { - RawKind { + RawFields { lang: None, text: split_lines(text).join("\n").into(), block: false, diff --git a/src/syntax/tokens.rs b/src/syntax/tokens.rs index b27832c5..be8ceee5 100644 --- a/src/syntax/tokens.rs +++ b/src/syntax/tokens.rs @@ -4,7 +4,7 @@ use unicode_xid::UnicodeXID; use unscanny::Scanner; use super::resolve::{resolve_hex, resolve_raw, resolve_string}; -use super::{ErrorPos, NodeKind, RawKind, Unit}; +use super::{ErrorPos, NodeKind, RawFields, Unit}; use crate::geom::{AbsUnit, AngleUnit}; use crate::util::{format_eco, EcoString}; @@ -351,7 +351,7 @@ impl<'s> Tokens<'s> { // Special case for empty inline block. if backticks == 2 { - return NodeKind::Raw(Arc::new(RawKind { + return NodeKind::Raw(Arc::new(RawFields { text: EcoString::new(), lang: None, block: false, @@ -724,7 +724,7 @@ mod tests { } fn Raw(text: &str, lang: Option<&str>, block: bool) -> NodeKind { - NodeKind::Raw(Arc::new(RawKind { + NodeKind::Raw(Arc::new(RawFields { text: text.into(), lang: lang.map(Into::into), block, |
