summaryrefslogtreecommitdiff
path: root/src/diagnostics/html_tag.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/diagnostics/html_tag.rs')
-rw-r--r--src/diagnostics/html_tag.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/diagnostics/html_tag.rs b/src/diagnostics/html_tag.rs
new file mode 100644
index 0000000..8cf7eb0
--- /dev/null
+++ b/src/diagnostics/html_tag.rs
@@ -0,0 +1,34 @@
+use miette::Diagnostic;
+use thiserror::Error;
+
+use crate::{
+ diagnostics::AstDiagnostic,
+ tokenize::{Span, TokenType},
+};
+
+#[derive(Error, Debug, Diagnostic)]
+#[error("html tags is not allowed in kuht")]
+#[diagnostic(code(HtmlTag), severity(Error))]
+pub struct HtmlTag {
+ #[label(primary, "invalid html tag")]
+ tag: Span,
+}
+
+impl AstDiagnostic for HtmlTag {
+ fn handle_element(element: &crate::parse::Element<'_>) -> Option<Self> {
+ let TokenType::Tag {
+ lowercase_tag_name, ..
+ } = element.start_tag.ty
+ else {
+ return None;
+ };
+
+ if lowercase_tag_name != "html" {
+ return None;
+ }
+
+ Some(Self {
+ tag: element.start_tag.span,
+ })
+ }
+}