mirror of
https://github.com/swc-project/swc.git
synced 2024-08-17 04:10:37 +03:00
feat(html): Initialize (#4240)
This commit is contained in:
parent
b973d35282
commit
3e7872c8de
4
.gitattributes
vendored
4
.gitattributes
vendored
@ -15,9 +15,11 @@
|
||||
**/tests/**/*.ts linguist-detectable=false
|
||||
**/tests/**/*.tsx linguist-detectable=false
|
||||
**/tests/**/*.css linguist-detectable=false
|
||||
**/tests/**/*.html linguist-detectable=false
|
||||
**/benches/**/*.js linguist-detectable=false
|
||||
**/benches/**/*.jsx linguist-detectable=false
|
||||
**/benches/**/*.mjs linguist-detectable=false
|
||||
**/benches/**/*.ts linguist-detectable=false
|
||||
**/benches/**/*.tsx linguist-detectable=false
|
||||
**/benches/**/*.css linguist-detectable=false
|
||||
**/benches/**/*.css linguist-detectable=false
|
||||
**/benches/**/*.html linguist-detectable=false
|
16
.github/workflows/cargo.yml
vendored
16
.github/workflows/cargo.yml
vendored
@ -256,6 +256,22 @@ jobs:
|
||||
os: ubuntu-latest
|
||||
- crate: swc_graph_analyzer
|
||||
os: ubuntu-latest
|
||||
- crate: swc_html
|
||||
os: ubuntu-latest
|
||||
- crate: swc_html_ast
|
||||
os: ubuntu-latest
|
||||
- crate: swc_html_codegen
|
||||
os: ubuntu-latest
|
||||
- crate: swc_html_codegen
|
||||
os: windows-latest
|
||||
- crate: swc_html_codegen_macros
|
||||
os: ubuntu-latest
|
||||
- crate: swc_html_parser
|
||||
os: ubuntu-latest
|
||||
- crate: swc_html_parser
|
||||
os: windows-latest
|
||||
- crate: swc_html_visit
|
||||
os: ubuntu-latest
|
||||
- crate: swc_macros_common
|
||||
os: ubuntu-latest
|
||||
- crate: swc_node_base
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -27,6 +27,7 @@ node_modules/
|
||||
|
||||
# Flamegraph
|
||||
*.html
|
||||
!crates/swc_html*/**/*.html
|
||||
*.svg
|
||||
package-lock.json
|
||||
*.data
|
||||
|
72
Cargo.lock
generated
72
Cargo.lock
generated
@ -3710,6 +3710,78 @@ dependencies = [
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "swc_html"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"swc_html_ast",
|
||||
"swc_html_codegen",
|
||||
"swc_html_parser",
|
||||
"swc_html_visit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "swc_html_ast"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"is-macro",
|
||||
"serde",
|
||||
"string_enum",
|
||||
"swc_atoms",
|
||||
"swc_common",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "swc_html_codegen"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"auto_impl",
|
||||
"bitflags",
|
||||
"swc_atoms",
|
||||
"swc_common",
|
||||
"swc_html_ast",
|
||||
"swc_html_codegen_macros",
|
||||
"swc_html_parser",
|
||||
"swc_html_visit",
|
||||
"testing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "swc_html_codegen_macros"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"pmutil",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"swc_macros_common",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "swc_html_parser"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"lexical",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"swc_atoms",
|
||||
"swc_common",
|
||||
"swc_html_ast",
|
||||
"swc_html_visit",
|
||||
"testing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "swc_html_visit"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"swc_atoms",
|
||||
"swc_common",
|
||||
"swc_html_ast",
|
||||
"swc_visit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "swc_macros_common"
|
||||
version = "0.3.3"
|
||||
|
@ -10,6 +10,7 @@ members = [
|
||||
"crates/swc_ecma_lints",
|
||||
"crates/swc_ecma_quote",
|
||||
"crates/swc_estree_compat",
|
||||
"crates/swc_html",
|
||||
"crates/swc_plugin",
|
||||
"crates/swc_plugin_macro",
|
||||
"crates/swc_plugin_runner",
|
||||
|
19
crates/swc_html/Cargo.toml
Normal file
19
crates/swc_html/Cargo.toml
Normal file
@ -0,0 +1,19 @@
|
||||
[package]
|
||||
authors = ["강동윤 <kdy1997.dev@gmail.com>", "Alexander Akait <sheo13666q@gmail.com>"]
|
||||
description = "HTML apis for rust"
|
||||
documentation = "https://rustdoc.swc.rs/swc_html/"
|
||||
edition = "2021"
|
||||
license = "Apache-2.0"
|
||||
name = "swc_html"
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "0.1.0"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
||||
|
||||
[dependencies]
|
||||
swc_html_ast = { version = "0.1.0", path = "../swc_html_ast" }
|
||||
swc_html_codegen = { version = "0.1.0", path = "../swc_html_codegen" }
|
||||
swc_html_parser = { version = "0.1.0", path = "../swc_html_parser" }
|
||||
swc_html_visit = { version = "0.1.0", path = "../swc_html_visit" }
|
4
crates/swc_html/src/lib.rs
Normal file
4
crates/swc_html/src/lib.rs
Normal file
@ -0,0 +1,4 @@
|
||||
pub extern crate swc_html_ast as ast;
|
||||
pub extern crate swc_html_codegen as codegen;
|
||||
pub extern crate swc_html_parser as parser;
|
||||
pub extern crate swc_html_visit as visit;
|
18
crates/swc_html_ast/Cargo.toml
Normal file
18
crates/swc_html_ast/Cargo.toml
Normal file
@ -0,0 +1,18 @@
|
||||
[package]
|
||||
authors = ["강동윤 <kdy1997.dev@gmail.com>", "Alexander Akait <sheo13666q@gmail.com>"]
|
||||
description = "AST definitions of html"
|
||||
documentation = "https://rustdoc.swc.rs/swc_html_ast/"
|
||||
edition = "2021"
|
||||
license = "Apache-2.0"
|
||||
name = "swc_html_ast"
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "0.1.0"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
is-macro = "0.2.0"
|
||||
serde = { version = "1.0.127", features = ["derive"] }
|
||||
string_enum = { version = "0.3.1", path = "../string_enum/" }
|
||||
swc_atoms = { version = "0.2.7", path = "../swc_atoms" }
|
||||
swc_common = { version = "0.17.0", path = "../swc_common" }
|
9
crates/swc_html_ast/src/base.rs
Normal file
9
crates/swc_html_ast/src/base.rs
Normal file
@ -0,0 +1,9 @@
|
||||
use swc_common::{ast_node, Span};
|
||||
|
||||
use crate::TokenAndSpan;
|
||||
|
||||
#[ast_node("Document")]
|
||||
pub struct Document {
|
||||
pub span: Span,
|
||||
pub children: Vec<TokenAndSpan>,
|
||||
}
|
8
crates/swc_html_ast/src/lib.rs
Normal file
8
crates/swc_html_ast/src/lib.rs
Normal file
@ -0,0 +1,8 @@
|
||||
#![deny(clippy::all)]
|
||||
#![allow(clippy::large_enum_variant)]
|
||||
|
||||
//! AST definitions for HTML.
|
||||
pub use self::{base::*, token::*};
|
||||
|
||||
mod base;
|
||||
mod token;
|
42
crates/swc_html_ast/src/token.rs
Normal file
42
crates/swc_html_ast/src/token.rs
Normal file
@ -0,0 +1,42 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use swc_atoms::JsWord;
|
||||
use swc_common::{ast_node, Span};
|
||||
|
||||
#[ast_node("TokenAndSpan")]
|
||||
pub struct TokenAndSpan {
|
||||
pub span: Span,
|
||||
pub token: Token,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Attribute {
|
||||
pub name: JsWord,
|
||||
pub value: JsWord,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub enum Token {
|
||||
Doctype {
|
||||
name: Option<JsWord>,
|
||||
force_quirks: bool,
|
||||
public_id: Option<JsWord>,
|
||||
system_id: Option<JsWord>,
|
||||
},
|
||||
StartTag {
|
||||
tag_name: JsWord,
|
||||
self_closing: bool,
|
||||
attributes: Vec<Attribute>,
|
||||
},
|
||||
EndTag {
|
||||
tag_name: JsWord,
|
||||
self_closing: bool,
|
||||
attributes: Vec<Attribute>,
|
||||
},
|
||||
Comment {
|
||||
data: JsWord,
|
||||
},
|
||||
Character {
|
||||
value: char,
|
||||
},
|
||||
Eof,
|
||||
}
|
26
crates/swc_html_codegen/Cargo.toml
Normal file
26
crates/swc_html_codegen/Cargo.toml
Normal file
@ -0,0 +1,26 @@
|
||||
[package]
|
||||
authors = ["강동윤 <kdy1997.dev@gmail.com>", "Alexander Akait <sheo13666q@gmail.com>"]
|
||||
description = "HTML code generator for the swc project"
|
||||
documentation = "https://rustdoc.swc.rs/swc_html_codegen/"
|
||||
edition = "2021"
|
||||
include = ["Cargo.toml", "src/**/*.rs"]
|
||||
license = "Apache-2.0"
|
||||
name = "swc_html_codegen"
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "0.1.0"
|
||||
|
||||
[dependencies]
|
||||
auto_impl = "0.5.0"
|
||||
bitflags = "1.3.2"
|
||||
swc_atoms = { version = "0.2.7", path = "../swc_atoms" }
|
||||
swc_common = { version = "0.17.0", path = "../swc_common" }
|
||||
swc_html_ast = { version = "0.1.0", path = "../swc_html_ast" }
|
||||
swc_html_codegen_macros = { version = "0.1.0", path = "../swc_html_codegen_macros" }
|
||||
|
||||
[dev-dependencies]
|
||||
swc_common = { version = "0.17.3", path = "../swc_common", features = [
|
||||
"sourcemap",
|
||||
] }
|
||||
swc_html_parser = { version = "0.1.0", path = "../swc_html_parser" }
|
||||
swc_html_visit = { version = "0.1.0", path = "../swc_html_visit" }
|
||||
testing = { version = "0.19.0", path = "../testing" }
|
52
crates/swc_html_codegen/src/emit.rs
Normal file
52
crates/swc_html_codegen/src/emit.rs
Normal file
@ -0,0 +1,52 @@
|
||||
use std::fmt::Result;
|
||||
|
||||
use swc_common::Spanned;
|
||||
|
||||
///
|
||||
/// # Type parameters
|
||||
///
|
||||
/// ## `T`
|
||||
///
|
||||
/// The type of the ast node.
|
||||
pub trait Emit<T>
|
||||
where
|
||||
T: Spanned,
|
||||
{
|
||||
fn emit(&mut self, node: &T) -> Result;
|
||||
}
|
||||
|
||||
impl<T, E> Emit<&'_ T> for E
|
||||
where
|
||||
E: Emit<T>,
|
||||
T: Spanned,
|
||||
{
|
||||
#[inline]
|
||||
fn emit(&mut self, node: &&'_ T) -> Result {
|
||||
self.emit(&**node)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, E> Emit<Box<T>> for E
|
||||
where
|
||||
E: Emit<T>,
|
||||
T: Spanned,
|
||||
{
|
||||
#[inline]
|
||||
fn emit(&mut self, node: &Box<T>) -> Result {
|
||||
self.emit(&**node)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, E> Emit<Option<T>> for E
|
||||
where
|
||||
E: Emit<T>,
|
||||
T: Spanned,
|
||||
{
|
||||
#[inline]
|
||||
fn emit(&mut self, node: &Option<T>) -> Result {
|
||||
match node {
|
||||
Some(node) => self.emit(&*node),
|
||||
None => Ok(()),
|
||||
}
|
||||
}
|
||||
}
|
200
crates/swc_html_codegen/src/lib.rs
Normal file
200
crates/swc_html_codegen/src/lib.rs
Normal file
@ -0,0 +1,200 @@
|
||||
#![deny(clippy::all)]
|
||||
#![allow(clippy::needless_update)]
|
||||
|
||||
pub use std::fmt::Result;
|
||||
|
||||
use swc_common::Spanned;
|
||||
use swc_html_ast::*;
|
||||
use swc_html_codegen_macros::emitter;
|
||||
use writer::HtmlWriter;
|
||||
|
||||
pub use self::emit::*;
|
||||
use self::list::ListFormat;
|
||||
|
||||
#[macro_use]
|
||||
mod macros;
|
||||
mod emit;
|
||||
mod list;
|
||||
pub mod writer;
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct CodegenConfig {
|
||||
pub minify: bool,
|
||||
}
|
||||
#[derive(Debug)]
|
||||
pub struct CodeGenerator<W>
|
||||
where
|
||||
W: HtmlWriter,
|
||||
{
|
||||
wr: W,
|
||||
config: CodegenConfig,
|
||||
}
|
||||
|
||||
impl<W> CodeGenerator<W>
|
||||
where
|
||||
W: HtmlWriter,
|
||||
{
|
||||
pub fn new(wr: W, config: CodegenConfig) -> Self {
|
||||
CodeGenerator { wr, config }
|
||||
}
|
||||
|
||||
#[emitter]
|
||||
fn emit_document(&mut self, n: &Document) -> Result {
|
||||
self.emit_list(&n.children, ListFormat::NotDelimited)?;
|
||||
}
|
||||
|
||||
#[emitter]
|
||||
fn emit_token_and_span(&mut self, n: &TokenAndSpan) -> Result {
|
||||
let span = n.span;
|
||||
|
||||
match &n.token {
|
||||
Token::Doctype {
|
||||
name,
|
||||
public_id,
|
||||
system_id,
|
||||
..
|
||||
} => {
|
||||
let mut doctype = String::new();
|
||||
|
||||
doctype.push('<');
|
||||
doctype.push('!');
|
||||
doctype.push_str("DOCTYPE");
|
||||
|
||||
if let Some(name) = &name {
|
||||
doctype.push(' ');
|
||||
doctype.push_str(name);
|
||||
}
|
||||
|
||||
if let Some(public_id) = &public_id {
|
||||
doctype.push(' ');
|
||||
doctype.push_str("PUBLIC");
|
||||
doctype.push(' ');
|
||||
doctype.push('"');
|
||||
doctype.push_str(public_id);
|
||||
doctype.push('"');
|
||||
}
|
||||
|
||||
if let Some(system_id) = &system_id {
|
||||
doctype.push(' ');
|
||||
doctype.push('"');
|
||||
doctype.push_str(system_id);
|
||||
doctype.push('"');
|
||||
}
|
||||
|
||||
doctype.push('>');
|
||||
|
||||
write_raw!(self, span, &doctype);
|
||||
}
|
||||
Token::StartTag {
|
||||
tag_name,
|
||||
attributes,
|
||||
self_closing,
|
||||
} => {
|
||||
let mut start_tag = String::new();
|
||||
|
||||
start_tag.push('<');
|
||||
start_tag.push_str(tag_name);
|
||||
|
||||
for attribute in attributes {
|
||||
start_tag.push(' ');
|
||||
start_tag.push_str(&attribute.name);
|
||||
start_tag.push('=');
|
||||
|
||||
let quote = if attribute.value.contains('"') {
|
||||
'\''
|
||||
} else {
|
||||
'"'
|
||||
};
|
||||
|
||||
start_tag.push(quote);
|
||||
start_tag.push_str(&attribute.value);
|
||||
start_tag.push(quote);
|
||||
}
|
||||
|
||||
if *self_closing {
|
||||
start_tag.push('/');
|
||||
}
|
||||
|
||||
start_tag.push('>');
|
||||
|
||||
write_raw!(self, span, &start_tag);
|
||||
}
|
||||
Token::EndTag {
|
||||
tag_name,
|
||||
attributes,
|
||||
..
|
||||
} => {
|
||||
let mut start_tag = String::new();
|
||||
|
||||
start_tag.push_str("</");
|
||||
start_tag.push_str(tag_name);
|
||||
|
||||
for attribute in attributes {
|
||||
start_tag.push(' ');
|
||||
start_tag.push_str(&attribute.name);
|
||||
start_tag.push('=');
|
||||
start_tag.push_str(&attribute.value);
|
||||
}
|
||||
|
||||
start_tag.push('>');
|
||||
|
||||
write_raw!(self, span, &start_tag);
|
||||
}
|
||||
Token::Comment { data } => {
|
||||
let mut comment = String::new();
|
||||
|
||||
comment.push_str("<!--");
|
||||
comment.push_str(data);
|
||||
comment.push_str("-->");
|
||||
|
||||
write_str!(self, span, &comment);
|
||||
}
|
||||
Token::Character { value } => {
|
||||
write_str!(self, span, &value.to_string());
|
||||
}
|
||||
Token::Eof => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn emit_list<N>(&mut self, nodes: &[N], format: ListFormat) -> Result
|
||||
where
|
||||
Self: Emit<N>,
|
||||
N: Spanned,
|
||||
{
|
||||
for (idx, node) in nodes.iter().enumerate() {
|
||||
if idx != 0 {
|
||||
self.write_delim(format)?;
|
||||
|
||||
if format & ListFormat::LinesMask == ListFormat::MultiLine {
|
||||
formatting_newline!(self);
|
||||
}
|
||||
}
|
||||
|
||||
emit!(self, node)
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn write_delim(&mut self, f: ListFormat) -> Result {
|
||||
match f & ListFormat::DelimitersMask {
|
||||
ListFormat::None => {}
|
||||
ListFormat::CommaDelimited => {
|
||||
write_raw!(self, ",");
|
||||
formatting_space!(self);
|
||||
}
|
||||
ListFormat::SpaceDelimited => {
|
||||
space!(self)
|
||||
}
|
||||
ListFormat::SemiDelimited => {
|
||||
write_raw!(self, ";")
|
||||
}
|
||||
ListFormat::DotDelimited => {
|
||||
write_raw!(self, ".");
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
39
crates/swc_html_codegen/src/list.rs
Normal file
39
crates/swc_html_codegen/src/list.rs
Normal file
@ -0,0 +1,39 @@
|
||||
#![allow(non_upper_case_globals)]
|
||||
use bitflags::bitflags;
|
||||
use swc_common::add_bitflags;
|
||||
|
||||
bitflags! {
|
||||
pub struct ListFormat: u16 {
|
||||
const None = 0;
|
||||
}
|
||||
}
|
||||
|
||||
add_bitflags!(
|
||||
ListFormat,
|
||||
// Handled by bitflags! macro.
|
||||
// Values { None: 0 },
|
||||
/// Line separators
|
||||
Values {
|
||||
/// Prints the list on a single line (default).
|
||||
SingleLine: 0,
|
||||
/// Prints the list on multiple lines.
|
||||
MultiLine: 1 << 0,
|
||||
/// Prints the list using line preservation if possible.
|
||||
PreserveLines: 1 << 1,
|
||||
LinesMask: SingleLine | MultiLine | PreserveLines,
|
||||
},
|
||||
/// Delimiters
|
||||
Values {
|
||||
NotDelimited: 0,
|
||||
SpaceDelimited: 1 << 2,
|
||||
/// There is no delimiter between list items (default).
|
||||
SemiDelimited: 1 << 3,
|
||||
CommaDelimited: 1 << 4,
|
||||
DotDelimited: 1 << 5,
|
||||
DelimitersMask: SpaceDelimited | SemiDelimited | CommaDelimited | DotDelimited,
|
||||
},
|
||||
Values {
|
||||
/// Write a trailing comma (",") if present.
|
||||
AllowTrailingComma: 1 << 6,
|
||||
},
|
||||
);
|
61
crates/swc_html_codegen/src/macros.rs
Normal file
61
crates/swc_html_codegen/src/macros.rs
Normal file
@ -0,0 +1,61 @@
|
||||
macro_rules! emit {
|
||||
($g:expr,$n:expr) => {{
|
||||
use crate::Emit;
|
||||
|
||||
$g.emit(&$n)?;
|
||||
}};
|
||||
}
|
||||
|
||||
macro_rules! write_raw {
|
||||
($g:expr,$span:expr,$n:expr) => {{
|
||||
$g.wr.write_raw(Some($span), $n)?;
|
||||
}};
|
||||
|
||||
($g:expr,$n:expr) => {{
|
||||
$g.wr.write_raw(None, $n)?;
|
||||
}};
|
||||
}
|
||||
|
||||
macro_rules! write_str {
|
||||
($g:expr,$span:expr,$n:expr) => {{
|
||||
$g.wr.write_str($span, $n)?;
|
||||
}};
|
||||
}
|
||||
|
||||
macro_rules! formatting_newline {
|
||||
($g:expr) => {{
|
||||
if !$g.config.minify {
|
||||
$g.wr.write_newline()?;
|
||||
}
|
||||
}};
|
||||
}
|
||||
|
||||
macro_rules! space {
|
||||
($g:expr) => {{
|
||||
$g.wr.write_space()?;
|
||||
}};
|
||||
}
|
||||
|
||||
macro_rules! formatting_space {
|
||||
($g:expr) => {{
|
||||
if !$g.config.minify {
|
||||
$g.wr.write_space()?;
|
||||
}
|
||||
}};
|
||||
}
|
||||
|
||||
// macro_rules! increase_indent {
|
||||
// ($g:expr) => {{
|
||||
// if !$g.config.minify {
|
||||
// $g.wr.increase_indent();
|
||||
// }
|
||||
// }};
|
||||
// }
|
||||
//
|
||||
// macro_rules! decrease_indent {
|
||||
// ($g:expr) => {{
|
||||
// if !$g.config.minify {
|
||||
// $g.wr.decrease_indent();
|
||||
// }
|
||||
// }};
|
||||
// }
|
223
crates/swc_html_codegen/src/writer/basic.rs
Normal file
223
crates/swc_html_codegen/src/writer/basic.rs
Normal file
@ -0,0 +1,223 @@
|
||||
use std::fmt::{Result, Write};
|
||||
|
||||
use swc_common::{BytePos, LineCol, Span};
|
||||
|
||||
use super::HtmlWriter;
|
||||
|
||||
pub enum IndentType {
|
||||
Tab,
|
||||
Space,
|
||||
}
|
||||
|
||||
impl Default for IndentType {
|
||||
fn default() -> Self {
|
||||
IndentType::Space
|
||||
}
|
||||
}
|
||||
|
||||
pub enum LineFeed {
|
||||
LF,
|
||||
CRLF,
|
||||
}
|
||||
|
||||
impl Default for LineFeed {
|
||||
fn default() -> Self {
|
||||
LineFeed::LF
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BasicHtmlWriterConfig {
|
||||
pub indent_type: IndentType,
|
||||
pub indent_width: i32,
|
||||
pub linefeed: LineFeed,
|
||||
}
|
||||
|
||||
impl Default for BasicHtmlWriterConfig {
|
||||
fn default() -> Self {
|
||||
BasicHtmlWriterConfig {
|
||||
indent_type: IndentType::default(),
|
||||
indent_width: 2,
|
||||
linefeed: LineFeed::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BasicHtmlWriter<'a, W>
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
line_start: bool,
|
||||
line: usize,
|
||||
col: usize,
|
||||
|
||||
indent_type: &'a str,
|
||||
indent_level: usize,
|
||||
linefeed: &'a str,
|
||||
|
||||
srcmap: Option<&'a mut Vec<(BytePos, LineCol)>>,
|
||||
|
||||
config: BasicHtmlWriterConfig,
|
||||
|
||||
w: W,
|
||||
}
|
||||
|
||||
impl<'a, W> BasicHtmlWriter<'a, W>
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
pub fn new(
|
||||
writer: W,
|
||||
srcmap: Option<&'a mut Vec<(BytePos, LineCol)>>,
|
||||
config: BasicHtmlWriterConfig,
|
||||
) -> Self {
|
||||
let indent_type = match config.indent_type {
|
||||
IndentType::Tab => "\t",
|
||||
IndentType::Space => " ",
|
||||
};
|
||||
let linefeed = match config.linefeed {
|
||||
LineFeed::LF => "\n",
|
||||
LineFeed::CRLF => "\r\n",
|
||||
};
|
||||
|
||||
BasicHtmlWriter {
|
||||
line_start: true,
|
||||
line: 0,
|
||||
col: 0,
|
||||
|
||||
indent_type,
|
||||
indent_level: 0,
|
||||
linefeed,
|
||||
|
||||
config,
|
||||
srcmap,
|
||||
|
||||
w: writer,
|
||||
}
|
||||
}
|
||||
|
||||
fn write(&mut self, span: Option<Span>, data: &str) -> Result {
|
||||
if !data.is_empty() {
|
||||
if self.line_start {
|
||||
self.write_indent_string()?;
|
||||
self.line_start = false;
|
||||
}
|
||||
|
||||
if let Some(span) = span {
|
||||
if !span.is_dummy() {
|
||||
self.srcmap(span.lo())
|
||||
}
|
||||
}
|
||||
|
||||
self.raw_write(data)?;
|
||||
|
||||
if let Some(span) = span {
|
||||
if !span.is_dummy() {
|
||||
self.srcmap(span.hi())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn write_indent_string(&mut self) -> Result {
|
||||
for _ in 0..(self.config.indent_width * self.indent_level as i32) {
|
||||
self.raw_write(self.indent_type)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn raw_write(&mut self, data: &str) -> Result {
|
||||
self.w.write_str(data)?;
|
||||
self.col += data.chars().count();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn srcmap(&mut self, byte_pos: BytePos) {
|
||||
if let Some(ref mut srcmap) = self.srcmap {
|
||||
srcmap.push((
|
||||
byte_pos,
|
||||
LineCol {
|
||||
line: self.line as _,
|
||||
col: self.col as _,
|
||||
},
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<W> HtmlWriter for BasicHtmlWriter<'_, W>
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
fn write_space(&mut self) -> Result {
|
||||
self.write_raw(None, " ")
|
||||
}
|
||||
|
||||
fn write_newline(&mut self) -> Result {
|
||||
if !self.line_start {
|
||||
self.raw_write(self.linefeed)?;
|
||||
self.line += 1;
|
||||
self.col = 0;
|
||||
self.line_start = true;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn write_raw(&mut self, span: Option<Span>, text: &str) -> Result {
|
||||
debug_assert!(
|
||||
!text.contains('\n'),
|
||||
"write_raw should not contains new lines, got '{}'",
|
||||
text,
|
||||
);
|
||||
|
||||
self.write(span, text)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn write_str(&mut self, span: Span, s: &str) -> Result {
|
||||
if !s.is_empty() {
|
||||
let mut lines = s.split('\n').peekable();
|
||||
let mut lo_byte_pos = span.lo();
|
||||
|
||||
while let Some(line) = lines.next() {
|
||||
if !span.is_dummy() {
|
||||
self.srcmap(lo_byte_pos)
|
||||
}
|
||||
|
||||
self.raw_write(line)?;
|
||||
|
||||
if lines.peek().is_some() {
|
||||
self.raw_write("\n")?;
|
||||
self.line += 1;
|
||||
self.col = 0;
|
||||
|
||||
if !span.is_dummy() {
|
||||
lo_byte_pos = lo_byte_pos + BytePos((line.len() + 1) as u32);
|
||||
}
|
||||
} else if !span.is_dummy() {
|
||||
self.srcmap(span.hi());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn increase_indent(&mut self) {
|
||||
self.indent_level += 1;
|
||||
}
|
||||
|
||||
fn decrease_indent(&mut self) {
|
||||
debug_assert!(
|
||||
(self.indent_level as i32) >= 0,
|
||||
"indent should zero or greater than zero",
|
||||
);
|
||||
|
||||
self.indent_level -= 1;
|
||||
}
|
||||
}
|
21
crates/swc_html_codegen/src/writer/mod.rs
Normal file
21
crates/swc_html_codegen/src/writer/mod.rs
Normal file
@ -0,0 +1,21 @@
|
||||
use std::fmt::Result;
|
||||
|
||||
use auto_impl::auto_impl;
|
||||
use swc_common::Span;
|
||||
|
||||
pub mod basic;
|
||||
|
||||
#[auto_impl(&mut, Box)]
|
||||
pub trait HtmlWriter {
|
||||
fn write_space(&mut self) -> Result;
|
||||
|
||||
fn write_newline(&mut self) -> Result;
|
||||
|
||||
fn write_raw(&mut self, span: Option<Span>, text: &str) -> Result;
|
||||
|
||||
fn write_str(&mut self, span: Span, s: &str) -> Result;
|
||||
|
||||
fn increase_indent(&mut self);
|
||||
|
||||
fn decrease_indent(&mut self);
|
||||
}
|
218
crates/swc_html_codegen/tests/fixture.rs
Normal file
218
crates/swc_html_codegen/tests/fixture.rs
Normal file
@ -0,0 +1,218 @@
|
||||
#![allow(clippy::needless_update)]
|
||||
|
||||
use std::{
|
||||
mem::take,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
use swc_common::Span;
|
||||
use swc_html_ast::*;
|
||||
use swc_html_codegen::{
|
||||
writer::basic::{BasicHtmlWriter, BasicHtmlWriterConfig, IndentType, LineFeed},
|
||||
CodeGenerator, CodegenConfig, Emit,
|
||||
};
|
||||
use swc_html_parser::{parse_file, parser::ParserConfig};
|
||||
use swc_html_visit::{VisitMut, VisitMutWith};
|
||||
use testing::{assert_eq, run_test2, NormalizedOutput};
|
||||
|
||||
fn run(input: &Path, minify: bool) {
|
||||
let dir = input.parent().unwrap();
|
||||
// let map = if minify {
|
||||
// dir.join(format!(
|
||||
// "output.min.{}.map",
|
||||
// input.extension().unwrap().to_string_lossy()
|
||||
// ))
|
||||
// } else {
|
||||
// dir.join(format!(
|
||||
// "output.{}.map",
|
||||
// input.extension().unwrap().to_string_lossy()
|
||||
// ))
|
||||
// };
|
||||
let output = if minify {
|
||||
dir.join(format!(
|
||||
"output.min.{}",
|
||||
input.extension().unwrap().to_string_lossy()
|
||||
))
|
||||
} else {
|
||||
dir.join(format!(
|
||||
"output.{}",
|
||||
input.extension().unwrap().to_string_lossy()
|
||||
))
|
||||
};
|
||||
|
||||
run_test2(false, |cm, handler| {
|
||||
let fm = cm.load_file(input).unwrap();
|
||||
|
||||
eprintln!("==== ==== Input ==== ====\n{}\n", fm.src);
|
||||
|
||||
let mut errors = vec![];
|
||||
let mut document: Document = parse_file(
|
||||
&fm,
|
||||
ParserConfig {
|
||||
..Default::default()
|
||||
},
|
||||
&mut errors,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
for err in take(&mut errors) {
|
||||
err.to_diagnostics(&handler).emit();
|
||||
}
|
||||
|
||||
let mut html_str = String::new();
|
||||
// let mut src_map_buf = vec![];
|
||||
|
||||
{
|
||||
let wr = BasicHtmlWriter::new(
|
||||
&mut html_str,
|
||||
None, // Some(&mut src_map_buf),
|
||||
BasicHtmlWriterConfig::default(),
|
||||
);
|
||||
|
||||
let mut gen = CodeGenerator::new(wr, CodegenConfig { minify });
|
||||
|
||||
gen.emit(&document).unwrap();
|
||||
}
|
||||
|
||||
// let source_map = cm.build_source_map(&mut src_map_buf);
|
||||
// let mut source_map_output: Vec<u8> = vec![];
|
||||
// source_map.to_writer(&mut source_map_output).unwrap();
|
||||
// let str_source_map_output = String::from_utf8_lossy(&source_map_output);
|
||||
// std::fs::write(map, &*str_source_map_output).expect("Unable to write file");
|
||||
|
||||
let fm_output = cm.load_file(&output).unwrap();
|
||||
|
||||
NormalizedOutput::from(html_str)
|
||||
.compare_to_file(output)
|
||||
.unwrap();
|
||||
|
||||
let mut errors = vec![];
|
||||
let mut document_output: Document = parse_file(
|
||||
&fm_output,
|
||||
ParserConfig {
|
||||
..Default::default()
|
||||
},
|
||||
&mut errors,
|
||||
)
|
||||
.map_err(|err| {
|
||||
err.to_diagnostics(&handler).emit();
|
||||
})?;
|
||||
|
||||
for err in take(&mut errors) {
|
||||
err.to_diagnostics(&handler).emit();
|
||||
}
|
||||
|
||||
document.visit_mut_with(&mut NormalizeTest);
|
||||
document_output.visit_mut_with(&mut NormalizeTest);
|
||||
|
||||
assert_eq!(document, document_output);
|
||||
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
struct NormalizeTest;
|
||||
|
||||
impl VisitMut for NormalizeTest {
|
||||
fn visit_mut_token_and_span(&mut self, n: &mut TokenAndSpan) {
|
||||
n.visit_mut_children_with(self);
|
||||
}
|
||||
|
||||
fn visit_mut_span(&mut self, n: &mut Span) {
|
||||
*n = Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
#[testing::fixture("tests/fixture/**/input.html")]
|
||||
fn html(input: PathBuf) {
|
||||
run(&input, false);
|
||||
run(&input, true);
|
||||
}
|
||||
|
||||
#[testing::fixture("tests/options/indent_type/**/input.html")]
|
||||
fn indent_type(input: PathBuf) {
|
||||
let dir = input.parent().unwrap();
|
||||
let output = dir.join(format!(
|
||||
"output.{}",
|
||||
input.extension().unwrap().to_string_lossy()
|
||||
));
|
||||
|
||||
run_test2(false, |cm, handler| {
|
||||
let fm = cm.load_file(&input).unwrap();
|
||||
|
||||
eprintln!("==== ==== Input ==== ====\n{}\n", fm.src);
|
||||
|
||||
let mut errors = vec![];
|
||||
let mut document: Document = parse_file(
|
||||
&fm,
|
||||
ParserConfig {
|
||||
..Default::default()
|
||||
},
|
||||
&mut errors,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
for err in take(&mut errors) {
|
||||
err.to_diagnostics(&handler).emit();
|
||||
}
|
||||
|
||||
let mut html_str = String::new();
|
||||
|
||||
{
|
||||
let wr = BasicHtmlWriter::new(
|
||||
&mut html_str,
|
||||
None,
|
||||
BasicHtmlWriterConfig {
|
||||
indent_type: IndentType::Tab,
|
||||
indent_width: 2,
|
||||
linefeed: LineFeed::default(),
|
||||
},
|
||||
);
|
||||
|
||||
let mut gen = CodeGenerator::new(wr, CodegenConfig { minify: false });
|
||||
|
||||
gen.emit(&document).unwrap();
|
||||
}
|
||||
|
||||
println!("{:?}", output);
|
||||
|
||||
let fm_output = cm.load_file(&output).unwrap();
|
||||
|
||||
NormalizedOutput::from(html_str)
|
||||
.compare_to_file(output)
|
||||
.unwrap();
|
||||
|
||||
let mut errors = vec![];
|
||||
let mut document_output: Document = parse_file(
|
||||
&fm_output,
|
||||
ParserConfig {
|
||||
..Default::default()
|
||||
},
|
||||
&mut errors,
|
||||
)
|
||||
.map_err(|err| {
|
||||
err.to_diagnostics(&handler).emit();
|
||||
})?;
|
||||
|
||||
for err in take(&mut errors) {
|
||||
err.to_diagnostics(&handler).emit();
|
||||
}
|
||||
|
||||
document.visit_mut_with(&mut NormalizeTest);
|
||||
document_output.visit_mut_with(&mut NormalizeTest);
|
||||
|
||||
assert_eq!(document, document_output);
|
||||
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
struct DropSpan;
|
||||
|
||||
impl VisitMut for DropSpan {
|
||||
fn visit_mut_span(&mut self, n: &mut Span) {
|
||||
*n = Default::default()
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
||||
"http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>!DOCTYPE</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
</head>
|
||||
<body>
|
||||
<p>Разум — это Будда, а прекращение умозрительного мышления — это путь.
|
||||
Перестав мыслить понятиями и размышлять о путях существования и небытия,
|
||||
о душе и плоти, о пассивном и активном и о других подобных вещах,
|
||||
начинаешь осознавать, что разум — это Будда,
|
||||
что Будда — это сущность разума,
|
||||
и что разум подобен бесконечности.</p>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>!DOCTYPE</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
</head>
|
||||
<body>
|
||||
<p>Разум — это Будда, а прекращение умозрительного мышления — это путь.
|
||||
Перестав мыслить понятиями и размышлять о путях существования и небытия,
|
||||
о душе и плоти, о пассивном и активном и о других подобных вещах,
|
||||
начинаешь осознавать, что разум — это Будда,
|
||||
что Будда — это сущность разума,
|
||||
и что разум подобен бесконечности.</p>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>!DOCTYPE</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
</head>
|
||||
<body>
|
||||
<p>Разум — это Будда, а прекращение умозрительного мышления — это путь.
|
||||
Перестав мыслить понятиями и размышлять о путях существования и небытия,
|
||||
о душе и плоти, о пассивном и активном и о других подобных вещах,
|
||||
начинаешь осознавать, что разум — это Будда,
|
||||
что Будда — это сущность разума,
|
||||
и что разум подобен бесконечности.</p>
|
||||
</body>
|
||||
</html>
|
10
crates/swc_html_codegen/tests/fixture/document/input.html
Normal file
10
crates/swc_html_codegen/tests/fixture/document/input.html
Normal file
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h1>My First Heading</h1>
|
||||
|
||||
<p>My first paragraph.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
10
crates/swc_html_codegen/tests/fixture/document/output.html
Normal file
10
crates/swc_html_codegen/tests/fixture/document/output.html
Normal file
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h1>My First Heading</h1>
|
||||
|
||||
<p>My first paragraph.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h1>My First Heading</h1>
|
||||
|
||||
<p>My first paragraph.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
13
crates/swc_html_codegen/tests/fixture/headings/input.html
Normal file
13
crates/swc_html_codegen/tests/fixture/headings/input.html
Normal file
@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h1>This is heading 1</h1>
|
||||
<h2>This is heading 2</h2>
|
||||
<h3>This is heading 3</h3>
|
||||
<h4>This is heading 4</h4>
|
||||
<h5>This is heading 5</h5>
|
||||
<h6>This is heading 6</h6>
|
||||
|
||||
</body>
|
||||
</html>
|
13
crates/swc_html_codegen/tests/fixture/headings/output.html
Normal file
13
crates/swc_html_codegen/tests/fixture/headings/output.html
Normal file
@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h1>This is heading 1</h1>
|
||||
<h2>This is heading 2</h2>
|
||||
<h3>This is heading 3</h3>
|
||||
<h4>This is heading 4</h4>
|
||||
<h5>This is heading 5</h5>
|
||||
<h6>This is heading 6</h6>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h1>This is heading 1</h1>
|
||||
<h2>This is heading 2</h2>
|
||||
<h3>This is heading 3</h3>
|
||||
<h4>This is heading 4</h4>
|
||||
<h5>This is heading 5</h5>
|
||||
<h6>This is heading 6</h6>
|
||||
|
||||
</body>
|
||||
</html>
|
11
crates/swc_html_codegen/tests/fixture/images/input.html
Normal file
11
crates/swc_html_codegen/tests/fixture/images/input.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h2>HTML Images</h2>
|
||||
<p>HTML images are defined with the img tag:</p>
|
||||
|
||||
<img src="w3schools.jpg" alt="W3Schools.com" width="104" height="142">
|
||||
|
||||
</body>
|
||||
</html>
|
11
crates/swc_html_codegen/tests/fixture/images/output.html
Normal file
11
crates/swc_html_codegen/tests/fixture/images/output.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h2>HTML Images</h2>
|
||||
<p>HTML images are defined with the img tag:</p>
|
||||
|
||||
<img src="w3schools.jpg" alt="W3Schools.com" width="104" height="142">
|
||||
|
||||
</body>
|
||||
</html>
|
11
crates/swc_html_codegen/tests/fixture/images/output.min.html
Normal file
11
crates/swc_html_codegen/tests/fixture/images/output.min.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h2>HTML Images</h2>
|
||||
<p>HTML images are defined with the img tag:</p>
|
||||
|
||||
<img src="w3schools.jpg" alt="W3Schools.com" width="104" height="142">
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<p id="demo"></p>
|
||||
|
||||
<script>
|
||||
document.getElementById("demo").innerHTML = "Hello JavaScript!";
|
||||
</script>
|
||||
|
||||
<noscript>Sorry, your browser does not support JavaScript!</noscript>
|
||||
|
||||
<p>A browser without support for JavaScript will show the text written inside the noscript element.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<p id="demo"></p>
|
||||
|
||||
<script>
|
||||
document.getElementById("demo").innerHTML = "Hello JavaScript!";
|
||||
</script>
|
||||
|
||||
<noscript>Sorry, your browser does not support JavaScript!</noscript>
|
||||
|
||||
<p>A browser without support for JavaScript will show the text written inside the noscript element.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<p id="demo"></p>
|
||||
|
||||
<script>
|
||||
document.getElementById("demo").innerHTML = "Hello JavaScript!";
|
||||
</script>
|
||||
|
||||
<noscript>Sorry, your browser does not support JavaScript!</noscript>
|
||||
|
||||
<p>A browser without support for JavaScript will show the text written inside the noscript element.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,9 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<p>This is a paragraph.</p>
|
||||
<p>This is another paragraph.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,9 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<p>This is a paragraph.</p>
|
||||
<p>This is another paragraph.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,9 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<p>This is a paragraph.</p>
|
||||
<p>This is another paragraph.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
19
crates/swc_html_codegen/tests/fixture/pre-tag/input.html
Normal file
19
crates/swc_html_codegen/tests/fixture/pre-tag/input.html
Normal file
@ -0,0 +1,19 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<p>The pre tag preserves both spaces and line breaks:</p>
|
||||
|
||||
<pre>
|
||||
My Bonnie lies over the ocean.
|
||||
|
||||
My Bonnie lies over the sea.
|
||||
|
||||
My Bonnie lies over the ocean.
|
||||
|
||||
Oh, bring back my Bonnie to me.
|
||||
</pre>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
19
crates/swc_html_codegen/tests/fixture/pre-tag/output.html
Normal file
19
crates/swc_html_codegen/tests/fixture/pre-tag/output.html
Normal file
@ -0,0 +1,19 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<p>The pre tag preserves both spaces and line breaks:</p>
|
||||
|
||||
<pre>
|
||||
My Bonnie lies over the ocean.
|
||||
|
||||
My Bonnie lies over the sea.
|
||||
|
||||
My Bonnie lies over the ocean.
|
||||
|
||||
Oh, bring back my Bonnie to me.
|
||||
</pre>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
@ -0,0 +1,19 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<p>The pre tag preserves both spaces and line breaks:</p>
|
||||
|
||||
<pre>
|
||||
My Bonnie lies over the ocean.
|
||||
|
||||
My Bonnie lies over the sea.
|
||||
|
||||
My Bonnie lies over the ocean.
|
||||
|
||||
Oh, bring back my Bonnie to me.
|
||||
</pre>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
@ -0,0 +1,8 @@
|
||||
<!-- following are self closing tags -->
|
||||
<!-- have no content or child -->
|
||||
|
||||
<br />
|
||||
<hr />
|
||||
<input type="text" />
|
||||
<img src="#URL" alt="image" />
|
||||
<area shape="rect" coords="0,0,100,100" href="#URL" />
|
@ -0,0 +1,8 @@
|
||||
<!-- following are self closing tags -->
|
||||
<!-- have no content or child -->
|
||||
|
||||
<br/>
|
||||
<hr/>
|
||||
<input type="text"/>
|
||||
<img src="#URL" alt="image"/>
|
||||
<area shape="rect" coords="0,0,100,100" href="#URL"/>
|
@ -0,0 +1,8 @@
|
||||
<!-- following are self closing tags -->
|
||||
<!-- have no content or child -->
|
||||
|
||||
<br/>
|
||||
<hr/>
|
||||
<input type="text"/>
|
||||
<img src="#URL" alt="image"/>
|
||||
<area shape="rect" coords="0,0,100,100" href="#URL"/>
|
10
crates/swc_html_codegen/tests/options/indent_type/input.html
Normal file
10
crates/swc_html_codegen/tests/options/indent_type/input.html
Normal file
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h1>My First Heading</h1>
|
||||
|
||||
<p>My first paragraph.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h1>My First Heading</h1>
|
||||
|
||||
<p>My first paragraph.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h1>My First Heading</h1>
|
||||
|
||||
<p>My first paragraph.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h1>My First Heading</h1>
|
||||
|
||||
<p>My first paragraph.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h1>My First Heading</h1>
|
||||
|
||||
<p>My first paragraph.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h1>My First Heading</h1>
|
||||
|
||||
<p>My first paragraph.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h1>My First Heading</h1>
|
||||
|
||||
<p>My first paragraph.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h1>My First Heading</h1>
|
||||
|
||||
<p>My first paragraph.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h1>My First Heading</h1>
|
||||
|
||||
<p>My first paragraph.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
10
crates/swc_html_codegen/tests/options/linefeed/lf/input.html
Normal file
10
crates/swc_html_codegen/tests/options/linefeed/lf/input.html
Normal file
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h1>My First Heading</h1>
|
||||
|
||||
<p>My first paragraph.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h1>My First Heading</h1>
|
||||
|
||||
<p>My first paragraph.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h1>My First Heading</h1>
|
||||
|
||||
<p>My first paragraph.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
19
crates/swc_html_codegen_macros/Cargo.toml
Normal file
19
crates/swc_html_codegen_macros/Cargo.toml
Normal file
@ -0,0 +1,19 @@
|
||||
[package]
|
||||
authors = ["강동윤 <kdy1997.dev@gmail.com>", "Alexander Akait <sheo13666q@gmail.com>"]
|
||||
description = "Internal macro for the html code generator"
|
||||
documentation = "https://rustdoc.swc.rs/swc_html_codegen_macros/"
|
||||
edition = "2021"
|
||||
license = "Apache-2.0"
|
||||
name = "swc_html_codegen_macros"
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "0.1.0"
|
||||
|
||||
[lib]
|
||||
proc-macro = true
|
||||
|
||||
[dependencies]
|
||||
pmutil = "0.5.1"
|
||||
proc-macro2 = "1"
|
||||
quote = "1"
|
||||
swc_macros_common = { version = "0.3.2", path = "../swc_macros_common" }
|
||||
syn = { version = "1", features = ["fold"] }
|
86
crates/swc_html_codegen_macros/src/lib.rs
Normal file
86
crates/swc_html_codegen_macros/src/lib.rs
Normal file
@ -0,0 +1,86 @@
|
||||
#![deny(clippy::all)]
|
||||
|
||||
extern crate proc_macro;
|
||||
|
||||
use pmutil::{smart_quote, Quote, ToTokensExt};
|
||||
use syn::{FnArg, ImplItemMethod, Type, TypeReference};
|
||||
|
||||
#[proc_macro_attribute]
|
||||
pub fn emitter(
|
||||
_attr: proc_macro::TokenStream,
|
||||
item: proc_macro::TokenStream,
|
||||
) -> proc_macro::TokenStream {
|
||||
let item: ImplItemMethod = syn::parse(item).expect("failed to parse input as an item");
|
||||
let item = expand(item);
|
||||
|
||||
item.dump().into()
|
||||
}
|
||||
|
||||
fn expand(i: ImplItemMethod) -> ImplItemMethod {
|
||||
let mtd_name = i.sig.ident.clone();
|
||||
assert!(
|
||||
format!("{}", i.sig.ident).starts_with("emit_"),
|
||||
"#[emitter] methods should start with `emit_`"
|
||||
);
|
||||
let block = {
|
||||
let node_type = {
|
||||
i.sig
|
||||
.inputs
|
||||
.clone()
|
||||
.into_iter()
|
||||
.nth(1)
|
||||
.and_then(|arg| match arg {
|
||||
FnArg::Typed(ty) => Some(ty.ty),
|
||||
_ => None,
|
||||
})
|
||||
.map(|ty| {
|
||||
// &Ident -> Ident
|
||||
match *ty {
|
||||
Type::Reference(TypeReference { elem, .. }) => *elem,
|
||||
_ => panic!(
|
||||
"Type of node parameter should be reference but got {}",
|
||||
ty.dump()
|
||||
),
|
||||
}
|
||||
})
|
||||
.expect(
|
||||
"#[emitter] methods should have signature of
|
||||
fn (&mut self, node: Node) -> Result;
|
||||
",
|
||||
)
|
||||
};
|
||||
|
||||
Quote::new_call_site()
|
||||
.quote_with(smart_quote!(
|
||||
Vars {
|
||||
block: &i.block,
|
||||
NodeType: &node_type,
|
||||
mtd_name,
|
||||
},
|
||||
{
|
||||
{
|
||||
impl<W> crate::Emit<NodeType> for crate::CodeGenerator<W>
|
||||
where
|
||||
W: crate::writer::HtmlWriter,
|
||||
{
|
||||
fn emit(&mut self, n: &NodeType) -> crate::Result {
|
||||
self.mtd_name(n)
|
||||
}
|
||||
}
|
||||
|
||||
block
|
||||
|
||||
// Emitter methods return Result<_, _>
|
||||
// We inject this to avoid writing Ok(()) every time.
|
||||
#[allow(unreachable_code)]
|
||||
{
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
}
|
||||
))
|
||||
.parse()
|
||||
};
|
||||
|
||||
ImplItemMethod { block, ..i }
|
||||
}
|
26
crates/swc_html_parser/Cargo.toml
Normal file
26
crates/swc_html_parser/Cargo.toml
Normal file
@ -0,0 +1,26 @@
|
||||
[package]
|
||||
authors = ["강동윤 <kdy1997.dev@gmail.com>", "Alexander Akait <sheo13666q@gmail.com>"]
|
||||
description = "HTML parser"
|
||||
documentation = "https://rustdoc.swc.rs/swc_html_parser/"
|
||||
edition = "2021"
|
||||
include = ["Cargo.toml", "src/**/*.rs"]
|
||||
license = "Apache-2.0"
|
||||
name = "swc_html_parser"
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "0.1.0"
|
||||
|
||||
[features]
|
||||
debug = []
|
||||
|
||||
[dependencies]
|
||||
bitflags = "1.2.1"
|
||||
lexical = "6.1.0"
|
||||
swc_atoms = {version = "0.2.7", path = "../swc_atoms"}
|
||||
swc_common = {version = "0.17.0", path = "../swc_common"}
|
||||
swc_html_ast = {version = "0.1.0", path = "../swc_html_ast"}
|
||||
|
||||
[dev-dependencies]
|
||||
serde = "1.0.127"
|
||||
serde_json = "1.0.66"
|
||||
swc_html_visit = {version = "0.1.0", path = "../swc_html_visit"}
|
||||
testing = {version = "0.19.0", path = "../testing"}
|
209
crates/swc_html_parser/src/error.rs
Normal file
209
crates/swc_html_parser/src/error.rs
Normal file
@ -0,0 +1,209 @@
|
||||
use std::borrow::Cow;
|
||||
|
||||
use swc_common::{
|
||||
errors::{DiagnosticBuilder, Handler},
|
||||
Span,
|
||||
};
|
||||
|
||||
/// Size is same as a size of a pointer.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct Error {
|
||||
inner: Box<(Span, ErrorKind)>,
|
||||
}
|
||||
|
||||
impl Error {
|
||||
pub fn kind(&self) -> &ErrorKind {
|
||||
&self.inner.1
|
||||
}
|
||||
|
||||
pub fn into_inner(self) -> Box<(Span, ErrorKind)> {
|
||||
self.inner
|
||||
}
|
||||
|
||||
pub fn new(span: Span, kind: ErrorKind) -> Self {
|
||||
Error {
|
||||
inner: Box::new((span, kind)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_diagnostics<'a>(&self, handler: &'a Handler) -> DiagnosticBuilder<'a> {
|
||||
let msg: Cow<_> = match &self.inner.1 {
|
||||
ErrorKind::Eof => "Unexpected end of file".into(),
|
||||
ErrorKind::ControlCharacterInInputStream => "Control character in input stream".into(),
|
||||
ErrorKind::NoncharacterInInputStream => "Noncharacter in input stream".into(),
|
||||
ErrorKind::SurrogateInInputStream => "Surrogate in input stream".into(),
|
||||
ErrorKind::NonVoidHtmlElementStartTagWithTrailingSolidus => {
|
||||
"Non void html element start tag with trailing solidus".into()
|
||||
}
|
||||
ErrorKind::EndTagWithAttributes => "End tag with attributes".into(),
|
||||
ErrorKind::EndTagWithTrailingSolidus => "End tag with trailing solidus".into(),
|
||||
ErrorKind::UnexpectedSolidusInTag => "Unexpected solidus in tag".into(),
|
||||
ErrorKind::UnexpectedNullCharacter => "Unexpected null character".into(),
|
||||
ErrorKind::UnexpectedQuestionMarkInsteadOfTagName => {
|
||||
"Unexpected question mark instead of tag name".into()
|
||||
}
|
||||
ErrorKind::InvalidFirstCharacterOfTagName => {
|
||||
"Invalid first character of tag name".into()
|
||||
}
|
||||
ErrorKind::UnexpectedEqualsSignBeforeAttributeName => {
|
||||
"Unexpected equals sign before attribute name".into()
|
||||
}
|
||||
ErrorKind::MissingEndTagName => "Missing end tag name".into(),
|
||||
ErrorKind::UnexpectedCharacterInAttributeName => {
|
||||
"Unexpected character in attribute name".into()
|
||||
}
|
||||
ErrorKind::UnknownNamedCharacterReference => "Unknown named character reference".into(),
|
||||
ErrorKind::MissingSemicolonAfterCharacterReference => {
|
||||
"Missing semicolon after character reference".into()
|
||||
}
|
||||
ErrorKind::UnexpectedCharacterAfterDoctypeSystemIdentifier => {
|
||||
"Unexpected character after doctype system identifier".into()
|
||||
}
|
||||
ErrorKind::UnexpectedCharacterInUnquotedAttributeValue => {
|
||||
"Unexpected character in unquoted attribute value".into()
|
||||
}
|
||||
ErrorKind::EofBeforeTagName => "Eof before tag name".into(),
|
||||
ErrorKind::EofInTag => "Eof in tag".into(),
|
||||
ErrorKind::MissingAttributeValue => "Missing attribute value".into(),
|
||||
ErrorKind::MissingWhitespaceBetweenAttributes => {
|
||||
"Missing whitespace between attributes".into()
|
||||
}
|
||||
ErrorKind::MissingWhitespaceAfterDoctypePublicKeyword => {
|
||||
"Missing whitespace after doctype public keyword".into()
|
||||
}
|
||||
ErrorKind::MissingWhitespaceBetweenDoctypePublicAndSystemIdentifiers => {
|
||||
"Missing whitespace between doctype public and system identifiers".into()
|
||||
}
|
||||
ErrorKind::MissingWhitespaceAfterDoctypeSystemKeyword => {
|
||||
"Missing whitespace after doctype system keyword".into()
|
||||
}
|
||||
ErrorKind::MissingQuoteBeforeDoctypePublicIdentifier => {
|
||||
"Missing quote before doctype public identifier".into()
|
||||
}
|
||||
ErrorKind::MissingQuoteBeforeDoctypeSystemIdentifier => {
|
||||
"Missing quote before doctype system identifier".into()
|
||||
}
|
||||
ErrorKind::MissingDoctypePublicIdentifier => "Missing doctype public identifier".into(),
|
||||
ErrorKind::MissingDoctypeSystemIdentifier => "Missing doctype system identifier".into(),
|
||||
ErrorKind::AbruptDoctypePublicIdentifier => "Abrupt doctype public identifier".into(),
|
||||
ErrorKind::AbruptDoctypeSystemIdentifier => "Abrupt doctype system identifier".into(),
|
||||
ErrorKind::CdataInHtmlContent => "Cdata in html content".into(),
|
||||
ErrorKind::IncorrectlyOpenedComment => "Incorrectly opened comment".into(),
|
||||
ErrorKind::EofInScriptHtmlCommentLikeText => {
|
||||
"Eof in script html comment like text".into()
|
||||
}
|
||||
ErrorKind::EofInDoctype => "Eof in doctype".into(),
|
||||
ErrorKind::NestedComment => "Nested comment".into(),
|
||||
ErrorKind::AbruptClosingOfEmptyComment => "Abrupt closing of empty comment".into(),
|
||||
ErrorKind::EofInComment => "Eof in comment".into(),
|
||||
ErrorKind::IncorrectlyClosedComment => "Incorrectly closed comment".into(),
|
||||
ErrorKind::EofInCdata => "Eof in cdata".into(),
|
||||
ErrorKind::AbsenceOfDigitsInNumericCharacterReference => {
|
||||
"Absence of digits in numeric character reference".into()
|
||||
}
|
||||
ErrorKind::NullCharacterReference => "Null character reference".into(),
|
||||
ErrorKind::SurrogateCharacterReference => "Surrogate character reference".into(),
|
||||
ErrorKind::CharacterReferenceOutsideUnicodeRange => {
|
||||
"Character reference outside unicode range".into()
|
||||
}
|
||||
ErrorKind::ControlCharacterReference => "Control character reference".into(),
|
||||
ErrorKind::NoncharacterCharacterReference => "Noncharacter character reference".into(),
|
||||
ErrorKind::MissingWhitespaceBeforeDoctypeName => {
|
||||
"Missing whitespace before doctype name".into()
|
||||
}
|
||||
ErrorKind::MissingDoctypeName => "Missing doctype name".into(),
|
||||
ErrorKind::InvalidCharacterSequenceAfterDoctypeName => {
|
||||
"Invalid character sequence after doctype name".into()
|
||||
}
|
||||
ErrorKind::DuplicateAttribute => "Duplicate attribute".into(),
|
||||
ErrorKind::NonConformingDoctype => "Non conforming doctype".into(),
|
||||
ErrorKind::MissingDoctype => "Missing doctype".into(),
|
||||
ErrorKind::MisplacedDoctype => "Misplaced doctype".into(),
|
||||
ErrorKind::EndTagWithoutMatchingOpenElement => {
|
||||
"End tag without matching open element".into()
|
||||
}
|
||||
ErrorKind::ClosingOfElementWithOpenChildElements => {
|
||||
"Closing of element with open child elements".into()
|
||||
}
|
||||
ErrorKind::DisallowedContentInNoscriptInHead => {
|
||||
"Disallowed content in noscript in head".into()
|
||||
}
|
||||
ErrorKind::OpenElementsLeftAfterEof => "Open elements left after eof".into(),
|
||||
ErrorKind::AbandonedHeadElementChild => "Abandoned head element child".into(),
|
||||
ErrorKind::MisplacedStartTagForHeadElement => {
|
||||
"Misplaced start tag for head element".into()
|
||||
}
|
||||
ErrorKind::NestedNoscriptInHead => "Nested noscript in head".into(),
|
||||
ErrorKind::EofInElementThatCanContainOnlyText => {
|
||||
"Eof in element that can contain only text".into()
|
||||
}
|
||||
};
|
||||
handler.struct_span_err(self.inner.0, &msg)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[non_exhaustive]
|
||||
pub enum ErrorKind {
|
||||
Eof,
|
||||
ControlCharacterInInputStream,
|
||||
NoncharacterInInputStream,
|
||||
SurrogateInInputStream,
|
||||
NonVoidHtmlElementStartTagWithTrailingSolidus,
|
||||
EndTagWithAttributes,
|
||||
EndTagWithTrailingSolidus,
|
||||
UnexpectedSolidusInTag,
|
||||
UnexpectedNullCharacter,
|
||||
UnexpectedQuestionMarkInsteadOfTagName,
|
||||
InvalidFirstCharacterOfTagName,
|
||||
UnexpectedEqualsSignBeforeAttributeName,
|
||||
MissingEndTagName,
|
||||
UnexpectedCharacterInAttributeName,
|
||||
UnknownNamedCharacterReference,
|
||||
MissingSemicolonAfterCharacterReference,
|
||||
UnexpectedCharacterAfterDoctypeSystemIdentifier,
|
||||
UnexpectedCharacterInUnquotedAttributeValue,
|
||||
EofBeforeTagName,
|
||||
EofInTag,
|
||||
MissingAttributeValue,
|
||||
MissingWhitespaceBetweenAttributes,
|
||||
MissingWhitespaceAfterDoctypePublicKeyword,
|
||||
MissingWhitespaceBetweenDoctypePublicAndSystemIdentifiers,
|
||||
MissingWhitespaceAfterDoctypeSystemKeyword,
|
||||
MissingQuoteBeforeDoctypePublicIdentifier,
|
||||
MissingQuoteBeforeDoctypeSystemIdentifier,
|
||||
MissingDoctypePublicIdentifier,
|
||||
MissingDoctypeSystemIdentifier,
|
||||
AbruptDoctypePublicIdentifier,
|
||||
AbruptDoctypeSystemIdentifier,
|
||||
CdataInHtmlContent,
|
||||
IncorrectlyOpenedComment,
|
||||
EofInScriptHtmlCommentLikeText,
|
||||
EofInDoctype,
|
||||
NestedComment,
|
||||
AbruptClosingOfEmptyComment,
|
||||
EofInComment,
|
||||
IncorrectlyClosedComment,
|
||||
EofInCdata,
|
||||
AbsenceOfDigitsInNumericCharacterReference,
|
||||
NullCharacterReference,
|
||||
SurrogateCharacterReference,
|
||||
CharacterReferenceOutsideUnicodeRange,
|
||||
ControlCharacterReference,
|
||||
NoncharacterCharacterReference,
|
||||
MissingWhitespaceBeforeDoctypeName,
|
||||
MissingDoctypeName,
|
||||
InvalidCharacterSequenceAfterDoctypeName,
|
||||
DuplicateAttribute,
|
||||
NonConformingDoctype,
|
||||
MissingDoctype,
|
||||
MisplacedDoctype,
|
||||
EndTagWithoutMatchingOpenElement,
|
||||
ClosingOfElementWithOpenChildElements,
|
||||
DisallowedContentInNoscriptInHead,
|
||||
OpenElementsLeftAfterEof,
|
||||
AbandonedHeadElementChild,
|
||||
MisplacedStartTagForHeadElement,
|
||||
NestedNoscriptInHead,
|
||||
EofInElementThatCanContainOnlyText,
|
||||
}
|
4725
crates/swc_html_parser/src/lexer/mod.rs
Normal file
4725
crates/swc_html_parser/src/lexer/mod.rs
Normal file
File diff suppressed because it is too large
Load Diff
75
crates/swc_html_parser/src/lib.rs
Normal file
75
crates/swc_html_parser/src/lib.rs
Normal file
@ -0,0 +1,75 @@
|
||||
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||
#![deny(unused_must_use)]
|
||||
#![deny(clippy::all)]
|
||||
#![allow(clippy::needless_return)]
|
||||
#![allow(clippy::nonminimal_bool)]
|
||||
#![allow(clippy::wrong_self_convention)]
|
||||
|
||||
use swc_common::{input::StringInput, BytePos, SourceFile};
|
||||
|
||||
use crate::{
|
||||
error::Error,
|
||||
lexer::Lexer,
|
||||
parser::{PResult, Parser, ParserConfig},
|
||||
};
|
||||
|
||||
#[macro_use]
|
||||
mod macros;
|
||||
pub mod error;
|
||||
pub mod lexer;
|
||||
pub mod parser;
|
||||
|
||||
pub trait Parse<T> {
|
||||
fn parse(&mut self) -> PResult<T>;
|
||||
}
|
||||
|
||||
impl<T, P> Parse<Box<T>> for P
|
||||
where
|
||||
Self: Parse<T>,
|
||||
{
|
||||
fn parse(&mut self) -> PResult<Box<T>> {
|
||||
self.parse().map(Box::new)
|
||||
}
|
||||
}
|
||||
|
||||
/// Parse a given string as `T`.
|
||||
///
|
||||
/// If there are syntax errors but if it was recoverable, it will be appendend
|
||||
/// to `errors`.
|
||||
pub fn parse_str<'a, T>(
|
||||
src: &'a str,
|
||||
start_pos: BytePos,
|
||||
end_pos: BytePos,
|
||||
config: ParserConfig,
|
||||
errors: &mut Vec<Error>,
|
||||
) -> PResult<T>
|
||||
where
|
||||
Parser<Lexer<StringInput<'a>>>: Parse<T>,
|
||||
{
|
||||
let lexer = Lexer::new(StringInput::new(src, start_pos, end_pos), config);
|
||||
let mut parser = Parser::new(lexer, config);
|
||||
|
||||
let res = parser.parse();
|
||||
errors.extend(parser.take_errors());
|
||||
res
|
||||
}
|
||||
|
||||
/// Parse a given file as `T`.
|
||||
///
|
||||
/// If there are syntax errors but if it was recoverable, it will be appendend
|
||||
/// to `errors`.
|
||||
pub fn parse_file<'a, T>(
|
||||
fm: &'a SourceFile,
|
||||
config: ParserConfig,
|
||||
errors: &mut Vec<Error>,
|
||||
) -> PResult<T>
|
||||
where
|
||||
Parser<Lexer<StringInput<'a>>>: Parse<T>,
|
||||
{
|
||||
let lexer = Lexer::new(StringInput::from(fm), config);
|
||||
let mut parser = Parser::new(lexer, config);
|
||||
|
||||
let res = parser.parse();
|
||||
errors.extend(parser.take_errors());
|
||||
res
|
||||
}
|
1
crates/swc_html_parser/src/macros.rs
Normal file
1
crates/swc_html_parser/src/macros.rs
Normal file
@ -0,0 +1 @@
|
||||
|
27
crates/swc_html_parser/src/parser/base.rs
Normal file
27
crates/swc_html_parser/src/parser/base.rs
Normal file
@ -0,0 +1,27 @@
|
||||
use swc_common::Span;
|
||||
use swc_html_ast::*;
|
||||
|
||||
use super::{input::ParserInput, PResult, Parser};
|
||||
use crate::Parse;
|
||||
|
||||
impl<I> Parse<Document> for Parser<I>
|
||||
where
|
||||
I: ParserInput,
|
||||
{
|
||||
fn parse(&mut self) -> PResult<Document> {
|
||||
let start = self.input.cur_span()?;
|
||||
|
||||
let mut children = vec![];
|
||||
|
||||
while !is_one_of!(self, EOF) {
|
||||
children.extend(self.input.bump()?);
|
||||
}
|
||||
|
||||
let last = self.input.last_pos()?;
|
||||
|
||||
Ok(Document {
|
||||
span: Span::new(start.lo, last, Default::default()),
|
||||
children,
|
||||
})
|
||||
}
|
||||
}
|
139
crates/swc_html_parser/src/parser/input.rs
Normal file
139
crates/swc_html_parser/src/parser/input.rs
Normal file
@ -0,0 +1,139 @@
|
||||
use std::fmt::Debug;
|
||||
|
||||
use swc_common::{BytePos, Span};
|
||||
use swc_html_ast::{Token, TokenAndSpan};
|
||||
|
||||
use super::PResult;
|
||||
use crate::error::ErrorKind;
|
||||
|
||||
pub trait ParserInput {
|
||||
type State: Debug;
|
||||
|
||||
fn next(&mut self) -> PResult<TokenAndSpan>;
|
||||
|
||||
fn start_pos(&mut self) -> BytePos;
|
||||
|
||||
fn state(&mut self) -> Self::State;
|
||||
|
||||
fn reset(&mut self, state: &Self::State);
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(super) struct Buffer<I>
|
||||
where
|
||||
I: ParserInput,
|
||||
{
|
||||
cur: Option<TokenAndSpan>,
|
||||
peeked: Option<TokenAndSpan>,
|
||||
input: I,
|
||||
last_pos: BytePos,
|
||||
}
|
||||
|
||||
impl<I> Buffer<I>
|
||||
where
|
||||
I: ParserInput,
|
||||
{
|
||||
pub fn new(mut input: I) -> Self {
|
||||
let last_pos = input.start_pos();
|
||||
Buffer {
|
||||
cur: None,
|
||||
peeked: None,
|
||||
input,
|
||||
last_pos,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn last_pos(&mut self) -> PResult<BytePos> {
|
||||
self.cur()?;
|
||||
|
||||
Ok(self.last_pos)
|
||||
}
|
||||
|
||||
pub fn cur_span(&mut self) -> PResult<Span> {
|
||||
if self.cur.is_none() {
|
||||
self.bump_inner()?;
|
||||
}
|
||||
|
||||
Ok(self.cur.as_ref().map(|cur| cur.span).unwrap_or_default())
|
||||
}
|
||||
|
||||
pub fn cur(&mut self) -> PResult<Option<&Token>> {
|
||||
if self.cur.is_none() {
|
||||
self.bump_inner()?;
|
||||
}
|
||||
|
||||
Ok(self.cur.as_ref().map(|v| &v.token))
|
||||
}
|
||||
|
||||
// pub(super) fn peek(&mut self) -> PResult<Option<&Token>> {
|
||||
// self.cur()?;
|
||||
//
|
||||
// if self.peeked.is_none() {
|
||||
// self.peeked = Some(self.input.next()?);
|
||||
// }
|
||||
//
|
||||
// Ok(self.peeked.as_ref().map(|v| &v.token))
|
||||
// }
|
||||
|
||||
#[track_caller]
|
||||
pub fn bump(&mut self) -> PResult<Option<TokenAndSpan>> {
|
||||
debug_assert!(
|
||||
self.cur.is_some(),
|
||||
"bump() is called without checking current token"
|
||||
);
|
||||
|
||||
if let Some(cur) = &self.cur {
|
||||
self.last_pos = cur.span.hi;
|
||||
}
|
||||
|
||||
let token = self.cur.take();
|
||||
|
||||
self.bump_inner()?;
|
||||
|
||||
Ok(token)
|
||||
}
|
||||
|
||||
fn bump_inner(&mut self) -> PResult<()> {
|
||||
if let Some(cur) = &self.cur {
|
||||
self.last_pos = cur.span.hi;
|
||||
}
|
||||
|
||||
self.cur = None;
|
||||
|
||||
if let Some(next) = self.peeked.take() {
|
||||
self.cur = Some(next);
|
||||
}
|
||||
|
||||
if self.cur.is_none() {
|
||||
let res = self.input.next();
|
||||
|
||||
if let Err(err) = &res {
|
||||
if let ErrorKind::Eof = err.kind() {
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
||||
self.cur = res.map(Some)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// pub(super) fn state(&mut self) -> WrappedState<I::State> {
|
||||
// WrappedState {
|
||||
// cur: self.cur.clone(),
|
||||
// inner: self.input.state(),
|
||||
// }
|
||||
// }
|
||||
|
||||
// pub(super) fn reset(&mut self, state: &WrappedState<I::State>) {
|
||||
// self.cur = state.cur.clone();
|
||||
// self.input.reset(&state.inner);
|
||||
// }
|
||||
}
|
||||
|
||||
// #[derive(Debug, Clone)]
|
||||
// pub(super) struct WrappedState<S> {
|
||||
// cur: Option<TokenAndSpan>,
|
||||
// inner: S,
|
||||
// }
|
20
crates/swc_html_parser/src/parser/macros.rs
Normal file
20
crates/swc_html_parser/src/parser/macros.rs
Normal file
@ -0,0 +1,20 @@
|
||||
macro_rules! is {
|
||||
($parser:expr, EOF) => {{
|
||||
$parser.input.cur()?.is_none()
|
||||
}};
|
||||
|
||||
($parser:expr, $tt:tt) => {{
|
||||
match $parser.input.cur()? {
|
||||
Some(tok_pat!($tt)) => true,
|
||||
_ => false,
|
||||
}
|
||||
}};
|
||||
}
|
||||
|
||||
macro_rules! is_one_of {
|
||||
($parser:expr, $($tt:tt),+) => {
|
||||
$(
|
||||
is!($parser, $tt)
|
||||
)||*
|
||||
};
|
||||
}
|
58
crates/swc_html_parser/src/parser/mod.rs
Normal file
58
crates/swc_html_parser/src/parser/mod.rs
Normal file
@ -0,0 +1,58 @@
|
||||
use std::mem::take;
|
||||
|
||||
use swc_html_ast::*;
|
||||
|
||||
use self::input::{Buffer, ParserInput};
|
||||
use crate::{error::Error, Parse};
|
||||
|
||||
#[macro_use]
|
||||
mod macros;
|
||||
mod base;
|
||||
pub mod input;
|
||||
|
||||
pub type PResult<T> = Result<T, Error>;
|
||||
|
||||
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub struct ParserConfig {}
|
||||
|
||||
#[derive(Debug, Default, Clone, Copy)]
|
||||
struct Ctx {}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Parser<I>
|
||||
where
|
||||
I: ParserInput,
|
||||
{
|
||||
#[allow(dead_code)]
|
||||
config: ParserConfig,
|
||||
input: Buffer<I>,
|
||||
// ctx: Ctx,
|
||||
errors: Vec<Error>,
|
||||
}
|
||||
|
||||
impl<I> Parser<I>
|
||||
where
|
||||
I: ParserInput,
|
||||
{
|
||||
pub fn new(input: I, config: ParserConfig) -> Self {
|
||||
Parser {
|
||||
config,
|
||||
input: Buffer::new(input),
|
||||
// ctx: Default::default(),
|
||||
errors: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn dump_cur(&mut self) -> String {
|
||||
format!("{:?}", self.input.cur())
|
||||
}
|
||||
|
||||
/// Take **recovered** errors.
|
||||
pub fn take_errors(&mut self) -> Vec<Error> {
|
||||
take(&mut self.errors)
|
||||
}
|
||||
|
||||
pub fn parse_all(&mut self) -> PResult<Document> {
|
||||
self.parse()
|
||||
}
|
||||
}
|
128
crates/swc_html_parser/tests/fixture.rs
Normal file
128
crates/swc_html_parser/tests/fixture.rs
Normal file
@ -0,0 +1,128 @@
|
||||
#![allow(clippy::needless_update)]
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use swc_common::{errors::Handler, input::SourceFileInput, Span, Spanned};
|
||||
use swc_html_ast::*;
|
||||
use swc_html_parser::{
|
||||
lexer::Lexer,
|
||||
parser::{PResult, Parser, ParserConfig},
|
||||
};
|
||||
use swc_html_visit::{Visit, VisitWith};
|
||||
use testing::NormalizedOutput;
|
||||
|
||||
pub struct Invalid {
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
fn test_pass(input: PathBuf, config: ParserConfig) {
|
||||
testing::run_test2(false, |cm, handler| {
|
||||
let ref_json_path = input.parent().unwrap().join("output.json");
|
||||
|
||||
let fm = cm.load_file(&input).unwrap();
|
||||
let lexer = Lexer::new(SourceFileInput::from(&*fm), config);
|
||||
let mut parser = Parser::new(lexer, config);
|
||||
|
||||
let document: PResult<Document> = parser.parse_all();
|
||||
|
||||
match document {
|
||||
Ok(document) => {
|
||||
let actual_json = serde_json::to_string_pretty(&document)
|
||||
.map(NormalizedOutput::from)
|
||||
.expect("failed to serialize document");
|
||||
|
||||
actual_json.compare_to_file(&ref_json_path).unwrap();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Err(err) => {
|
||||
let mut d = err.to_diagnostics(&handler);
|
||||
d.note(&format!("current token = {}", parser.dump_cur()));
|
||||
|
||||
d.emit();
|
||||
|
||||
Err(())
|
||||
}
|
||||
}
|
||||
})
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[testing::fixture("tests/fixture/**/input.html")]
|
||||
fn pass(input: PathBuf) {
|
||||
test_pass(
|
||||
input,
|
||||
ParserConfig {
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
struct SpanVisualizer<'a> {
|
||||
handler: &'a Handler,
|
||||
}
|
||||
|
||||
macro_rules! mtd {
|
||||
($T:ty,$name:ident) => {
|
||||
fn $name(&mut self, n: &$T) {
|
||||
self.handler
|
||||
.struct_span_err(n.span(), stringify!($T))
|
||||
.emit();
|
||||
|
||||
n.visit_children_with(self);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
impl Visit for SpanVisualizer<'_> {
|
||||
mtd!(Document, visit_document);
|
||||
|
||||
fn visit_token_and_span(&mut self, n: &TokenAndSpan) {
|
||||
self.handler
|
||||
.struct_span_err(n.span, &format!("{:?}", n.token))
|
||||
.emit();
|
||||
}
|
||||
}
|
||||
|
||||
#[testing::fixture("tests/fixture/**/input.html")]
|
||||
fn span(input: PathBuf) {
|
||||
let dir = input.parent().unwrap().to_path_buf();
|
||||
|
||||
let output = testing::run_test2(false, |cm, handler| {
|
||||
// Type annotation
|
||||
if false {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let config = ParserConfig {
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let fm = cm.load_file(&input).unwrap();
|
||||
let lexer = Lexer::new(SourceFileInput::from(&*fm), config);
|
||||
let mut parser = Parser::new(lexer, config);
|
||||
|
||||
let document: PResult<Document> = parser.parse_all();
|
||||
|
||||
match document {
|
||||
Ok(document) => {
|
||||
document.visit_with(&mut SpanVisualizer { handler: &handler });
|
||||
|
||||
Err(())
|
||||
}
|
||||
Err(err) => {
|
||||
let mut d = err.to_diagnostics(&handler);
|
||||
d.note(&format!("current token = {}", parser.dump_cur()));
|
||||
|
||||
d.emit();
|
||||
|
||||
panic!();
|
||||
}
|
||||
}
|
||||
})
|
||||
.unwrap_err();
|
||||
|
||||
output
|
||||
.compare_to_file(&dir.join("span.rust-debug"))
|
||||
.unwrap();
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<a href=https://www.w3schools.com>This is a link</a>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,407 @@
|
||||
{
|
||||
"type": "Document",
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 101,
|
||||
"ctxt": 0
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 15,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Doctype": {
|
||||
"name": "html",
|
||||
"force_quirks": false,
|
||||
"public_id": null,
|
||||
"system_id": null
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 15,
|
||||
"end": 16,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 16,
|
||||
"end": 22,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"StartTag": {
|
||||
"tag_name": "html",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 22,
|
||||
"end": 23,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 23,
|
||||
"end": 29,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"StartTag": {
|
||||
"tag_name": "body",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 29,
|
||||
"end": 30,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 30,
|
||||
"end": 31,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 31,
|
||||
"end": 65,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"StartTag": {
|
||||
"tag_name": "a",
|
||||
"self_closing": false,
|
||||
"attributes": [
|
||||
{
|
||||
"name": "href",
|
||||
"value": "https://www.w3schools.com"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 65,
|
||||
"end": 66,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "T"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 66,
|
||||
"end": 67,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "h"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 67,
|
||||
"end": 68,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "i"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 68,
|
||||
"end": 69,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "s"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 69,
|
||||
"end": 70,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": " "
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 70,
|
||||
"end": 71,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "i"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 71,
|
||||
"end": 72,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "s"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 72,
|
||||
"end": 73,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": " "
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 73,
|
||||
"end": 74,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "a"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 74,
|
||||
"end": 75,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": " "
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 75,
|
||||
"end": 76,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "l"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 76,
|
||||
"end": 77,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "i"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 77,
|
||||
"end": 78,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 78,
|
||||
"end": 79,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "k"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 79,
|
||||
"end": 83,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"EndTag": {
|
||||
"tag_name": "a",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 83,
|
||||
"end": 84,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 84,
|
||||
"end": 85,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 85,
|
||||
"end": 92,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"EndTag": {
|
||||
"tag_name": "body",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 92,
|
||||
"end": 93,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 93,
|
||||
"end": 100,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"EndTag": {
|
||||
"tag_name": "html",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 100,
|
||||
"end": 101,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,191 @@
|
||||
|
||||
x Document
|
||||
,-[$DIR/tests/fixture/attribute-without-quotes/input.html:1:1]
|
||||
1 | ,-> <!DOCTYPE html>
|
||||
2 | | <html>
|
||||
3 | | <body>
|
||||
4 | |
|
||||
5 | | <a href=https://www.w3schools.com>This is a link</a>
|
||||
6 | |
|
||||
7 | | </body>
|
||||
8 | `-> </html>
|
||||
`----
|
||||
|
||||
x Doctype { name: Some(Atom('html' type=inline)), force_quirks: false, public_id: None, system_id: None }
|
||||
,-[$DIR/tests/fixture/attribute-without-quotes/input.html:1:1]
|
||||
1 | <!DOCTYPE html>
|
||||
: ^^^^^^^^^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/attribute-without-quotes/input.html:1:1]
|
||||
1 | <!DOCTYPE html>
|
||||
: ^
|
||||
2 | <html>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('html' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/attribute-without-quotes/input.html:2:1]
|
||||
2 | <html>
|
||||
: ^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/attribute-without-quotes/input.html:2:1]
|
||||
2 | <html>
|
||||
: ^
|
||||
3 | <body>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('body' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/attribute-without-quotes/input.html:3:1]
|
||||
3 | <body>
|
||||
: ^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/attribute-without-quotes/input.html:3:1]
|
||||
3 | <body>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/attribute-without-quotes/input.html:4:1]
|
||||
4 |
|
||||
: ^
|
||||
5 | <a href=https://www.w3schools.com>This is a link</a>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('a' type=inline), self_closing: false, attributes: [Attribute { name: Atom('href' type=inline), value: Atom('https://www.w3schools.com' type=dynamic) }] }
|
||||
,-[$DIR/tests/fixture/attribute-without-quotes/input.html:5:1]
|
||||
5 | <a href=https://www.w3schools.com>This is a link</a>
|
||||
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: 'T' }
|
||||
,-[$DIR/tests/fixture/attribute-without-quotes/input.html:5:1]
|
||||
5 | <a href=https://www.w3schools.com>This is a link</a>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'h' }
|
||||
,-[$DIR/tests/fixture/attribute-without-quotes/input.html:5:1]
|
||||
5 | <a href=https://www.w3schools.com>This is a link</a>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/attribute-without-quotes/input.html:5:1]
|
||||
5 | <a href=https://www.w3schools.com>This is a link</a>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 's' }
|
||||
,-[$DIR/tests/fixture/attribute-without-quotes/input.html:5:1]
|
||||
5 | <a href=https://www.w3schools.com>This is a link</a>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/attribute-without-quotes/input.html:5:1]
|
||||
5 | <a href=https://www.w3schools.com>This is a link</a>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/attribute-without-quotes/input.html:5:1]
|
||||
5 | <a href=https://www.w3schools.com>This is a link</a>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 's' }
|
||||
,-[$DIR/tests/fixture/attribute-without-quotes/input.html:5:1]
|
||||
5 | <a href=https://www.w3schools.com>This is a link</a>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/attribute-without-quotes/input.html:5:1]
|
||||
5 | <a href=https://www.w3schools.com>This is a link</a>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'a' }
|
||||
,-[$DIR/tests/fixture/attribute-without-quotes/input.html:5:1]
|
||||
5 | <a href=https://www.w3schools.com>This is a link</a>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/attribute-without-quotes/input.html:5:1]
|
||||
5 | <a href=https://www.w3schools.com>This is a link</a>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'l' }
|
||||
,-[$DIR/tests/fixture/attribute-without-quotes/input.html:5:1]
|
||||
5 | <a href=https://www.w3schools.com>This is a link</a>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/attribute-without-quotes/input.html:5:1]
|
||||
5 | <a href=https://www.w3schools.com>This is a link</a>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'n' }
|
||||
,-[$DIR/tests/fixture/attribute-without-quotes/input.html:5:1]
|
||||
5 | <a href=https://www.w3schools.com>This is a link</a>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'k' }
|
||||
,-[$DIR/tests/fixture/attribute-without-quotes/input.html:5:1]
|
||||
5 | <a href=https://www.w3schools.com>This is a link</a>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('a' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/attribute-without-quotes/input.html:5:1]
|
||||
5 | <a href=https://www.w3schools.com>This is a link</a>
|
||||
: ^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/attribute-without-quotes/input.html:5:1]
|
||||
5 | <a href=https://www.w3schools.com>This is a link</a>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/attribute-without-quotes/input.html:6:1]
|
||||
6 |
|
||||
: ^
|
||||
7 | </body>
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('body' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/attribute-without-quotes/input.html:7:1]
|
||||
7 | </body>
|
||||
: ^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/attribute-without-quotes/input.html:7:1]
|
||||
7 | </body>
|
||||
: ^
|
||||
8 | </html>
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('html' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/attribute-without-quotes/input.html:8:1]
|
||||
8 | </html>
|
||||
: ^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/attribute-without-quotes/input.html:8:1]
|
||||
8 | </html>
|
||||
: ^
|
||||
`----
|
@ -0,0 +1,11 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Title of the document</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
The content of the document......
|
||||
</body>
|
||||
|
||||
</html>
|
1043
crates/swc_html_parser/tests/fixture/doctype-lowercase/output.json
Normal file
1043
crates/swc_html_parser/tests/fixture/doctype-lowercase/output.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,491 @@
|
||||
|
||||
x Document
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:1:1]
|
||||
1 | ,-> <!doctype html>
|
||||
2 | | <html>
|
||||
3 | | <head>
|
||||
4 | | <title>Title of the document</title>
|
||||
5 | | </head>
|
||||
6 | |
|
||||
7 | | <body>
|
||||
8 | | The content of the document......
|
||||
9 | | </body>
|
||||
10 | |
|
||||
11 | `-> </html>
|
||||
`----
|
||||
|
||||
x Doctype { name: Some(Atom('html' type=inline)), force_quirks: false, public_id: None, system_id: None }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:1:1]
|
||||
1 | <!doctype html>
|
||||
: ^^^^^^^^^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:1:1]
|
||||
1 | <!doctype html>
|
||||
: ^
|
||||
2 | <html>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('html' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:2:1]
|
||||
2 | <html>
|
||||
: ^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:2:1]
|
||||
2 | <html>
|
||||
: ^
|
||||
3 | <head>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('head' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:3:1]
|
||||
3 | <head>
|
||||
: ^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:3:1]
|
||||
3 | <head>
|
||||
: ^
|
||||
4 | <title>Title of the document</title>
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:4:1]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:4:2]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:4:3]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:4:4]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('title' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: 'T' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 't' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'l' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'e' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'o' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'f' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 't' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'h' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'e' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'd' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'o' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'c' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'u' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'm' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'e' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'n' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 't' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('title' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
5 | </head>
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('head' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:5:1]
|
||||
5 | </head>
|
||||
: ^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:5:1]
|
||||
5 | </head>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:6:1]
|
||||
6 |
|
||||
: ^
|
||||
7 | <body>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('body' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:7:1]
|
||||
7 | <body>
|
||||
: ^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:7:1]
|
||||
7 | <body>
|
||||
: ^
|
||||
8 | The content of the document......
|
||||
`----
|
||||
|
||||
x Character { value: 'T' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'h' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'e' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'c' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'o' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'n' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 't' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'e' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'n' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 't' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'o' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'f' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 't' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'h' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'e' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'd' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'o' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'c' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'u' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'm' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'e' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'n' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 't' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '.' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '.' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '.' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '.' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '.' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '.' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
9 | </body>
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('body' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:9:1]
|
||||
9 | </body>
|
||||
: ^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:9:1]
|
||||
9 | </body>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:10:1]
|
||||
10 |
|
||||
: ^
|
||||
11 | </html>
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('html' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:11:1]
|
||||
11 | </html>
|
||||
: ^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/doctype-lowercase/input.html:11:1]
|
||||
11 | </html>
|
||||
: ^
|
||||
`----
|
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Title of the document</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
The content of the document......
|
||||
</body>
|
||||
|
||||
</html>
|
1043
crates/swc_html_parser/tests/fixture/doctype-uppercase/output.json
Normal file
1043
crates/swc_html_parser/tests/fixture/doctype-uppercase/output.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,491 @@
|
||||
|
||||
x Document
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:1:1]
|
||||
1 | ,-> <!DOCTYPE html>
|
||||
2 | | <html>
|
||||
3 | | <head>
|
||||
4 | | <title>Title of the document</title>
|
||||
5 | | </head>
|
||||
6 | |
|
||||
7 | | <body>
|
||||
8 | | The content of the document......
|
||||
9 | | </body>
|
||||
10 | |
|
||||
11 | `-> </html>
|
||||
`----
|
||||
|
||||
x Doctype { name: Some(Atom('html' type=inline)), force_quirks: false, public_id: None, system_id: None }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:1:1]
|
||||
1 | <!DOCTYPE html>
|
||||
: ^^^^^^^^^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:1:1]
|
||||
1 | <!DOCTYPE html>
|
||||
: ^
|
||||
2 | <html>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('html' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:2:1]
|
||||
2 | <html>
|
||||
: ^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:2:1]
|
||||
2 | <html>
|
||||
: ^
|
||||
3 | <head>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('head' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:3:1]
|
||||
3 | <head>
|
||||
: ^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:3:1]
|
||||
3 | <head>
|
||||
: ^
|
||||
4 | <title>Title of the document</title>
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:4:1]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:4:2]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:4:3]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:4:4]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('title' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: 'T' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 't' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'l' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'e' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'o' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'f' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 't' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'h' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'e' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'd' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'o' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'c' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'u' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'm' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'e' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'n' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 't' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('title' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:4:5]
|
||||
4 | <title>Title of the document</title>
|
||||
: ^
|
||||
5 | </head>
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('head' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:5:1]
|
||||
5 | </head>
|
||||
: ^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:5:1]
|
||||
5 | </head>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:6:1]
|
||||
6 |
|
||||
: ^
|
||||
7 | <body>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('body' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:7:1]
|
||||
7 | <body>
|
||||
: ^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:7:1]
|
||||
7 | <body>
|
||||
: ^
|
||||
8 | The content of the document......
|
||||
`----
|
||||
|
||||
x Character { value: 'T' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'h' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'e' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'c' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'o' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'n' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 't' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'e' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'n' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 't' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'o' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'f' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 't' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'h' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'e' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'd' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'o' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'c' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'u' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'm' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'e' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'n' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 't' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '.' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '.' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '.' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '.' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '.' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '.' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:8:1]
|
||||
8 | The content of the document......
|
||||
: ^
|
||||
9 | </body>
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('body' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:9:1]
|
||||
9 | </body>
|
||||
: ^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:9:1]
|
||||
9 | </body>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:10:1]
|
||||
10 |
|
||||
: ^
|
||||
11 | </html>
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('html' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:11:1]
|
||||
11 | </html>
|
||||
: ^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/doctype-uppercase/input.html:11:1]
|
||||
11 | </html>
|
||||
: ^
|
||||
`----
|
10
crates/swc_html_parser/tests/fixture/document/input.html
Normal file
10
crates/swc_html_parser/tests/fixture/document/input.html
Normal file
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h1>My First Heading</h1>
|
||||
|
||||
<p>My first paragraph.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
731
crates/swc_html_parser/tests/fixture/document/output.json
Normal file
731
crates/swc_html_parser/tests/fixture/document/output.json
Normal file
@ -0,0 +1,731 @@
|
||||
{
|
||||
"type": "Document",
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 102,
|
||||
"ctxt": 0
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 15,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Doctype": {
|
||||
"name": "html",
|
||||
"force_quirks": false,
|
||||
"public_id": null,
|
||||
"system_id": null
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 15,
|
||||
"end": 16,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 16,
|
||||
"end": 22,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"StartTag": {
|
||||
"tag_name": "html",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 22,
|
||||
"end": 23,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 23,
|
||||
"end": 29,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"StartTag": {
|
||||
"tag_name": "body",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 29,
|
||||
"end": 30,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 30,
|
||||
"end": 31,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 31,
|
||||
"end": 35,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"StartTag": {
|
||||
"tag_name": "h1",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 35,
|
||||
"end": 36,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "M"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 36,
|
||||
"end": 37,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "y"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 37,
|
||||
"end": 38,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": " "
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 38,
|
||||
"end": 39,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "F"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 39,
|
||||
"end": 40,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "i"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 40,
|
||||
"end": 41,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "r"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 41,
|
||||
"end": 42,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "s"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 42,
|
||||
"end": 43,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "t"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 43,
|
||||
"end": 44,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": " "
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 44,
|
||||
"end": 45,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "H"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 45,
|
||||
"end": 46,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "e"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 46,
|
||||
"end": 47,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "a"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 47,
|
||||
"end": 48,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "d"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 48,
|
||||
"end": 49,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "i"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 49,
|
||||
"end": 50,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 50,
|
||||
"end": 51,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "g"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 51,
|
||||
"end": 56,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"EndTag": {
|
||||
"tag_name": "h1",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 56,
|
||||
"end": 57,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 57,
|
||||
"end": 58,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 58,
|
||||
"end": 61,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"StartTag": {
|
||||
"tag_name": "p",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 61,
|
||||
"end": 62,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "M"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 62,
|
||||
"end": 63,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "y"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 63,
|
||||
"end": 64,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": " "
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 64,
|
||||
"end": 65,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "f"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 65,
|
||||
"end": 66,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "i"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 66,
|
||||
"end": 67,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "r"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 67,
|
||||
"end": 68,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "s"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 68,
|
||||
"end": 69,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "t"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 69,
|
||||
"end": 70,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": " "
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 70,
|
||||
"end": 71,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "p"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 71,
|
||||
"end": 72,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "a"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 72,
|
||||
"end": 73,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "r"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 73,
|
||||
"end": 74,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "a"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 74,
|
||||
"end": 75,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "g"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 75,
|
||||
"end": 76,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "r"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 76,
|
||||
"end": 77,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "a"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 77,
|
||||
"end": 78,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "p"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 78,
|
||||
"end": 79,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "h"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 79,
|
||||
"end": 80,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "."
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 80,
|
||||
"end": 84,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"EndTag": {
|
||||
"tag_name": "p",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 84,
|
||||
"end": 85,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 85,
|
||||
"end": 86,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 86,
|
||||
"end": 93,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"EndTag": {
|
||||
"tag_name": "body",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 93,
|
||||
"end": 94,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 94,
|
||||
"end": 101,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"EndTag": {
|
||||
"tag_name": "html",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 101,
|
||||
"end": 102,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
344
crates/swc_html_parser/tests/fixture/document/span.rust-debug
Normal file
344
crates/swc_html_parser/tests/fixture/document/span.rust-debug
Normal file
@ -0,0 +1,344 @@
|
||||
|
||||
x Document
|
||||
,-[$DIR/tests/fixture/document/input.html:1:1]
|
||||
1 | ,-> <!DOCTYPE html>
|
||||
2 | | <html>
|
||||
3 | | <body>
|
||||
4 | |
|
||||
5 | | <h1>My First Heading</h1>
|
||||
6 | |
|
||||
7 | | <p>My first paragraph.</p>
|
||||
8 | |
|
||||
9 | | </body>
|
||||
10 | `-> </html>
|
||||
`----
|
||||
|
||||
x Doctype { name: Some(Atom('html' type=inline)), force_quirks: false, public_id: None, system_id: None }
|
||||
,-[$DIR/tests/fixture/document/input.html:1:1]
|
||||
1 | <!DOCTYPE html>
|
||||
: ^^^^^^^^^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/document/input.html:1:1]
|
||||
1 | <!DOCTYPE html>
|
||||
: ^
|
||||
2 | <html>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('html' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/document/input.html:2:1]
|
||||
2 | <html>
|
||||
: ^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/document/input.html:2:1]
|
||||
2 | <html>
|
||||
: ^
|
||||
3 | <body>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('body' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/document/input.html:3:1]
|
||||
3 | <body>
|
||||
: ^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/document/input.html:3:1]
|
||||
3 | <body>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/document/input.html:4:1]
|
||||
4 |
|
||||
: ^
|
||||
5 | <h1>My First Heading</h1>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('h1' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/document/input.html:5:1]
|
||||
5 | <h1>My First Heading</h1>
|
||||
: ^^^^
|
||||
`----
|
||||
|
||||
x Character { value: 'M' }
|
||||
,-[$DIR/tests/fixture/document/input.html:5:1]
|
||||
5 | <h1>My First Heading</h1>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'y' }
|
||||
,-[$DIR/tests/fixture/document/input.html:5:1]
|
||||
5 | <h1>My First Heading</h1>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/document/input.html:5:1]
|
||||
5 | <h1>My First Heading</h1>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'F' }
|
||||
,-[$DIR/tests/fixture/document/input.html:5:1]
|
||||
5 | <h1>My First Heading</h1>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/document/input.html:5:1]
|
||||
5 | <h1>My First Heading</h1>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'r' }
|
||||
,-[$DIR/tests/fixture/document/input.html:5:1]
|
||||
5 | <h1>My First Heading</h1>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 's' }
|
||||
,-[$DIR/tests/fixture/document/input.html:5:1]
|
||||
5 | <h1>My First Heading</h1>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 't' }
|
||||
,-[$DIR/tests/fixture/document/input.html:5:1]
|
||||
5 | <h1>My First Heading</h1>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/document/input.html:5:1]
|
||||
5 | <h1>My First Heading</h1>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'H' }
|
||||
,-[$DIR/tests/fixture/document/input.html:5:1]
|
||||
5 | <h1>My First Heading</h1>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'e' }
|
||||
,-[$DIR/tests/fixture/document/input.html:5:1]
|
||||
5 | <h1>My First Heading</h1>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'a' }
|
||||
,-[$DIR/tests/fixture/document/input.html:5:1]
|
||||
5 | <h1>My First Heading</h1>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'd' }
|
||||
,-[$DIR/tests/fixture/document/input.html:5:1]
|
||||
5 | <h1>My First Heading</h1>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/document/input.html:5:1]
|
||||
5 | <h1>My First Heading</h1>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'n' }
|
||||
,-[$DIR/tests/fixture/document/input.html:5:1]
|
||||
5 | <h1>My First Heading</h1>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'g' }
|
||||
,-[$DIR/tests/fixture/document/input.html:5:1]
|
||||
5 | <h1>My First Heading</h1>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('h1' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/document/input.html:5:1]
|
||||
5 | <h1>My First Heading</h1>
|
||||
: ^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/document/input.html:5:1]
|
||||
5 | <h1>My First Heading</h1>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/document/input.html:6:1]
|
||||
6 |
|
||||
: ^
|
||||
7 | <p>My first paragraph.</p>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('p' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/document/input.html:7:1]
|
||||
7 | <p>My first paragraph.</p>
|
||||
: ^^^
|
||||
`----
|
||||
|
||||
x Character { value: 'M' }
|
||||
,-[$DIR/tests/fixture/document/input.html:7:1]
|
||||
7 | <p>My first paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'y' }
|
||||
,-[$DIR/tests/fixture/document/input.html:7:1]
|
||||
7 | <p>My first paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/document/input.html:7:1]
|
||||
7 | <p>My first paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'f' }
|
||||
,-[$DIR/tests/fixture/document/input.html:7:1]
|
||||
7 | <p>My first paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/document/input.html:7:1]
|
||||
7 | <p>My first paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'r' }
|
||||
,-[$DIR/tests/fixture/document/input.html:7:1]
|
||||
7 | <p>My first paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 's' }
|
||||
,-[$DIR/tests/fixture/document/input.html:7:1]
|
||||
7 | <p>My first paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 't' }
|
||||
,-[$DIR/tests/fixture/document/input.html:7:1]
|
||||
7 | <p>My first paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/document/input.html:7:1]
|
||||
7 | <p>My first paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'p' }
|
||||
,-[$DIR/tests/fixture/document/input.html:7:1]
|
||||
7 | <p>My first paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'a' }
|
||||
,-[$DIR/tests/fixture/document/input.html:7:1]
|
||||
7 | <p>My first paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'r' }
|
||||
,-[$DIR/tests/fixture/document/input.html:7:1]
|
||||
7 | <p>My first paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'a' }
|
||||
,-[$DIR/tests/fixture/document/input.html:7:1]
|
||||
7 | <p>My first paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'g' }
|
||||
,-[$DIR/tests/fixture/document/input.html:7:1]
|
||||
7 | <p>My first paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'r' }
|
||||
,-[$DIR/tests/fixture/document/input.html:7:1]
|
||||
7 | <p>My first paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'a' }
|
||||
,-[$DIR/tests/fixture/document/input.html:7:1]
|
||||
7 | <p>My first paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'p' }
|
||||
,-[$DIR/tests/fixture/document/input.html:7:1]
|
||||
7 | <p>My first paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'h' }
|
||||
,-[$DIR/tests/fixture/document/input.html:7:1]
|
||||
7 | <p>My first paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '.' }
|
||||
,-[$DIR/tests/fixture/document/input.html:7:1]
|
||||
7 | <p>My first paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('p' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/document/input.html:7:1]
|
||||
7 | <p>My first paragraph.</p>
|
||||
: ^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/document/input.html:7:1]
|
||||
7 | <p>My first paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/document/input.html:8:1]
|
||||
8 |
|
||||
: ^
|
||||
9 | </body>
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('body' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/document/input.html:9:1]
|
||||
9 | </body>
|
||||
: ^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/document/input.html:9:1]
|
||||
9 | </body>
|
||||
: ^
|
||||
10 | </html>
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('html' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/document/input.html:10:1]
|
||||
10 | </html>
|
||||
: ^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/document/input.html:10:1]
|
||||
10 | </html>
|
||||
: ^
|
||||
`----
|
13
crates/swc_html_parser/tests/fixture/headings/input.html
Normal file
13
crates/swc_html_parser/tests/fixture/headings/input.html
Normal file
@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h1>This is heading 1</h1>
|
||||
<h2>This is heading 2</h2>
|
||||
<h3>This is heading 3</h3>
|
||||
<h4>This is heading 4</h4>
|
||||
<h5>This is heading 5</h5>
|
||||
<h6>This is heading 6</h6>
|
||||
|
||||
</body>
|
||||
</html>
|
1761
crates/swc_html_parser/tests/fixture/headings/output.json
Normal file
1761
crates/swc_html_parser/tests/fixture/headings/output.json
Normal file
File diff suppressed because it is too large
Load Diff
819
crates/swc_html_parser/tests/fixture/headings/span.rust-debug
Normal file
819
crates/swc_html_parser/tests/fixture/headings/span.rust-debug
Normal file
@ -0,0 +1,819 @@
|
||||
|
||||
x Document
|
||||
,-[$DIR/tests/fixture/headings/input.html:1:1]
|
||||
1 | ,-> <!DOCTYPE html>
|
||||
2 | | <html>
|
||||
3 | | <body>
|
||||
4 | |
|
||||
5 | | <h1>This is heading 1</h1>
|
||||
6 | | <h2>This is heading 2</h2>
|
||||
7 | | <h3>This is heading 3</h3>
|
||||
8 | | <h4>This is heading 4</h4>
|
||||
9 | | <h5>This is heading 5</h5>
|
||||
10 | | <h6>This is heading 6</h6>
|
||||
11 | |
|
||||
12 | | </body>
|
||||
13 | `-> </html>
|
||||
`----
|
||||
|
||||
x Doctype { name: Some(Atom('html' type=inline)), force_quirks: false, public_id: None, system_id: None }
|
||||
,-[$DIR/tests/fixture/headings/input.html:1:1]
|
||||
1 | <!DOCTYPE html>
|
||||
: ^^^^^^^^^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:1:1]
|
||||
1 | <!DOCTYPE html>
|
||||
: ^
|
||||
2 | <html>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('html' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/headings/input.html:2:1]
|
||||
2 | <html>
|
||||
: ^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:2:1]
|
||||
2 | <html>
|
||||
: ^
|
||||
3 | <body>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('body' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/headings/input.html:3:1]
|
||||
3 | <body>
|
||||
: ^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:3:1]
|
||||
3 | <body>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:4:1]
|
||||
4 |
|
||||
: ^
|
||||
5 | <h1>This is heading 1</h1>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('h1' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/headings/input.html:5:1]
|
||||
5 | <h1>This is heading 1</h1>
|
||||
: ^^^^
|
||||
`----
|
||||
|
||||
x Character { value: 'T' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:5:1]
|
||||
5 | <h1>This is heading 1</h1>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'h' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:5:1]
|
||||
5 | <h1>This is heading 1</h1>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:5:1]
|
||||
5 | <h1>This is heading 1</h1>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 's' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:5:1]
|
||||
5 | <h1>This is heading 1</h1>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:5:1]
|
||||
5 | <h1>This is heading 1</h1>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:5:1]
|
||||
5 | <h1>This is heading 1</h1>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 's' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:5:1]
|
||||
5 | <h1>This is heading 1</h1>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:5:1]
|
||||
5 | <h1>This is heading 1</h1>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'h' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:5:1]
|
||||
5 | <h1>This is heading 1</h1>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'e' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:5:1]
|
||||
5 | <h1>This is heading 1</h1>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'a' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:5:1]
|
||||
5 | <h1>This is heading 1</h1>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'd' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:5:1]
|
||||
5 | <h1>This is heading 1</h1>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:5:1]
|
||||
5 | <h1>This is heading 1</h1>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'n' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:5:1]
|
||||
5 | <h1>This is heading 1</h1>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'g' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:5:1]
|
||||
5 | <h1>This is heading 1</h1>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:5:1]
|
||||
5 | <h1>This is heading 1</h1>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '1' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:5:1]
|
||||
5 | <h1>This is heading 1</h1>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('h1' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/headings/input.html:5:1]
|
||||
5 | <h1>This is heading 1</h1>
|
||||
: ^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:5:1]
|
||||
5 | <h1>This is heading 1</h1>
|
||||
: ^
|
||||
6 | <h2>This is heading 2</h2>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('h2' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/headings/input.html:6:1]
|
||||
6 | <h2>This is heading 2</h2>
|
||||
: ^^^^
|
||||
`----
|
||||
|
||||
x Character { value: 'T' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:6:1]
|
||||
6 | <h2>This is heading 2</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'h' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:6:1]
|
||||
6 | <h2>This is heading 2</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:6:1]
|
||||
6 | <h2>This is heading 2</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 's' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:6:1]
|
||||
6 | <h2>This is heading 2</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:6:1]
|
||||
6 | <h2>This is heading 2</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:6:1]
|
||||
6 | <h2>This is heading 2</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 's' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:6:1]
|
||||
6 | <h2>This is heading 2</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:6:1]
|
||||
6 | <h2>This is heading 2</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'h' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:6:1]
|
||||
6 | <h2>This is heading 2</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'e' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:6:1]
|
||||
6 | <h2>This is heading 2</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'a' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:6:1]
|
||||
6 | <h2>This is heading 2</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'd' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:6:1]
|
||||
6 | <h2>This is heading 2</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:6:1]
|
||||
6 | <h2>This is heading 2</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'n' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:6:1]
|
||||
6 | <h2>This is heading 2</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'g' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:6:1]
|
||||
6 | <h2>This is heading 2</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:6:1]
|
||||
6 | <h2>This is heading 2</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '2' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:6:1]
|
||||
6 | <h2>This is heading 2</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('h2' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/headings/input.html:6:1]
|
||||
6 | <h2>This is heading 2</h2>
|
||||
: ^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:6:1]
|
||||
6 | <h2>This is heading 2</h2>
|
||||
: ^
|
||||
7 | <h3>This is heading 3</h3>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('h3' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/headings/input.html:7:1]
|
||||
7 | <h3>This is heading 3</h3>
|
||||
: ^^^^
|
||||
`----
|
||||
|
||||
x Character { value: 'T' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:7:1]
|
||||
7 | <h3>This is heading 3</h3>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'h' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:7:1]
|
||||
7 | <h3>This is heading 3</h3>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:7:1]
|
||||
7 | <h3>This is heading 3</h3>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 's' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:7:1]
|
||||
7 | <h3>This is heading 3</h3>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:7:1]
|
||||
7 | <h3>This is heading 3</h3>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:7:1]
|
||||
7 | <h3>This is heading 3</h3>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 's' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:7:1]
|
||||
7 | <h3>This is heading 3</h3>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:7:1]
|
||||
7 | <h3>This is heading 3</h3>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'h' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:7:1]
|
||||
7 | <h3>This is heading 3</h3>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'e' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:7:1]
|
||||
7 | <h3>This is heading 3</h3>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'a' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:7:1]
|
||||
7 | <h3>This is heading 3</h3>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'd' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:7:1]
|
||||
7 | <h3>This is heading 3</h3>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:7:1]
|
||||
7 | <h3>This is heading 3</h3>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'n' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:7:1]
|
||||
7 | <h3>This is heading 3</h3>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'g' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:7:1]
|
||||
7 | <h3>This is heading 3</h3>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:7:1]
|
||||
7 | <h3>This is heading 3</h3>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '3' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:7:1]
|
||||
7 | <h3>This is heading 3</h3>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('h3' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/headings/input.html:7:1]
|
||||
7 | <h3>This is heading 3</h3>
|
||||
: ^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:7:1]
|
||||
7 | <h3>This is heading 3</h3>
|
||||
: ^
|
||||
8 | <h4>This is heading 4</h4>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('h4' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/headings/input.html:8:1]
|
||||
8 | <h4>This is heading 4</h4>
|
||||
: ^^^^
|
||||
`----
|
||||
|
||||
x Character { value: 'T' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:8:1]
|
||||
8 | <h4>This is heading 4</h4>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'h' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:8:1]
|
||||
8 | <h4>This is heading 4</h4>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:8:1]
|
||||
8 | <h4>This is heading 4</h4>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 's' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:8:1]
|
||||
8 | <h4>This is heading 4</h4>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:8:1]
|
||||
8 | <h4>This is heading 4</h4>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:8:1]
|
||||
8 | <h4>This is heading 4</h4>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 's' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:8:1]
|
||||
8 | <h4>This is heading 4</h4>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:8:1]
|
||||
8 | <h4>This is heading 4</h4>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'h' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:8:1]
|
||||
8 | <h4>This is heading 4</h4>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'e' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:8:1]
|
||||
8 | <h4>This is heading 4</h4>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'a' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:8:1]
|
||||
8 | <h4>This is heading 4</h4>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'd' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:8:1]
|
||||
8 | <h4>This is heading 4</h4>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:8:1]
|
||||
8 | <h4>This is heading 4</h4>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'n' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:8:1]
|
||||
8 | <h4>This is heading 4</h4>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'g' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:8:1]
|
||||
8 | <h4>This is heading 4</h4>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:8:1]
|
||||
8 | <h4>This is heading 4</h4>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '4' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:8:1]
|
||||
8 | <h4>This is heading 4</h4>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('h4' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/headings/input.html:8:1]
|
||||
8 | <h4>This is heading 4</h4>
|
||||
: ^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:8:1]
|
||||
8 | <h4>This is heading 4</h4>
|
||||
: ^
|
||||
9 | <h5>This is heading 5</h5>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('h5' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/headings/input.html:9:1]
|
||||
9 | <h5>This is heading 5</h5>
|
||||
: ^^^^
|
||||
`----
|
||||
|
||||
x Character { value: 'T' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:9:1]
|
||||
9 | <h5>This is heading 5</h5>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'h' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:9:1]
|
||||
9 | <h5>This is heading 5</h5>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:9:1]
|
||||
9 | <h5>This is heading 5</h5>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 's' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:9:1]
|
||||
9 | <h5>This is heading 5</h5>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:9:1]
|
||||
9 | <h5>This is heading 5</h5>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:9:1]
|
||||
9 | <h5>This is heading 5</h5>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 's' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:9:1]
|
||||
9 | <h5>This is heading 5</h5>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:9:1]
|
||||
9 | <h5>This is heading 5</h5>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'h' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:9:1]
|
||||
9 | <h5>This is heading 5</h5>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'e' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:9:1]
|
||||
9 | <h5>This is heading 5</h5>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'a' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:9:1]
|
||||
9 | <h5>This is heading 5</h5>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'd' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:9:1]
|
||||
9 | <h5>This is heading 5</h5>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:9:1]
|
||||
9 | <h5>This is heading 5</h5>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'n' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:9:1]
|
||||
9 | <h5>This is heading 5</h5>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'g' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:9:1]
|
||||
9 | <h5>This is heading 5</h5>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:9:1]
|
||||
9 | <h5>This is heading 5</h5>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '5' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:9:1]
|
||||
9 | <h5>This is heading 5</h5>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('h5' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/headings/input.html:9:1]
|
||||
9 | <h5>This is heading 5</h5>
|
||||
: ^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:9:1]
|
||||
9 | <h5>This is heading 5</h5>
|
||||
: ^
|
||||
10 | <h6>This is heading 6</h6>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('h6' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/headings/input.html:10:1]
|
||||
10 | <h6>This is heading 6</h6>
|
||||
: ^^^^
|
||||
`----
|
||||
|
||||
x Character { value: 'T' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:10:1]
|
||||
10 | <h6>This is heading 6</h6>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'h' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:10:1]
|
||||
10 | <h6>This is heading 6</h6>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:10:1]
|
||||
10 | <h6>This is heading 6</h6>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 's' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:10:1]
|
||||
10 | <h6>This is heading 6</h6>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:10:1]
|
||||
10 | <h6>This is heading 6</h6>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:10:1]
|
||||
10 | <h6>This is heading 6</h6>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 's' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:10:1]
|
||||
10 | <h6>This is heading 6</h6>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:10:1]
|
||||
10 | <h6>This is heading 6</h6>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'h' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:10:1]
|
||||
10 | <h6>This is heading 6</h6>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'e' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:10:1]
|
||||
10 | <h6>This is heading 6</h6>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'a' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:10:1]
|
||||
10 | <h6>This is heading 6</h6>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'd' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:10:1]
|
||||
10 | <h6>This is heading 6</h6>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:10:1]
|
||||
10 | <h6>This is heading 6</h6>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'n' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:10:1]
|
||||
10 | <h6>This is heading 6</h6>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'g' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:10:1]
|
||||
10 | <h6>This is heading 6</h6>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:10:1]
|
||||
10 | <h6>This is heading 6</h6>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '6' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:10:1]
|
||||
10 | <h6>This is heading 6</h6>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('h6' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/headings/input.html:10:1]
|
||||
10 | <h6>This is heading 6</h6>
|
||||
: ^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:10:1]
|
||||
10 | <h6>This is heading 6</h6>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:11:1]
|
||||
11 |
|
||||
: ^
|
||||
12 | </body>
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('body' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/headings/input.html:12:1]
|
||||
12 | </body>
|
||||
: ^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:12:1]
|
||||
12 | </body>
|
||||
: ^
|
||||
13 | </html>
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('html' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/headings/input.html:13:1]
|
||||
13 | </html>
|
||||
: ^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/headings/input.html:13:1]
|
||||
13 | </html>
|
||||
: ^
|
||||
`----
|
@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<!--This is a comment-->
|
||||
<!-- This is a comment -->
|
||||
<p>This is a paragraph.</p>
|
||||
<!-- Comments are not displayed in the browser -->
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
610
crates/swc_html_parser/tests/fixture/hidden-comments/output.json
Normal file
610
crates/swc_html_parser/tests/fixture/hidden-comments/output.json
Normal file
@ -0,0 +1,610 @@
|
||||
{
|
||||
"type": "Document",
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 183,
|
||||
"ctxt": 0
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 15,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Doctype": {
|
||||
"name": "html",
|
||||
"force_quirks": false,
|
||||
"public_id": null,
|
||||
"system_id": null
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 15,
|
||||
"end": 16,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 16,
|
||||
"end": 22,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"StartTag": {
|
||||
"tag_name": "html",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 22,
|
||||
"end": 23,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 23,
|
||||
"end": 29,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"StartTag": {
|
||||
"tag_name": "body",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 29,
|
||||
"end": 30,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 30,
|
||||
"end": 31,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 31,
|
||||
"end": 55,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Comment": {
|
||||
"data": "This is a comment"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 55,
|
||||
"end": 56,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 56,
|
||||
"end": 82,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Comment": {
|
||||
"data": " This is a comment "
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 82,
|
||||
"end": 83,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 83,
|
||||
"end": 86,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"StartTag": {
|
||||
"tag_name": "p",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 86,
|
||||
"end": 87,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "T"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 87,
|
||||
"end": 88,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "h"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 88,
|
||||
"end": 89,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "i"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 89,
|
||||
"end": 90,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "s"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 90,
|
||||
"end": 91,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": " "
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 91,
|
||||
"end": 92,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "i"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 92,
|
||||
"end": 93,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "s"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 93,
|
||||
"end": 94,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": " "
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 94,
|
||||
"end": 95,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "a"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 95,
|
||||
"end": 96,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": " "
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 96,
|
||||
"end": 97,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "p"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 97,
|
||||
"end": 98,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "a"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 98,
|
||||
"end": 99,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "r"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 99,
|
||||
"end": 100,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "a"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 100,
|
||||
"end": 101,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "g"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 101,
|
||||
"end": 102,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "r"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 102,
|
||||
"end": 103,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "a"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 103,
|
||||
"end": 104,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "p"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 104,
|
||||
"end": 105,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "h"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 105,
|
||||
"end": 106,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "."
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 106,
|
||||
"end": 110,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"EndTag": {
|
||||
"tag_name": "p",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 110,
|
||||
"end": 111,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 111,
|
||||
"end": 161,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Comment": {
|
||||
"data": " Comments are not displayed in the browser "
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 161,
|
||||
"end": 162,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 162,
|
||||
"end": 163,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 163,
|
||||
"end": 170,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"EndTag": {
|
||||
"tag_name": "body",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 170,
|
||||
"end": 171,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 171,
|
||||
"end": 172,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": " "
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 172,
|
||||
"end": 173,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": " "
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 173,
|
||||
"end": 180,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"EndTag": {
|
||||
"tag_name": "html",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 180,
|
||||
"end": 181,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 181,
|
||||
"end": 182,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 182,
|
||||
"end": 183,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,295 @@
|
||||
|
||||
x Document
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:1:1]
|
||||
1 | ,-> <!DOCTYPE html>
|
||||
2 | | <html>
|
||||
3 | | <body>
|
||||
4 | |
|
||||
5 | | <!--This is a comment-->
|
||||
6 | | <!-- This is a comment -->
|
||||
7 | | <p>This is a paragraph.</p>
|
||||
8 | | <!-- Comments are not displayed in the browser -->
|
||||
9 | |
|
||||
10 | | </body>
|
||||
11 | | </html>
|
||||
12 | |
|
||||
13 | `->
|
||||
`----
|
||||
|
||||
x Doctype { name: Some(Atom('html' type=inline)), force_quirks: false, public_id: None, system_id: None }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:1:1]
|
||||
1 | <!DOCTYPE html>
|
||||
: ^^^^^^^^^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:1:1]
|
||||
1 | <!DOCTYPE html>
|
||||
: ^
|
||||
2 | <html>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('html' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:2:1]
|
||||
2 | <html>
|
||||
: ^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:2:1]
|
||||
2 | <html>
|
||||
: ^
|
||||
3 | <body>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('body' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:3:1]
|
||||
3 | <body>
|
||||
: ^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:3:1]
|
||||
3 | <body>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:4:1]
|
||||
4 |
|
||||
: ^
|
||||
5 | <!--This is a comment-->
|
||||
`----
|
||||
|
||||
x Comment { data: Atom('This is a comment' type=dynamic) }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:5:1]
|
||||
5 | <!--This is a comment-->
|
||||
: ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:5:1]
|
||||
5 | <!--This is a comment-->
|
||||
: ^
|
||||
6 | <!-- This is a comment -->
|
||||
`----
|
||||
|
||||
x Comment { data: Atom(' This is a comment ' type=dynamic) }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:6:1]
|
||||
6 | <!-- This is a comment -->
|
||||
: ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:6:1]
|
||||
6 | <!-- This is a comment -->
|
||||
: ^
|
||||
7 | <p>This is a paragraph.</p>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('p' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:7:1]
|
||||
7 | <p>This is a paragraph.</p>
|
||||
: ^^^
|
||||
`----
|
||||
|
||||
x Character { value: 'T' }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:7:1]
|
||||
7 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'h' }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:7:1]
|
||||
7 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:7:1]
|
||||
7 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 's' }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:7:1]
|
||||
7 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:7:1]
|
||||
7 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:7:1]
|
||||
7 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 's' }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:7:1]
|
||||
7 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:7:1]
|
||||
7 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'a' }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:7:1]
|
||||
7 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:7:1]
|
||||
7 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'p' }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:7:1]
|
||||
7 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'a' }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:7:1]
|
||||
7 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'r' }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:7:1]
|
||||
7 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'a' }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:7:1]
|
||||
7 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'g' }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:7:1]
|
||||
7 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'r' }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:7:1]
|
||||
7 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'a' }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:7:1]
|
||||
7 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'p' }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:7:1]
|
||||
7 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'h' }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:7:1]
|
||||
7 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '.' }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:7:1]
|
||||
7 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('p' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:7:1]
|
||||
7 | <p>This is a paragraph.</p>
|
||||
: ^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:7:1]
|
||||
7 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
8 | <!-- Comments are not displayed in the browser -->
|
||||
`----
|
||||
|
||||
x Comment { data: Atom(' Comments are not displayed in the browser ' type=dynamic) }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:8:1]
|
||||
8 | <!-- Comments are not displayed in the browser -->
|
||||
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:8:1]
|
||||
8 | <!-- Comments are not displayed in the browser -->
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:9:1]
|
||||
9 |
|
||||
: ^
|
||||
10 | </body>
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('body' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:10:1]
|
||||
10 | </body>
|
||||
: ^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:10:1]
|
||||
10 | </body>
|
||||
: ^
|
||||
11 | </html>
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:11:1]
|
||||
11 | </html>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:11:2]
|
||||
11 | </html>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('html' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:11:3]
|
||||
11 | </html>
|
||||
: ^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:11:3]
|
||||
11 | </html>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:12:1]
|
||||
12 |
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/hidden-comments/input.html:13:1]
|
||||
13 |
|
||||
: ^
|
||||
`----
|
@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<!--[if IE 5]>This is IE 5<br><![endif]-->
|
||||
<!--[if IE 6]>This is IE 6<br><![endif]-->
|
||||
<!--[if IE 7]>This is IE 7<br><![endif]-->
|
||||
<!--[if IE 8]>This is IE 8<br><![endif]-->
|
||||
<!--[if IE 9]>This is IE 9<br><![endif]-->
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,307 @@
|
||||
{
|
||||
"type": "Document",
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 263,
|
||||
"ctxt": 0
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 15,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Doctype": {
|
||||
"name": "html",
|
||||
"force_quirks": false,
|
||||
"public_id": null,
|
||||
"system_id": null
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 15,
|
||||
"end": 16,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 16,
|
||||
"end": 22,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"StartTag": {
|
||||
"tag_name": "html",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 22,
|
||||
"end": 23,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 23,
|
||||
"end": 29,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"StartTag": {
|
||||
"tag_name": "body",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 29,
|
||||
"end": 30,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 30,
|
||||
"end": 31,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 31,
|
||||
"end": 73,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Comment": {
|
||||
"data": "[if IE 5]>This is IE 5<br><![endif]"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 73,
|
||||
"end": 74,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 74,
|
||||
"end": 116,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Comment": {
|
||||
"data": "[if IE 6]>This is IE 6<br><![endif]"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 116,
|
||||
"end": 117,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 117,
|
||||
"end": 159,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Comment": {
|
||||
"data": "[if IE 7]>This is IE 7<br><![endif]"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 159,
|
||||
"end": 160,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 160,
|
||||
"end": 202,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Comment": {
|
||||
"data": "[if IE 8]>This is IE 8<br><![endif]"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 202,
|
||||
"end": 203,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 203,
|
||||
"end": 245,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Comment": {
|
||||
"data": "[if IE 9]>This is IE 9<br><![endif]"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 245,
|
||||
"end": 246,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 246,
|
||||
"end": 247,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 247,
|
||||
"end": 254,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"EndTag": {
|
||||
"tag_name": "body",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 254,
|
||||
"end": 255,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 255,
|
||||
"end": 262,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"EndTag": {
|
||||
"tag_name": "html",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 262,
|
||||
"end": 263,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,157 @@
|
||||
|
||||
x Document
|
||||
,-[$DIR/tests/fixture/ie-conditional-comments/input.html:1:1]
|
||||
1 | ,-> <!DOCTYPE html>
|
||||
2 | | <html>
|
||||
3 | | <body>
|
||||
4 | |
|
||||
5 | | <!--[if IE 5]>This is IE 5<br><![endif]-->
|
||||
6 | | <!--[if IE 6]>This is IE 6<br><![endif]-->
|
||||
7 | | <!--[if IE 7]>This is IE 7<br><![endif]-->
|
||||
8 | | <!--[if IE 8]>This is IE 8<br><![endif]-->
|
||||
9 | | <!--[if IE 9]>This is IE 9<br><![endif]-->
|
||||
10 | |
|
||||
11 | | </body>
|
||||
12 | `-> </html>
|
||||
`----
|
||||
|
||||
x Doctype { name: Some(Atom('html' type=inline)), force_quirks: false, public_id: None, system_id: None }
|
||||
,-[$DIR/tests/fixture/ie-conditional-comments/input.html:1:1]
|
||||
1 | <!DOCTYPE html>
|
||||
: ^^^^^^^^^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/ie-conditional-comments/input.html:1:1]
|
||||
1 | <!DOCTYPE html>
|
||||
: ^
|
||||
2 | <html>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('html' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/ie-conditional-comments/input.html:2:1]
|
||||
2 | <html>
|
||||
: ^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/ie-conditional-comments/input.html:2:1]
|
||||
2 | <html>
|
||||
: ^
|
||||
3 | <body>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('body' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/ie-conditional-comments/input.html:3:1]
|
||||
3 | <body>
|
||||
: ^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/ie-conditional-comments/input.html:3:1]
|
||||
3 | <body>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/ie-conditional-comments/input.html:4:1]
|
||||
4 |
|
||||
: ^
|
||||
5 | <!--[if IE 5]>This is IE 5<br><![endif]-->
|
||||
`----
|
||||
|
||||
x Comment { data: Atom('[if IE 5]>This is IE 5<br><![endif]' type=dynamic) }
|
||||
,-[$DIR/tests/fixture/ie-conditional-comments/input.html:5:1]
|
||||
5 | <!--[if IE 5]>This is IE 5<br><![endif]-->
|
||||
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/ie-conditional-comments/input.html:5:1]
|
||||
5 | <!--[if IE 5]>This is IE 5<br><![endif]-->
|
||||
: ^
|
||||
6 | <!--[if IE 6]>This is IE 6<br><![endif]-->
|
||||
`----
|
||||
|
||||
x Comment { data: Atom('[if IE 6]>This is IE 6<br><![endif]' type=dynamic) }
|
||||
,-[$DIR/tests/fixture/ie-conditional-comments/input.html:6:1]
|
||||
6 | <!--[if IE 6]>This is IE 6<br><![endif]-->
|
||||
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/ie-conditional-comments/input.html:6:1]
|
||||
6 | <!--[if IE 6]>This is IE 6<br><![endif]-->
|
||||
: ^
|
||||
7 | <!--[if IE 7]>This is IE 7<br><![endif]-->
|
||||
`----
|
||||
|
||||
x Comment { data: Atom('[if IE 7]>This is IE 7<br><![endif]' type=dynamic) }
|
||||
,-[$DIR/tests/fixture/ie-conditional-comments/input.html:7:1]
|
||||
7 | <!--[if IE 7]>This is IE 7<br><![endif]-->
|
||||
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/ie-conditional-comments/input.html:7:1]
|
||||
7 | <!--[if IE 7]>This is IE 7<br><![endif]-->
|
||||
: ^
|
||||
8 | <!--[if IE 8]>This is IE 8<br><![endif]-->
|
||||
`----
|
||||
|
||||
x Comment { data: Atom('[if IE 8]>This is IE 8<br><![endif]' type=dynamic) }
|
||||
,-[$DIR/tests/fixture/ie-conditional-comments/input.html:8:1]
|
||||
8 | <!--[if IE 8]>This is IE 8<br><![endif]-->
|
||||
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/ie-conditional-comments/input.html:8:1]
|
||||
8 | <!--[if IE 8]>This is IE 8<br><![endif]-->
|
||||
: ^
|
||||
9 | <!--[if IE 9]>This is IE 9<br><![endif]-->
|
||||
`----
|
||||
|
||||
x Comment { data: Atom('[if IE 9]>This is IE 9<br><![endif]' type=dynamic) }
|
||||
,-[$DIR/tests/fixture/ie-conditional-comments/input.html:9:1]
|
||||
9 | <!--[if IE 9]>This is IE 9<br><![endif]-->
|
||||
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/ie-conditional-comments/input.html:9:1]
|
||||
9 | <!--[if IE 9]>This is IE 9<br><![endif]-->
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/ie-conditional-comments/input.html:10:1]
|
||||
10 |
|
||||
: ^
|
||||
11 | </body>
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('body' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/ie-conditional-comments/input.html:11:1]
|
||||
11 | </body>
|
||||
: ^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/ie-conditional-comments/input.html:11:1]
|
||||
11 | </body>
|
||||
: ^
|
||||
12 | </html>
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('html' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/ie-conditional-comments/input.html:12:1]
|
||||
12 | </html>
|
||||
: ^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/ie-conditional-comments/input.html:12:1]
|
||||
12 | </html>
|
||||
: ^
|
||||
`----
|
11
crates/swc_html_parser/tests/fixture/images/input.html
Normal file
11
crates/swc_html_parser/tests/fixture/images/input.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h2>HTML Images</h2>
|
||||
<p>HTML images are defined with the img tag:</p>
|
||||
|
||||
<img src="w3schools.jpg" alt="W3Schools.com" width="104" height="142">
|
||||
|
||||
</body>
|
||||
</html>
|
997
crates/swc_html_parser/tests/fixture/images/output.json
Normal file
997
crates/swc_html_parser/tests/fixture/images/output.json
Normal file
@ -0,0 +1,997 @@
|
||||
{
|
||||
"type": "Document",
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 190,
|
||||
"ctxt": 0
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 15,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Doctype": {
|
||||
"name": "html",
|
||||
"force_quirks": false,
|
||||
"public_id": null,
|
||||
"system_id": null
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 15,
|
||||
"end": 16,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 16,
|
||||
"end": 22,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"StartTag": {
|
||||
"tag_name": "html",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 22,
|
||||
"end": 23,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 23,
|
||||
"end": 29,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"StartTag": {
|
||||
"tag_name": "body",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 29,
|
||||
"end": 30,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 30,
|
||||
"end": 31,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 31,
|
||||
"end": 35,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"StartTag": {
|
||||
"tag_name": "h2",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 35,
|
||||
"end": 36,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "H"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 36,
|
||||
"end": 37,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "T"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 37,
|
||||
"end": 38,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "M"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 38,
|
||||
"end": 39,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "L"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 39,
|
||||
"end": 40,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": " "
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 40,
|
||||
"end": 41,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "I"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 41,
|
||||
"end": 42,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "m"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 42,
|
||||
"end": 43,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "a"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 43,
|
||||
"end": 44,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "g"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 44,
|
||||
"end": 45,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "e"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 45,
|
||||
"end": 46,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "s"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 46,
|
||||
"end": 51,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"EndTag": {
|
||||
"tag_name": "h2",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 51,
|
||||
"end": 52,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 52,
|
||||
"end": 55,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"StartTag": {
|
||||
"tag_name": "p",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 55,
|
||||
"end": 56,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "H"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 56,
|
||||
"end": 57,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "T"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 57,
|
||||
"end": 58,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "M"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 58,
|
||||
"end": 59,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "L"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 59,
|
||||
"end": 60,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": " "
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 60,
|
||||
"end": 61,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "i"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 61,
|
||||
"end": 62,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "m"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 62,
|
||||
"end": 63,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "a"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 63,
|
||||
"end": 64,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "g"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 64,
|
||||
"end": 65,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "e"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 65,
|
||||
"end": 66,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "s"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 66,
|
||||
"end": 67,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": " "
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 67,
|
||||
"end": 68,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "a"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 68,
|
||||
"end": 69,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "r"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 69,
|
||||
"end": 70,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "e"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 70,
|
||||
"end": 71,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": " "
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 71,
|
||||
"end": 72,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "d"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 72,
|
||||
"end": 73,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "e"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 73,
|
||||
"end": 74,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "f"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 74,
|
||||
"end": 75,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "i"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 75,
|
||||
"end": 76,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 76,
|
||||
"end": 77,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "e"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 77,
|
||||
"end": 78,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "d"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 78,
|
||||
"end": 79,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": " "
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 79,
|
||||
"end": 80,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "w"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 80,
|
||||
"end": 81,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "i"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 81,
|
||||
"end": 82,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "t"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 82,
|
||||
"end": 83,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "h"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 83,
|
||||
"end": 84,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": " "
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 84,
|
||||
"end": 85,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "t"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 85,
|
||||
"end": 86,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "h"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 86,
|
||||
"end": 87,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "e"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 87,
|
||||
"end": 88,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": " "
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 88,
|
||||
"end": 89,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "i"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 89,
|
||||
"end": 90,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "m"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 90,
|
||||
"end": 91,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "g"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 91,
|
||||
"end": 92,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": " "
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 92,
|
||||
"end": 93,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "t"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 93,
|
||||
"end": 94,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "a"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 94,
|
||||
"end": 95,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "g"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 95,
|
||||
"end": 96,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": ":"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 96,
|
||||
"end": 100,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"EndTag": {
|
||||
"tag_name": "p",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 100,
|
||||
"end": 101,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 101,
|
||||
"end": 102,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 102,
|
||||
"end": 172,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"StartTag": {
|
||||
"tag_name": "img",
|
||||
"self_closing": false,
|
||||
"attributes": [
|
||||
{
|
||||
"name": "src",
|
||||
"value": "w3schools.jpg"
|
||||
},
|
||||
{
|
||||
"name": "alt",
|
||||
"value": "W3Schools.com"
|
||||
},
|
||||
{
|
||||
"name": "width",
|
||||
"value": "104"
|
||||
},
|
||||
{
|
||||
"name": "height",
|
||||
"value": "142"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 172,
|
||||
"end": 173,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 173,
|
||||
"end": 174,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 174,
|
||||
"end": 181,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"EndTag": {
|
||||
"tag_name": "body",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 181,
|
||||
"end": 182,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 182,
|
||||
"end": 189,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"EndTag": {
|
||||
"tag_name": "html",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 189,
|
||||
"end": 190,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
462
crates/swc_html_parser/tests/fixture/images/span.rust-debug
Normal file
462
crates/swc_html_parser/tests/fixture/images/span.rust-debug
Normal file
@ -0,0 +1,462 @@
|
||||
|
||||
x Document
|
||||
,-[$DIR/tests/fixture/images/input.html:1:1]
|
||||
1 | ,-> <!DOCTYPE html>
|
||||
2 | | <html>
|
||||
3 | | <body>
|
||||
4 | |
|
||||
5 | | <h2>HTML Images</h2>
|
||||
6 | | <p>HTML images are defined with the img tag:</p>
|
||||
7 | |
|
||||
8 | | <img src="w3schools.jpg" alt="W3Schools.com" width="104" height="142">
|
||||
9 | |
|
||||
10 | | </body>
|
||||
11 | `-> </html>
|
||||
`----
|
||||
|
||||
x Doctype { name: Some(Atom('html' type=inline)), force_quirks: false, public_id: None, system_id: None }
|
||||
,-[$DIR/tests/fixture/images/input.html:1:1]
|
||||
1 | <!DOCTYPE html>
|
||||
: ^^^^^^^^^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/images/input.html:1:1]
|
||||
1 | <!DOCTYPE html>
|
||||
: ^
|
||||
2 | <html>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('html' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/images/input.html:2:1]
|
||||
2 | <html>
|
||||
: ^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/images/input.html:2:1]
|
||||
2 | <html>
|
||||
: ^
|
||||
3 | <body>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('body' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/images/input.html:3:1]
|
||||
3 | <body>
|
||||
: ^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/images/input.html:3:1]
|
||||
3 | <body>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/images/input.html:4:1]
|
||||
4 |
|
||||
: ^
|
||||
5 | <h2>HTML Images</h2>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('h2' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/images/input.html:5:1]
|
||||
5 | <h2>HTML Images</h2>
|
||||
: ^^^^
|
||||
`----
|
||||
|
||||
x Character { value: 'H' }
|
||||
,-[$DIR/tests/fixture/images/input.html:5:1]
|
||||
5 | <h2>HTML Images</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'T' }
|
||||
,-[$DIR/tests/fixture/images/input.html:5:1]
|
||||
5 | <h2>HTML Images</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'M' }
|
||||
,-[$DIR/tests/fixture/images/input.html:5:1]
|
||||
5 | <h2>HTML Images</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'L' }
|
||||
,-[$DIR/tests/fixture/images/input.html:5:1]
|
||||
5 | <h2>HTML Images</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/images/input.html:5:1]
|
||||
5 | <h2>HTML Images</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'I' }
|
||||
,-[$DIR/tests/fixture/images/input.html:5:1]
|
||||
5 | <h2>HTML Images</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'm' }
|
||||
,-[$DIR/tests/fixture/images/input.html:5:1]
|
||||
5 | <h2>HTML Images</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'a' }
|
||||
,-[$DIR/tests/fixture/images/input.html:5:1]
|
||||
5 | <h2>HTML Images</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'g' }
|
||||
,-[$DIR/tests/fixture/images/input.html:5:1]
|
||||
5 | <h2>HTML Images</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'e' }
|
||||
,-[$DIR/tests/fixture/images/input.html:5:1]
|
||||
5 | <h2>HTML Images</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 's' }
|
||||
,-[$DIR/tests/fixture/images/input.html:5:1]
|
||||
5 | <h2>HTML Images</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('h2' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/images/input.html:5:1]
|
||||
5 | <h2>HTML Images</h2>
|
||||
: ^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/images/input.html:5:1]
|
||||
5 | <h2>HTML Images</h2>
|
||||
: ^
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('p' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^^^
|
||||
`----
|
||||
|
||||
x Character { value: 'H' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'T' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'M' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'L' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'm' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'a' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'g' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'e' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 's' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'a' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'r' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'e' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'd' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'e' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'f' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'n' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'e' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'd' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'w' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 't' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'h' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 't' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'h' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'e' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'm' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'g' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 't' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'a' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'g' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ':' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('p' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/images/input.html:6:1]
|
||||
6 | <p>HTML images are defined with the img tag:</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/images/input.html:7:1]
|
||||
7 |
|
||||
: ^
|
||||
8 | <img src="w3schools.jpg" alt="W3Schools.com" width="104" height="142">
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('img' type=inline), self_closing: false, attributes: [Attribute { name: Atom('src' type=inline), value: Atom('w3schools.jpg' type=dynamic) }, Attribute { name:
|
||||
| Atom('alt' type=inline), value: Atom('W3Schools.com' type=dynamic) }, Attribute { name: Atom('width' type=inline), value: Atom('104' type=inline) }, Attribute { name: Atom('height' type=inline),
|
||||
| value: Atom('142' type=inline) }] }
|
||||
,-[$DIR/tests/fixture/images/input.html:8:1]
|
||||
8 | <img src="w3schools.jpg" alt="W3Schools.com" width="104" height="142">
|
||||
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/images/input.html:8:1]
|
||||
8 | <img src="w3schools.jpg" alt="W3Schools.com" width="104" height="142">
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/images/input.html:9:1]
|
||||
9 |
|
||||
: ^
|
||||
10 | </body>
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('body' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/images/input.html:10:1]
|
||||
10 | </body>
|
||||
: ^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/images/input.html:10:1]
|
||||
10 | </body>
|
||||
: ^
|
||||
11 | </html>
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('html' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/images/input.html:11:1]
|
||||
11 | </html>
|
||||
: ^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/images/input.html:11:1]
|
||||
11 | </html>
|
||||
: ^
|
||||
`----
|
22
crates/swc_html_parser/tests/fixture/lists/input.html
Normal file
22
crates/swc_html_parser/tests/fixture/lists/input.html
Normal file
@ -0,0 +1,22 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h2>An Unordered HTML List</h2>
|
||||
|
||||
<ul>
|
||||
<li>Coffee</li>
|
||||
<li>Tea</li>
|
||||
<li>Milk</li>
|
||||
</ul>
|
||||
|
||||
<h2>An Ordered HTML List</h2>
|
||||
|
||||
<ol>
|
||||
<li>Coffee</li>
|
||||
<li>Tea</li>
|
||||
<li>Milk</li>
|
||||
</ol>
|
||||
|
||||
</body>
|
||||
</html>
|
1868
crates/swc_html_parser/tests/fixture/lists/output.json
Normal file
1868
crates/swc_html_parser/tests/fixture/lists/output.json
Normal file
File diff suppressed because it is too large
Load Diff
876
crates/swc_html_parser/tests/fixture/lists/span.rust-debug
Normal file
876
crates/swc_html_parser/tests/fixture/lists/span.rust-debug
Normal file
@ -0,0 +1,876 @@
|
||||
|
||||
x Document
|
||||
,-[$DIR/tests/fixture/lists/input.html:1:1]
|
||||
1 | ,-> <!DOCTYPE html>
|
||||
2 | | <html>
|
||||
3 | | <body>
|
||||
4 | |
|
||||
5 | | <h2>An Unordered HTML List</h2>
|
||||
6 | |
|
||||
7 | | <ul>
|
||||
8 | | <li>Coffee</li>
|
||||
9 | | <li>Tea</li>
|
||||
10 | | <li>Milk</li>
|
||||
11 | | </ul>
|
||||
12 | |
|
||||
13 | | <h2>An Ordered HTML List</h2>
|
||||
14 | |
|
||||
15 | | <ol>
|
||||
16 | | <li>Coffee</li>
|
||||
17 | | <li>Tea</li>
|
||||
18 | | <li>Milk</li>
|
||||
19 | | </ol>
|
||||
20 | |
|
||||
21 | | </body>
|
||||
22 | `-> </html>
|
||||
`----
|
||||
|
||||
x Doctype { name: Some(Atom('html' type=inline)), force_quirks: false, public_id: None, system_id: None }
|
||||
,-[$DIR/tests/fixture/lists/input.html:1:1]
|
||||
1 | <!DOCTYPE html>
|
||||
: ^^^^^^^^^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:1:1]
|
||||
1 | <!DOCTYPE html>
|
||||
: ^
|
||||
2 | <html>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('html' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/lists/input.html:2:1]
|
||||
2 | <html>
|
||||
: ^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:2:1]
|
||||
2 | <html>
|
||||
: ^
|
||||
3 | <body>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('body' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/lists/input.html:3:1]
|
||||
3 | <body>
|
||||
: ^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:3:1]
|
||||
3 | <body>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:4:1]
|
||||
4 |
|
||||
: ^
|
||||
5 | <h2>An Unordered HTML List</h2>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('h2' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/lists/input.html:5:1]
|
||||
5 | <h2>An Unordered HTML List</h2>
|
||||
: ^^^^
|
||||
`----
|
||||
|
||||
x Character { value: 'A' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:5:1]
|
||||
5 | <h2>An Unordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'n' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:5:1]
|
||||
5 | <h2>An Unordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:5:1]
|
||||
5 | <h2>An Unordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'U' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:5:1]
|
||||
5 | <h2>An Unordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'n' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:5:1]
|
||||
5 | <h2>An Unordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'o' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:5:1]
|
||||
5 | <h2>An Unordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'r' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:5:1]
|
||||
5 | <h2>An Unordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'd' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:5:1]
|
||||
5 | <h2>An Unordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'e' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:5:1]
|
||||
5 | <h2>An Unordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'r' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:5:1]
|
||||
5 | <h2>An Unordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'e' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:5:1]
|
||||
5 | <h2>An Unordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'd' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:5:1]
|
||||
5 | <h2>An Unordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:5:1]
|
||||
5 | <h2>An Unordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'H' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:5:1]
|
||||
5 | <h2>An Unordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'T' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:5:1]
|
||||
5 | <h2>An Unordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'M' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:5:1]
|
||||
5 | <h2>An Unordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'L' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:5:1]
|
||||
5 | <h2>An Unordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:5:1]
|
||||
5 | <h2>An Unordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'L' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:5:1]
|
||||
5 | <h2>An Unordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:5:1]
|
||||
5 | <h2>An Unordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 's' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:5:1]
|
||||
5 | <h2>An Unordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 't' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:5:1]
|
||||
5 | <h2>An Unordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('h2' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/lists/input.html:5:1]
|
||||
5 | <h2>An Unordered HTML List</h2>
|
||||
: ^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:5:1]
|
||||
5 | <h2>An Unordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:6:1]
|
||||
6 |
|
||||
: ^
|
||||
7 | <ul>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('ul' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/lists/input.html:7:1]
|
||||
7 | <ul>
|
||||
: ^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:7:1]
|
||||
7 | <ul>
|
||||
: ^
|
||||
8 | <li>Coffee</li>
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:8:1]
|
||||
8 | <li>Coffee</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:8:2]
|
||||
8 | <li>Coffee</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:8:3]
|
||||
8 | <li>Coffee</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:8:4]
|
||||
8 | <li>Coffee</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('li' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/lists/input.html:8:5]
|
||||
8 | <li>Coffee</li>
|
||||
: ^^^^
|
||||
`----
|
||||
|
||||
x Character { value: 'C' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:8:5]
|
||||
8 | <li>Coffee</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'o' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:8:5]
|
||||
8 | <li>Coffee</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'f' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:8:5]
|
||||
8 | <li>Coffee</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'f' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:8:5]
|
||||
8 | <li>Coffee</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'e' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:8:5]
|
||||
8 | <li>Coffee</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'e' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:8:5]
|
||||
8 | <li>Coffee</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('li' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/lists/input.html:8:5]
|
||||
8 | <li>Coffee</li>
|
||||
: ^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:8:5]
|
||||
8 | <li>Coffee</li>
|
||||
: ^
|
||||
9 | <li>Tea</li>
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:9:1]
|
||||
9 | <li>Tea</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:9:2]
|
||||
9 | <li>Tea</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:9:3]
|
||||
9 | <li>Tea</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:9:4]
|
||||
9 | <li>Tea</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('li' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/lists/input.html:9:5]
|
||||
9 | <li>Tea</li>
|
||||
: ^^^^
|
||||
`----
|
||||
|
||||
x Character { value: 'T' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:9:5]
|
||||
9 | <li>Tea</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'e' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:9:5]
|
||||
9 | <li>Tea</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'a' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:9:5]
|
||||
9 | <li>Tea</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('li' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/lists/input.html:9:5]
|
||||
9 | <li>Tea</li>
|
||||
: ^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:9:5]
|
||||
9 | <li>Tea</li>
|
||||
: ^
|
||||
10 | <li>Milk</li>
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:10:1]
|
||||
10 | <li>Milk</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:10:2]
|
||||
10 | <li>Milk</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:10:3]
|
||||
10 | <li>Milk</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:10:4]
|
||||
10 | <li>Milk</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('li' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/lists/input.html:10:5]
|
||||
10 | <li>Milk</li>
|
||||
: ^^^^
|
||||
`----
|
||||
|
||||
x Character { value: 'M' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:10:5]
|
||||
10 | <li>Milk</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:10:5]
|
||||
10 | <li>Milk</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'l' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:10:5]
|
||||
10 | <li>Milk</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'k' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:10:5]
|
||||
10 | <li>Milk</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('li' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/lists/input.html:10:5]
|
||||
10 | <li>Milk</li>
|
||||
: ^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:10:5]
|
||||
10 | <li>Milk</li>
|
||||
: ^
|
||||
11 | </ul>
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('ul' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/lists/input.html:11:1]
|
||||
11 | </ul>
|
||||
: ^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:11:1]
|
||||
11 | </ul>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:12:1]
|
||||
12 |
|
||||
: ^
|
||||
13 | <h2>An Ordered HTML List</h2>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('h2' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/lists/input.html:13:1]
|
||||
13 | <h2>An Ordered HTML List</h2>
|
||||
: ^^^^
|
||||
`----
|
||||
|
||||
x Character { value: 'A' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:13:1]
|
||||
13 | <h2>An Ordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'n' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:13:1]
|
||||
13 | <h2>An Ordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:13:1]
|
||||
13 | <h2>An Ordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'O' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:13:1]
|
||||
13 | <h2>An Ordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'r' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:13:1]
|
||||
13 | <h2>An Ordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'd' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:13:1]
|
||||
13 | <h2>An Ordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'e' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:13:1]
|
||||
13 | <h2>An Ordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'r' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:13:1]
|
||||
13 | <h2>An Ordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'e' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:13:1]
|
||||
13 | <h2>An Ordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'd' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:13:1]
|
||||
13 | <h2>An Ordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:13:1]
|
||||
13 | <h2>An Ordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'H' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:13:1]
|
||||
13 | <h2>An Ordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'T' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:13:1]
|
||||
13 | <h2>An Ordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'M' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:13:1]
|
||||
13 | <h2>An Ordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'L' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:13:1]
|
||||
13 | <h2>An Ordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:13:1]
|
||||
13 | <h2>An Ordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'L' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:13:1]
|
||||
13 | <h2>An Ordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:13:1]
|
||||
13 | <h2>An Ordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 's' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:13:1]
|
||||
13 | <h2>An Ordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 't' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:13:1]
|
||||
13 | <h2>An Ordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('h2' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/lists/input.html:13:1]
|
||||
13 | <h2>An Ordered HTML List</h2>
|
||||
: ^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:13:1]
|
||||
13 | <h2>An Ordered HTML List</h2>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:14:1]
|
||||
14 |
|
||||
: ^
|
||||
15 | <ol>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('ol' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/lists/input.html:15:1]
|
||||
15 | <ol>
|
||||
: ^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:15:1]
|
||||
15 | <ol>
|
||||
: ^
|
||||
16 | <li>Coffee</li>
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:16:1]
|
||||
16 | <li>Coffee</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:16:2]
|
||||
16 | <li>Coffee</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:16:3]
|
||||
16 | <li>Coffee</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:16:4]
|
||||
16 | <li>Coffee</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('li' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/lists/input.html:16:5]
|
||||
16 | <li>Coffee</li>
|
||||
: ^^^^
|
||||
`----
|
||||
|
||||
x Character { value: 'C' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:16:5]
|
||||
16 | <li>Coffee</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'o' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:16:5]
|
||||
16 | <li>Coffee</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'f' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:16:5]
|
||||
16 | <li>Coffee</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'f' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:16:5]
|
||||
16 | <li>Coffee</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'e' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:16:5]
|
||||
16 | <li>Coffee</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'e' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:16:5]
|
||||
16 | <li>Coffee</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('li' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/lists/input.html:16:5]
|
||||
16 | <li>Coffee</li>
|
||||
: ^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:16:5]
|
||||
16 | <li>Coffee</li>
|
||||
: ^
|
||||
17 | <li>Tea</li>
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:17:1]
|
||||
17 | <li>Tea</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:17:2]
|
||||
17 | <li>Tea</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:17:3]
|
||||
17 | <li>Tea</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:17:4]
|
||||
17 | <li>Tea</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('li' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/lists/input.html:17:5]
|
||||
17 | <li>Tea</li>
|
||||
: ^^^^
|
||||
`----
|
||||
|
||||
x Character { value: 'T' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:17:5]
|
||||
17 | <li>Tea</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'e' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:17:5]
|
||||
17 | <li>Tea</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'a' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:17:5]
|
||||
17 | <li>Tea</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('li' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/lists/input.html:17:5]
|
||||
17 | <li>Tea</li>
|
||||
: ^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:17:5]
|
||||
17 | <li>Tea</li>
|
||||
: ^
|
||||
18 | <li>Milk</li>
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:18:1]
|
||||
18 | <li>Milk</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:18:2]
|
||||
18 | <li>Milk</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:18:3]
|
||||
18 | <li>Milk</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:18:4]
|
||||
18 | <li>Milk</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('li' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/lists/input.html:18:5]
|
||||
18 | <li>Milk</li>
|
||||
: ^^^^
|
||||
`----
|
||||
|
||||
x Character { value: 'M' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:18:5]
|
||||
18 | <li>Milk</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:18:5]
|
||||
18 | <li>Milk</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'l' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:18:5]
|
||||
18 | <li>Milk</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'k' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:18:5]
|
||||
18 | <li>Milk</li>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('li' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/lists/input.html:18:5]
|
||||
18 | <li>Milk</li>
|
||||
: ^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:18:5]
|
||||
18 | <li>Milk</li>
|
||||
: ^
|
||||
19 | </ol>
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('ol' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/lists/input.html:19:1]
|
||||
19 | </ol>
|
||||
: ^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:19:1]
|
||||
19 | </ol>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:20:1]
|
||||
20 |
|
||||
: ^
|
||||
21 | </body>
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('body' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/lists/input.html:21:1]
|
||||
21 | </body>
|
||||
: ^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:21:1]
|
||||
21 | </body>
|
||||
: ^
|
||||
22 | </html>
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('html' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/lists/input.html:22:1]
|
||||
22 | </html>
|
||||
: ^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/lists/input.html:22:1]
|
||||
22 | </html>
|
||||
: ^
|
||||
`----
|
@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<p>This is a paragraph.</p>
|
||||
<!--
|
||||
<p>Look at this cool image:</p>
|
||||
<img border="0" src="pic_trulli.jpg" alt="Trulli">
|
||||
-->
|
||||
<p>This is a paragraph too.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,861 @@
|
||||
{
|
||||
"type": "Document",
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 200,
|
||||
"ctxt": 0
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 15,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Doctype": {
|
||||
"name": "html",
|
||||
"force_quirks": false,
|
||||
"public_id": null,
|
||||
"system_id": null
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 15,
|
||||
"end": 16,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 16,
|
||||
"end": 22,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"StartTag": {
|
||||
"tag_name": "html",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 22,
|
||||
"end": 23,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 23,
|
||||
"end": 29,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"StartTag": {
|
||||
"tag_name": "body",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 29,
|
||||
"end": 30,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 30,
|
||||
"end": 31,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 31,
|
||||
"end": 34,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"StartTag": {
|
||||
"tag_name": "p",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 34,
|
||||
"end": 35,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "T"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 35,
|
||||
"end": 36,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "h"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 36,
|
||||
"end": 37,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "i"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 37,
|
||||
"end": 38,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "s"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 38,
|
||||
"end": 39,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": " "
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 39,
|
||||
"end": 40,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "i"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 40,
|
||||
"end": 41,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "s"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 41,
|
||||
"end": 42,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": " "
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 42,
|
||||
"end": 43,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "a"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 43,
|
||||
"end": 44,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": " "
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 44,
|
||||
"end": 45,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "p"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 45,
|
||||
"end": 46,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "a"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 46,
|
||||
"end": 47,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "r"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 47,
|
||||
"end": 48,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "a"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 48,
|
||||
"end": 49,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "g"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 49,
|
||||
"end": 50,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "r"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 50,
|
||||
"end": 51,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "a"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 51,
|
||||
"end": 52,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "p"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 52,
|
||||
"end": 53,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "h"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 53,
|
||||
"end": 54,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "."
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 54,
|
||||
"end": 58,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"EndTag": {
|
||||
"tag_name": "p",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 58,
|
||||
"end": 59,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 59,
|
||||
"end": 150,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Comment": {
|
||||
"data": "\n<p>Look at this cool image:</p>\n<img border=\"0\" src=\"pic_trulli.jpg\" alt=\"Trulli\">\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 150,
|
||||
"end": 151,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 151,
|
||||
"end": 154,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"StartTag": {
|
||||
"tag_name": "p",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 154,
|
||||
"end": 155,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "T"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 155,
|
||||
"end": 156,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "h"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 156,
|
||||
"end": 157,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "i"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 157,
|
||||
"end": 158,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "s"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 158,
|
||||
"end": 159,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": " "
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 159,
|
||||
"end": 160,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "i"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 160,
|
||||
"end": 161,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "s"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 161,
|
||||
"end": 162,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": " "
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 162,
|
||||
"end": 163,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "a"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 163,
|
||||
"end": 164,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": " "
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 164,
|
||||
"end": 165,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "p"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 165,
|
||||
"end": 166,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "a"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 166,
|
||||
"end": 167,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "r"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 167,
|
||||
"end": 168,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "a"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 168,
|
||||
"end": 169,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "g"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 169,
|
||||
"end": 170,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "r"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 170,
|
||||
"end": 171,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "a"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 171,
|
||||
"end": 172,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "p"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 172,
|
||||
"end": 173,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "h"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 173,
|
||||
"end": 174,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": " "
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 174,
|
||||
"end": 175,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "t"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 175,
|
||||
"end": 176,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "o"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 176,
|
||||
"end": 177,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "o"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 177,
|
||||
"end": 178,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "."
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 178,
|
||||
"end": 182,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"EndTag": {
|
||||
"tag_name": "p",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 182,
|
||||
"end": 183,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 183,
|
||||
"end": 184,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 184,
|
||||
"end": 191,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"EndTag": {
|
||||
"tag_name": "body",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 191,
|
||||
"end": 192,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 192,
|
||||
"end": 199,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"EndTag": {
|
||||
"tag_name": "html",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 199,
|
||||
"end": 200,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,413 @@
|
||||
|
||||
x Document
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:1:1]
|
||||
1 | ,-> <!DOCTYPE html>
|
||||
2 | | <html>
|
||||
3 | | <body>
|
||||
4 | |
|
||||
5 | | <p>This is a paragraph.</p>
|
||||
6 | | <!--
|
||||
7 | | <p>Look at this cool image:</p>
|
||||
8 | | <img border="0" src="pic_trulli.jpg" alt="Trulli">
|
||||
9 | | -->
|
||||
10 | | <p>This is a paragraph too.</p>
|
||||
11 | |
|
||||
12 | | </body>
|
||||
13 | `-> </html>
|
||||
`----
|
||||
|
||||
x Doctype { name: Some(Atom('html' type=inline)), force_quirks: false, public_id: None, system_id: None }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:1:1]
|
||||
1 | <!DOCTYPE html>
|
||||
: ^^^^^^^^^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:1:1]
|
||||
1 | <!DOCTYPE html>
|
||||
: ^
|
||||
2 | <html>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('html' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:2:1]
|
||||
2 | <html>
|
||||
: ^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:2:1]
|
||||
2 | <html>
|
||||
: ^
|
||||
3 | <body>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('body' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:3:1]
|
||||
3 | <body>
|
||||
: ^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:3:1]
|
||||
3 | <body>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:4:1]
|
||||
4 |
|
||||
: ^
|
||||
5 | <p>This is a paragraph.</p>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('p' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^^^
|
||||
`----
|
||||
|
||||
x Character { value: 'T' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'h' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 's' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 's' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'a' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'p' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'a' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'r' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'a' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'g' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'r' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'a' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'p' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'h' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '.' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('p' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
6 | <!--
|
||||
`----
|
||||
|
||||
x Comment { data: Atom('
|
||||
| <p>Look at this cool image:</p>
|
||||
| <img border="0" src="pic_trulli.jpg" alt="Trulli">
|
||||
| ' type=dynamic) }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:6:1]
|
||||
6 | ,-> <!--
|
||||
7 | | <p>Look at this cool image:</p>
|
||||
8 | | <img border="0" src="pic_trulli.jpg" alt="Trulli">
|
||||
9 | `-> -->
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:9:1]
|
||||
9 | -->
|
||||
: ^
|
||||
10 | <p>This is a paragraph too.</p>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('p' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:10:1]
|
||||
10 | <p>This is a paragraph too.</p>
|
||||
: ^^^
|
||||
`----
|
||||
|
||||
x Character { value: 'T' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:10:1]
|
||||
10 | <p>This is a paragraph too.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'h' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:10:1]
|
||||
10 | <p>This is a paragraph too.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:10:1]
|
||||
10 | <p>This is a paragraph too.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 's' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:10:1]
|
||||
10 | <p>This is a paragraph too.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:10:1]
|
||||
10 | <p>This is a paragraph too.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:10:1]
|
||||
10 | <p>This is a paragraph too.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 's' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:10:1]
|
||||
10 | <p>This is a paragraph too.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:10:1]
|
||||
10 | <p>This is a paragraph too.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'a' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:10:1]
|
||||
10 | <p>This is a paragraph too.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:10:1]
|
||||
10 | <p>This is a paragraph too.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'p' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:10:1]
|
||||
10 | <p>This is a paragraph too.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'a' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:10:1]
|
||||
10 | <p>This is a paragraph too.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'r' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:10:1]
|
||||
10 | <p>This is a paragraph too.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'a' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:10:1]
|
||||
10 | <p>This is a paragraph too.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'g' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:10:1]
|
||||
10 | <p>This is a paragraph too.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'r' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:10:1]
|
||||
10 | <p>This is a paragraph too.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'a' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:10:1]
|
||||
10 | <p>This is a paragraph too.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'p' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:10:1]
|
||||
10 | <p>This is a paragraph too.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'h' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:10:1]
|
||||
10 | <p>This is a paragraph too.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:10:1]
|
||||
10 | <p>This is a paragraph too.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 't' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:10:1]
|
||||
10 | <p>This is a paragraph too.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'o' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:10:1]
|
||||
10 | <p>This is a paragraph too.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'o' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:10:1]
|
||||
10 | <p>This is a paragraph too.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '.' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:10:1]
|
||||
10 | <p>This is a paragraph too.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('p' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:10:1]
|
||||
10 | <p>This is a paragraph too.</p>
|
||||
: ^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:10:1]
|
||||
10 | <p>This is a paragraph too.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:11:1]
|
||||
11 |
|
||||
: ^
|
||||
12 | </body>
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('body' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:12:1]
|
||||
12 | </body>
|
||||
: ^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:12:1]
|
||||
12 | </body>
|
||||
: ^
|
||||
13 | </html>
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('html' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:13:1]
|
||||
13 | </html>
|
||||
: ^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/multiline-comments/input.html:13:1]
|
||||
13 | </html>
|
||||
: ^
|
||||
`----
|
@ -0,0 +1,9 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<p>This is a paragraph.</p>
|
||||
<p>This is another paragraph.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
861
crates/swc_html_parser/tests/fixture/paragraphs/output.json
Normal file
861
crates/swc_html_parser/tests/fixture/paragraphs/output.json
Normal file
@ -0,0 +1,861 @@
|
||||
{
|
||||
"type": "Document",
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 110,
|
||||
"ctxt": 0
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 15,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Doctype": {
|
||||
"name": "html",
|
||||
"force_quirks": false,
|
||||
"public_id": null,
|
||||
"system_id": null
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 15,
|
||||
"end": 16,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 16,
|
||||
"end": 22,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"StartTag": {
|
||||
"tag_name": "html",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 22,
|
||||
"end": 23,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 23,
|
||||
"end": 29,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"StartTag": {
|
||||
"tag_name": "body",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 29,
|
||||
"end": 30,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 30,
|
||||
"end": 31,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 31,
|
||||
"end": 34,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"StartTag": {
|
||||
"tag_name": "p",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 34,
|
||||
"end": 35,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "T"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 35,
|
||||
"end": 36,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "h"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 36,
|
||||
"end": 37,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "i"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 37,
|
||||
"end": 38,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "s"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 38,
|
||||
"end": 39,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": " "
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 39,
|
||||
"end": 40,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "i"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 40,
|
||||
"end": 41,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "s"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 41,
|
||||
"end": 42,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": " "
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 42,
|
||||
"end": 43,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "a"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 43,
|
||||
"end": 44,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": " "
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 44,
|
||||
"end": 45,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "p"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 45,
|
||||
"end": 46,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "a"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 46,
|
||||
"end": 47,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "r"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 47,
|
||||
"end": 48,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "a"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 48,
|
||||
"end": 49,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "g"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 49,
|
||||
"end": 50,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "r"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 50,
|
||||
"end": 51,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "a"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 51,
|
||||
"end": 52,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "p"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 52,
|
||||
"end": 53,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "h"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 53,
|
||||
"end": 54,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "."
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 54,
|
||||
"end": 58,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"EndTag": {
|
||||
"tag_name": "p",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 58,
|
||||
"end": 59,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 59,
|
||||
"end": 62,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"StartTag": {
|
||||
"tag_name": "p",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 62,
|
||||
"end": 63,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "T"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 63,
|
||||
"end": 64,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "h"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 64,
|
||||
"end": 65,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "i"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 65,
|
||||
"end": 66,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "s"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 66,
|
||||
"end": 67,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": " "
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 67,
|
||||
"end": 68,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "i"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 68,
|
||||
"end": 69,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "s"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 69,
|
||||
"end": 70,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": " "
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 70,
|
||||
"end": 71,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "a"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 71,
|
||||
"end": 72,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 72,
|
||||
"end": 73,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "o"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 73,
|
||||
"end": 74,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "t"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 74,
|
||||
"end": 75,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "h"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 75,
|
||||
"end": 76,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "e"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 76,
|
||||
"end": 77,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "r"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 77,
|
||||
"end": 78,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": " "
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 78,
|
||||
"end": 79,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "p"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 79,
|
||||
"end": 80,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "a"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 80,
|
||||
"end": 81,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "r"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 81,
|
||||
"end": 82,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "a"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 82,
|
||||
"end": 83,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "g"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 83,
|
||||
"end": 84,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "r"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 84,
|
||||
"end": 85,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "a"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 85,
|
||||
"end": 86,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "p"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 86,
|
||||
"end": 87,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "h"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 87,
|
||||
"end": 88,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "."
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 88,
|
||||
"end": 92,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"EndTag": {
|
||||
"tag_name": "p",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 92,
|
||||
"end": 93,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 93,
|
||||
"end": 94,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 94,
|
||||
"end": 101,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"EndTag": {
|
||||
"tag_name": "body",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 101,
|
||||
"end": 102,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 102,
|
||||
"end": 109,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"EndTag": {
|
||||
"tag_name": "html",
|
||||
"self_closing": false,
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TokenAndSpan",
|
||||
"span": {
|
||||
"start": 109,
|
||||
"end": 110,
|
||||
"ctxt": 0
|
||||
},
|
||||
"token": {
|
||||
"Character": {
|
||||
"value": "\n"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
403
crates/swc_html_parser/tests/fixture/paragraphs/span.rust-debug
Normal file
403
crates/swc_html_parser/tests/fixture/paragraphs/span.rust-debug
Normal file
@ -0,0 +1,403 @@
|
||||
|
||||
x Document
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:1:1]
|
||||
1 | ,-> <!DOCTYPE html>
|
||||
2 | | <html>
|
||||
3 | | <body>
|
||||
4 | |
|
||||
5 | | <p>This is a paragraph.</p>
|
||||
6 | | <p>This is another paragraph.</p>
|
||||
7 | |
|
||||
8 | | </body>
|
||||
9 | `-> </html>
|
||||
`----
|
||||
|
||||
x Doctype { name: Some(Atom('html' type=inline)), force_quirks: false, public_id: None, system_id: None }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:1:1]
|
||||
1 | <!DOCTYPE html>
|
||||
: ^^^^^^^^^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:1:1]
|
||||
1 | <!DOCTYPE html>
|
||||
: ^
|
||||
2 | <html>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('html' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:2:1]
|
||||
2 | <html>
|
||||
: ^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:2:1]
|
||||
2 | <html>
|
||||
: ^
|
||||
3 | <body>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('body' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:3:1]
|
||||
3 | <body>
|
||||
: ^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:3:1]
|
||||
3 | <body>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:4:1]
|
||||
4 |
|
||||
: ^
|
||||
5 | <p>This is a paragraph.</p>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('p' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^^^
|
||||
`----
|
||||
|
||||
x Character { value: 'T' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'h' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 's' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 's' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'a' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'p' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'a' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'r' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'a' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'g' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'r' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'a' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'p' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'h' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '.' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('p' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:5:1]
|
||||
5 | <p>This is a paragraph.</p>
|
||||
: ^
|
||||
6 | <p>This is another paragraph.</p>
|
||||
`----
|
||||
|
||||
x StartTag { tag_name: Atom('p' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:6:1]
|
||||
6 | <p>This is another paragraph.</p>
|
||||
: ^^^
|
||||
`----
|
||||
|
||||
x Character { value: 'T' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:6:1]
|
||||
6 | <p>This is another paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'h' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:6:1]
|
||||
6 | <p>This is another paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:6:1]
|
||||
6 | <p>This is another paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 's' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:6:1]
|
||||
6 | <p>This is another paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:6:1]
|
||||
6 | <p>This is another paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'i' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:6:1]
|
||||
6 | <p>This is another paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 's' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:6:1]
|
||||
6 | <p>This is another paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:6:1]
|
||||
6 | <p>This is another paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'a' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:6:1]
|
||||
6 | <p>This is another paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'n' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:6:1]
|
||||
6 | <p>This is another paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'o' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:6:1]
|
||||
6 | <p>This is another paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 't' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:6:1]
|
||||
6 | <p>This is another paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'h' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:6:1]
|
||||
6 | <p>This is another paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'e' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:6:1]
|
||||
6 | <p>This is another paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'r' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:6:1]
|
||||
6 | <p>This is another paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: ' ' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:6:1]
|
||||
6 | <p>This is another paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'p' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:6:1]
|
||||
6 | <p>This is another paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'a' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:6:1]
|
||||
6 | <p>This is another paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'r' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:6:1]
|
||||
6 | <p>This is another paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'a' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:6:1]
|
||||
6 | <p>This is another paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'g' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:6:1]
|
||||
6 | <p>This is another paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'r' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:6:1]
|
||||
6 | <p>This is another paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'a' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:6:1]
|
||||
6 | <p>This is another paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'p' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:6:1]
|
||||
6 | <p>This is another paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: 'h' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:6:1]
|
||||
6 | <p>This is another paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '.' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:6:1]
|
||||
6 | <p>This is another paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('p' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:6:1]
|
||||
6 | <p>This is another paragraph.</p>
|
||||
: ^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:6:1]
|
||||
6 | <p>This is another paragraph.</p>
|
||||
: ^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:7:1]
|
||||
7 |
|
||||
: ^
|
||||
8 | </body>
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('body' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:8:1]
|
||||
8 | </body>
|
||||
: ^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:8:1]
|
||||
8 | </body>
|
||||
: ^
|
||||
9 | </html>
|
||||
`----
|
||||
|
||||
x EndTag { tag_name: Atom('html' type=inline), self_closing: false, attributes: [] }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:9:1]
|
||||
9 | </html>
|
||||
: ^^^^^^^
|
||||
`----
|
||||
|
||||
x Character { value: '\n' }
|
||||
,-[$DIR/tests/fixture/paragraphs/input.html:9:1]
|
||||
9 | </html>
|
||||
: ^
|
||||
`----
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user