file_path stringlengths 3 280 | file_language stringclasses 66 values | content stringlengths 1 1.04M | repo_name stringlengths 5 92 | repo_stars int64 0 154k | repo_description stringlengths 0 402 | repo_primary_language stringclasses 108 values | developer_username stringlengths 1 25 | developer_name stringlengths 0 30 | developer_company stringlengths 0 82 |
|---|---|---|---|---|---|---|---|---|---|
crates/swc_fast_ts_strip/tests/fixture/type-assertions/1.js | JavaScript | const foo = 1 ;
const bar = "bar"; | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_fast_ts_strip/tests/fixture/type-assertions/1.transform.js | JavaScript | const foo = 1;
const bar = "bar";
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_fast_ts_strip/tests/fixture/type-assertions/1.ts | TypeScript | const foo = 1 as number;
const bar = "bar"; | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_fast_ts_strip/tests/fixture/type-import-export.js | JavaScript |
import { x4, } from "m3";
import { x7, } from "m4";
import { x9, } from "m5";
import { } from "m6";
import { x17 } from "m7";
import { /* } */ } from 'foo';
export { x3 ,}
export { x8 , x9 , } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_fast_ts_strip/tests/fixture/type-import-export.transform.js | JavaScript | import { x9 } from "m5";
export { x9, };
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_fast_ts_strip/tests/fixture/type-import-export.ts | TypeScript | import type x1 from "m1";
import type { x2, x3 } from "m2";
import { x4, type x5, } from "m3";
import { type x6, x7, } from "m4";
import { type x8, x9, type x10 } from "m5";
import { type x11, type x12, type x13, } from "m6";
import { type x14, type x15, type x16, x17 } from "m7";
import {type x , /* } */ } from 'foo';
export { type x1 , type x2 , x3 ,}
export type { x4 , x5 , x6 }
export { type x7 , x8 , x9 , type x10 , } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_fast_ts_strip/tests/fixture/unicode.transform.js | JavaScript | function foo() {
void 1;
throw new Error('foo');
}
foo();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_fast_ts_strip/tests/fixture/unicode.ts | TypeScript | type 任意 = any;
function foo() {
<任意>(void 1); throw new Error('foo');
}
foo(); | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_graph_analyzer/src/lib.rs | Rust | use std::{fmt::Debug, hash::Hash, marker::PhantomData};
use auto_impl::auto_impl;
use rustc_hash::FxHashSet;
use swc_fast_graph::digraph::FastDiGraphMap;
#[auto_impl(&, Box, Rc, Arc)]
pub trait DepGraph {
type ModuleId: Debug + Copy + Eq + Hash + Ord;
fn deps_of(&self, module_id: Self::ModuleId) -> Vec<Self::ModuleId>;
}
/// Utility to detect cycles in a dependency graph.
pub struct GraphAnalyzer<G>
where
G: DepGraph,
{
/// `(src, dst)`
tracked: FxHashSet<(G::ModuleId, G::ModuleId)>,
dep_graph: G,
data: GraphResult<G>,
}
impl<G> GraphAnalyzer<G>
where
G: DepGraph,
{
pub fn new(dep_graph: G) -> Self {
Self {
dep_graph,
data: GraphResult {
all: Default::default(),
graph: Default::default(),
cycles: Default::default(),
_marker: Default::default(),
},
tracked: Default::default(),
}
}
pub fn load(&mut self, entry: G::ModuleId) {
self.add_to_graph(
entry,
&mut vec![entry],
&mut State {
visited: Default::default(),
},
);
}
fn add_to_graph(
&mut self,
module_id: G::ModuleId,
path: &mut Vec<G::ModuleId>,
state: &mut State<G::ModuleId>,
) {
let visited = state.visited.contains(&module_id);
// dbg!(visited);
// dbg!(&path);
let cycle_rpos = if visited {
path.iter().rposition(|v| *v == module_id)
} else {
None
};
if let Some(rpos) = cycle_rpos {
let cycle = path[rpos..].to_vec();
tracing::debug!("Found cycle: {:?}", cycle);
self.data.cycles.push(cycle);
}
let prev_last = *path.last().unwrap();
// Prevent infinite recursion.
if !self.tracked.insert((prev_last, module_id)) {
return;
}
path.push(module_id);
if !visited {
state.visited.push(module_id);
}
if !self.data.all.contains(&module_id) {
self.data.all.push(module_id);
}
self.data.graph.add_node(module_id);
for dep_module_id in self.dep_graph.deps_of(module_id) {
tracing::debug!("Dep: {:?} -> {:?}", module_id, dep_module_id);
self.data.graph.add_edge(module_id, dep_module_id, ());
self.add_to_graph(dep_module_id, path, state);
}
let res = path.pop();
debug_assert_eq!(res, Some(module_id));
}
pub fn into_result(self) -> GraphResult<G> {
self.data
}
}
struct State<I> {
visited: Vec<I>,
}
pub struct GraphResult<G>
where
G: DepGraph,
{
pub all: Vec<G::ModuleId>,
pub graph: FastDiGraphMap<G::ModuleId, ()>,
pub cycles: Vec<Vec<G::ModuleId>>,
_marker: PhantomData<G>,
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_graph_analyzer/tests/cycle.rs | Rust | use swc_graph_analyzer::{DepGraph, GraphAnalyzer};
struct Deps<'a> {
deps: &'a [(usize, Vec<usize>)],
}
impl DepGraph for Deps<'_> {
type ModuleId = usize;
fn deps_of(&self, module_id: Self::ModuleId) -> Vec<Self::ModuleId> {
self.deps
.iter()
.find_map(|(id, deps)| {
if *id == module_id {
Some(deps.clone())
} else {
None
}
})
.unwrap()
}
}
fn assert_cycles(deps: &[(usize, Vec<usize>)], cycles: Vec<Vec<usize>>) {
let _logger = testing::init();
{
let mut analyzer = GraphAnalyzer::new(Deps { deps });
analyzer.load(0);
let res = analyzer.into_result();
assert_eq!(res.cycles, cycles);
}
{
// Ensure that multiple load does not affect cycle detection.
let mut analyzer = GraphAnalyzer::new(Deps { deps });
for idx in 0..deps.len() {
analyzer.load(idx);
}
let res = analyzer.into_result();
assert_eq!(res.cycles, cycles);
}
}
#[test]
fn stc_1() {
assert_cycles(
&[
(0, vec![2]),
(1, Vec::new()),
(2, vec![1]),
(3, vec![0]),
(4, vec![2, 3]),
],
Vec::new(),
);
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html/src/lib.rs | Rust | 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;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_ast/src/base.rs | Rust | use is_macro::Is;
use string_enum::StringEnum;
use swc_atoms::Atom;
use swc_common::{ast_node, EqIgnoreSpan, Span};
#[ast_node("Document")]
#[derive(Eq, Hash, EqIgnoreSpan)]
pub struct Document {
pub span: Span,
pub mode: DocumentMode,
pub children: Vec<Child>,
}
#[ast_node("DocumentFragment")]
#[derive(Eq, Hash, EqIgnoreSpan)]
pub struct DocumentFragment {
pub span: Span,
pub children: Vec<Child>,
}
#[derive(StringEnum, Clone, Copy, Eq, PartialEq, PartialOrd, Ord, Hash, EqIgnoreSpan)]
#[cfg_attr(
feature = "rkyv",
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
)]
#[cfg_attr(feature = "rkyv", derive(bytecheck::CheckBytes))]
//#[cfg_attr(
// feature = "rkyv",
// archive(bound(serialize = "__S: rkyv::ser::ScratchSpace +
// rkyv::ser::Serializer"))
//)]
#[cfg_attr(feature = "rkyv", repr(u32))]
pub enum DocumentMode {
/// `no-quirks`
NoQuirks,
/// `limited-quirks`
LimitedQuirks,
/// `quirks`
Quirks,
}
#[ast_node]
#[derive(Eq, Hash, Is, EqIgnoreSpan)]
pub enum Child {
#[tag("DocumentType")]
DocumentType(DocumentType),
#[tag("Element")]
Element(Element),
#[tag("Text")]
Text(Text),
#[tag("Comment")]
Comment(Comment),
}
#[ast_node("DocumentType")]
#[derive(Eq, Hash)]
pub struct DocumentType {
pub span: Span,
pub name: Option<Atom>,
pub public_id: Option<Atom>,
pub system_id: Option<Atom>,
pub raw: Option<Atom>,
}
impl EqIgnoreSpan for DocumentType {
fn eq_ignore_span(&self, other: &Self) -> bool {
self.name == other.name
&& self.public_id == other.public_id
&& self.system_id == other.system_id
}
}
#[derive(StringEnum, Clone, Copy, Eq, PartialEq, PartialOrd, Ord, Hash, EqIgnoreSpan)]
#[cfg_attr(
feature = "rkyv",
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
)]
#[cfg_attr(feature = "rkyv", derive(bytecheck::CheckBytes))]
//#[cfg_attr(
// feature = "rkyv",
// archive(bound(serialize = "__S: rkyv::ser::ScratchSpace +
// rkyv::ser::Serializer"))
//)]
#[cfg_attr(feature = "rkyv", repr(u32))]
pub enum Namespace {
/// `http://www.w3.org/1999/xhtml`
HTML,
/// `http://www.w3.org/1998/Math/MathML`
MATHML,
/// `http://www.w3.org/2000/svg`
SVG,
/// `http://www.w3.org/1999/xlink`
XLINK,
/// `http://www.w3.org/XML/1998/namespace`
XML,
/// `http://www.w3.org/2000/xmlns/`
XMLNS,
}
#[ast_node("Element")]
#[derive(Eq, Hash, EqIgnoreSpan)]
pub struct Element {
pub span: Span,
pub tag_name: Atom,
pub namespace: Namespace,
pub attributes: Vec<Attribute>,
pub children: Vec<Child>,
/// For child nodes in `<template>`
pub content: Option<DocumentFragment>,
pub is_self_closing: bool,
}
#[ast_node("Attribute")]
#[derive(Eq, Hash)]
pub struct Attribute {
pub span: Span,
pub namespace: Option<Namespace>,
pub prefix: Option<Atom>,
pub name: Atom,
pub raw_name: Option<Atom>,
pub value: Option<Atom>,
pub raw_value: Option<Atom>,
}
impl EqIgnoreSpan for Attribute {
fn eq_ignore_span(&self, other: &Self) -> bool {
self.namespace == other.namespace
&& self.prefix == other.prefix
&& self.name == other.name
&& self.value == other.value
}
}
#[ast_node("Text")]
#[derive(Eq, Hash)]
pub struct Text {
pub span: Span,
pub data: Atom,
pub raw: Option<Atom>,
}
impl EqIgnoreSpan for Text {
fn eq_ignore_span(&self, other: &Self) -> bool {
self.data == other.data
}
}
#[ast_node("Comment")]
#[derive(Eq, Hash)]
pub struct Comment {
pub span: Span,
pub data: Atom,
pub raw: Option<Atom>,
}
impl EqIgnoreSpan for Comment {
fn eq_ignore_span(&self, other: &Self) -> bool {
self.data == other.data
}
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_ast/src/lib.rs | Rust | #![deny(clippy::all)]
#![allow(clippy::large_enum_variant)]
//! AST definitions for HTML.
pub use self::{base::*, token::*};
mod base;
mod token;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_ast/src/token.rs | Rust | use swc_atoms::Atom;
use swc_common::{ast_node, EqIgnoreSpan, Span};
#[ast_node("TokenAndSpan")]
#[derive(Eq, Hash, EqIgnoreSpan)]
pub struct TokenAndSpan {
pub span: Span,
pub token: Token,
}
#[ast_node]
#[derive(Eq, PartialOrd, Ord, Hash, EqIgnoreSpan)]
pub struct AttributeToken {
pub span: Span,
pub name: Atom,
pub raw_name: Option<Atom>,
pub value: Option<Atom>,
pub raw_value: Option<Atom>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, EqIgnoreSpan)]
#[cfg_attr(
feature = "rkyv",
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
)]
#[cfg_attr(
feature = "rkyv",
rkyv(serialize_bounds(__S: rkyv::ser::Writer + rkyv::ser::Allocator,
__S::Error: rkyv::rancor::Source))
)]
#[cfg_attr(feature = "rkyv", derive(bytecheck::CheckBytes))]
#[cfg_attr(feature = "rkyv", repr(u32))]
#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
pub enum Raw {
Same,
Atom(Atom),
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, EqIgnoreSpan)]
#[cfg_attr(
feature = "rkyv",
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
)]
#[cfg_attr(
feature = "rkyv",
rkyv(serialize_bounds(__S: rkyv::ser::Writer + rkyv::ser::Allocator,
__S::Error: rkyv::rancor::Source))
)]
#[cfg_attr(feature = "rkyv", derive(bytecheck::CheckBytes))]
#[cfg_attr(feature = "rkyv", repr(u32))]
#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
pub enum Token {
Doctype {
// Name
name: Option<Atom>,
// Is force quirks?
force_quirks: bool,
// Public identifier
public_id: Option<Atom>,
// System identifier
system_id: Option<Atom>,
// Raw value
raw: Option<Atom>,
},
StartTag {
tag_name: Atom,
raw_tag_name: Option<Atom>,
is_self_closing: bool,
attributes: Vec<AttributeToken>,
},
EndTag {
tag_name: Atom,
raw_tag_name: Option<Atom>,
is_self_closing: bool,
attributes: Vec<AttributeToken>,
},
Comment {
data: Atom,
raw: Option<Atom>,
},
Character {
value: char,
raw: Option<Raw>,
},
Eof,
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/src/ctx.rs | Rust | use std::ops::{Deref, DerefMut};
use crate::{writer::HtmlWriter, CodeGenerator};
impl<'b, W> CodeGenerator<'b, W>
where
W: HtmlWriter,
{
/// Original context is restored when returned guard is dropped.
#[inline]
pub(super) fn with_ctx(&mut self, ctx: Ctx) -> WithCtx<'_, 'b, W> {
let orig_ctx = self.ctx;
self.ctx = ctx;
WithCtx {
orig_ctx,
inner: self,
}
}
}
#[derive(Debug, Default, Clone, Copy)]
pub(crate) struct Ctx {
pub need_escape_text: bool,
}
pub(super) struct WithCtx<'w, 'a, I: 'w + HtmlWriter> {
inner: &'w mut CodeGenerator<'a, I>,
orig_ctx: Ctx,
}
impl<'w, I: HtmlWriter> Deref for WithCtx<'_, 'w, I> {
type Target = CodeGenerator<'w, I>;
fn deref(&self) -> &CodeGenerator<'w, I> {
self.inner
}
}
impl<'w, I: HtmlWriter> DerefMut for WithCtx<'_, 'w, I> {
fn deref_mut(&mut self) -> &mut CodeGenerator<'w, I> {
self.inner
}
}
impl<I: HtmlWriter> Drop for WithCtx<'_, '_, I> {
fn drop(&mut self) {
self.inner.ctx = self.orig_ctx;
}
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/src/emit.rs | Rust | 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,
{
#[allow(clippy::only_used_in_recursion)]
#[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(()),
}
}
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/src/lib.rs | Rust | #![deny(clippy::all)]
#![allow(clippy::needless_update)]
#![allow(clippy::match_like_matches_macro)]
#![allow(non_local_definitions)]
pub use std::fmt::Result;
use std::{borrow::Cow, iter::Peekable, str::Chars};
use swc_atoms::Atom;
use swc_common::Spanned;
use swc_html_ast::*;
use swc_html_codegen_macros::emitter;
use swc_html_utils::HTML_ENTITIES;
use writer::HtmlWriter;
pub use self::emit::*;
use self::{ctx::Ctx, list::ListFormat};
#[macro_use]
mod macros;
mod ctx;
mod emit;
mod list;
pub mod writer;
#[derive(Debug, Clone, Default)]
pub struct CodegenConfig<'a> {
pub minify: bool,
pub scripting_enabled: bool,
/// Should be used only for `DocumentFragment` code generation
pub context_element: Option<&'a Element>,
/// Don't print optional tags (only when `minify` enabled)
/// By default `true` when `minify` enabled, otherwise `false`
pub tag_omission: Option<bool>,
/// Making SVG and MathML elements self-closing where possible (only when
/// `minify` enabled) By default `false` when `minify` enabled,
/// otherwise `true`
pub self_closing_void_elements: Option<bool>,
/// Always print quotes or remove them where possible (only when `minify`
/// enabled) By default `false` when `minify` enabled, otherwise `true`
pub quotes: Option<bool>,
}
enum TagOmissionParent<'a> {
Document(&'a Document),
DocumentFragment(&'a DocumentFragment),
Element(&'a Element),
}
#[derive(Debug)]
pub struct CodeGenerator<'a, W>
where
W: HtmlWriter,
{
wr: W,
config: CodegenConfig<'a>,
ctx: Ctx,
// For legacy `<plaintext>`
is_plaintext: bool,
tag_omission: bool,
self_closing_void_elements: bool,
quotes: bool,
}
impl<'a, W> CodeGenerator<'a, W>
where
W: HtmlWriter,
{
pub fn new(wr: W, config: CodegenConfig<'a>) -> Self {
let tag_omission = config.tag_omission.unwrap_or(config.minify);
let self_closing_void_elements = config.tag_omission.unwrap_or(!config.minify);
let quotes = config.quotes.unwrap_or(!config.minify);
CodeGenerator {
wr,
config,
ctx: Default::default(),
is_plaintext: false,
tag_omission,
self_closing_void_elements,
quotes,
}
}
#[emitter]
fn emit_document(&mut self, n: &Document) -> Result {
if self.tag_omission {
self.emit_list_for_tag_omission(TagOmissionParent::Document(n))?;
} else {
self.emit_list(&n.children, ListFormat::NotDelimited)?;
}
}
#[emitter]
fn emit_document_fragment(&mut self, n: &DocumentFragment) -> Result {
let ctx = if let Some(context_element) = &self.config.context_element {
self.create_context_for_element(context_element)
} else {
Default::default()
};
if self.tag_omission {
self.with_ctx(ctx)
.emit_list_for_tag_omission(TagOmissionParent::DocumentFragment(n))?;
} else {
self.with_ctx(ctx)
.emit_list(&n.children, ListFormat::NotDelimited)?;
}
}
#[emitter]
fn emit_child(&mut self, n: &Child) -> Result {
match n {
Child::DocumentType(n) => emit!(self, n),
Child::Element(n) => emit!(self, n),
Child::Text(n) => emit!(self, n),
Child::Comment(n) => emit!(self, n),
}
}
#[emitter]
fn emit_document_doctype(&mut self, n: &DocumentType) -> Result {
let mut doctype = String::with_capacity(
10 + if let Some(name) = &n.name {
name.len() + 1
} else {
0
} + if let Some(public_id) = &n.public_id {
let mut len = public_id.len() + 10;
if let Some(system_id) = &n.system_id {
len += system_id.len() + 3
}
len
} else if let Some(system_id) = &n.system_id {
system_id.len() + 10
} else {
0
},
);
doctype.push('<');
doctype.push('!');
if self.config.minify {
doctype.push_str("doctype");
} else {
doctype.push_str("DOCTYPE");
}
if let Some(name) = &n.name {
doctype.push(' ');
doctype.push_str(name);
}
if let Some(public_id) = &n.public_id {
doctype.push(' ');
if self.config.minify {
doctype.push_str("public");
} else {
doctype.push_str("PUBLIC");
}
doctype.push(' ');
let public_id_quote = if public_id.contains('"') { '\'' } else { '"' };
doctype.push(public_id_quote);
doctype.push_str(public_id);
doctype.push(public_id_quote);
if let Some(system_id) = &n.system_id {
doctype.push(' ');
let system_id_quote = if system_id.contains('"') { '\'' } else { '"' };
doctype.push(system_id_quote);
doctype.push_str(system_id);
doctype.push(system_id_quote);
}
} else if let Some(system_id) = &n.system_id {
doctype.push(' ');
if self.config.minify {
doctype.push_str("system");
} else {
doctype.push_str("SYSTEM");
}
doctype.push(' ');
let system_id_quote = if system_id.contains('"') { '\'' } else { '"' };
doctype.push(system_id_quote);
doctype.push_str(system_id);
doctype.push(system_id_quote);
}
doctype.push('>');
write_multiline_raw!(self, n.span, &doctype);
formatting_newline!(self);
}
fn basic_emit_element(
&mut self,
n: &Element,
parent: Option<&Element>,
prev: Option<&Child>,
next: Option<&Child>,
) -> Result {
if self.is_plaintext {
return Ok(());
}
let has_attributes = !n.attributes.is_empty();
let can_omit_start_tag = self.tag_omission
&& !has_attributes
&& n.namespace == Namespace::HTML
&& match &*n.tag_name {
// Tag omission in text/html:
// An html element's start tag can be omitted if the first thing inside the html
// element is not a comment.
"html" if !matches!(n.children.first(), Some(Child::Comment(..))) => true,
// A head element's start tag can be omitted if the element is empty, or if the
// first thing inside the head element is an element.
"head"
if n.children.is_empty()
|| matches!(n.children.first(), Some(Child::Element(..))) =>
{
true
}
// A body element's start tag can be omitted if the element is empty, or if the
// first thing inside the body element is not ASCII whitespace or a comment, except
// if the first thing inside the body element would be parsed differently outside.
"body"
if n.children.is_empty()
|| (match n.children.first() {
Some(Child::Text(text))
if text.data.len() > 0
&& text.data.chars().next().unwrap().is_ascii_whitespace() =>
{
false
}
Some(Child::Comment(..)) => false,
Some(Child::Element(Element {
namespace,
tag_name,
..
})) if *namespace == Namespace::HTML
&& matches!(
&**tag_name,
"base"
| "basefont"
| "bgsound"
| "frameset"
| "link"
| "meta"
| "noframes"
| "noscript"
| "script"
| "style"
| "template"
| "title"
) =>
{
false
}
_ => true,
}) =>
{
true
}
// A colgroup element's start tag can be omitted if the first thing inside the
// colgroup element is a col element, and if the element is not immediately preceded
// by another colgroup element whose end tag has been omitted. (It can't be omitted
// if the element is empty.)
"colgroup"
if match n.children.first() {
Some(Child::Element(element))
if element.namespace == Namespace::HTML
&& element.tag_name == "col" =>
{
!matches!(prev, Some(Child::Element(element)) if element.namespace == Namespace::HTML
&& element.tag_name == "colgroup")
}
_ => false,
} =>
{
true
}
// A tbody element's start tag can be omitted if the first thing inside the tbody
// element is a tr element, and if the element is not immediately preceded by a
// tbody, thead, or tfoot element whose end tag has been omitted. (It can't be
// omitted if the element is empty.)
"tbody"
if match n.children.first() {
Some(Child::Element(element))
if element.namespace == Namespace::HTML && element.tag_name == "tr" =>
{
!matches!(prev, Some(Child::Element(element)) if element.namespace == Namespace::HTML
&& matches!(
&*element.tag_name,
"tbody" | "thead" | "tfoot"
))
}
_ => false,
} =>
{
true
}
_ => false,
};
let is_void_element = match n.namespace {
Namespace::HTML => matches!(
&*n.tag_name,
"area"
| "base"
| "basefont"
| "bgsound"
| "br"
| "col"
| "embed"
| "frame"
| "hr"
| "img"
| "input"
| "keygen"
| "link"
| "meta"
| "param"
| "source"
| "track"
| "wbr"
),
Namespace::SVG => n.children.is_empty(),
Namespace::MATHML => n.children.is_empty(),
_ => false,
};
if !can_omit_start_tag {
write_raw!(self, "<");
write_raw!(self, &n.tag_name);
if has_attributes {
space!(self);
self.emit_list(&n.attributes, ListFormat::SpaceDelimited)?;
}
if (matches!(n.namespace, Namespace::SVG | Namespace::MATHML) && is_void_element)
|| (self.self_closing_void_elements
&& n.is_self_closing
&& is_void_element
&& matches!(n.namespace, Namespace::HTML))
{
if self.config.minify {
let need_space = match n.attributes.last() {
Some(Attribute {
value: Some(value), ..
}) => !value.chars().any(|c| match c {
c if c.is_ascii_whitespace() => true,
'`' | '=' | '<' | '>' | '"' | '\'' => true,
_ => false,
}),
_ => false,
};
if need_space {
write_raw!(self, " ");
}
} else {
write_raw!(self, " ");
}
write_raw!(self, "/");
}
write_raw!(self, ">");
if !self.config.minify && n.namespace == Namespace::HTML && n.tag_name == "html" {
newline!(self);
}
}
if is_void_element {
return Ok(());
}
if !self.is_plaintext {
self.is_plaintext = matches!(&*n.tag_name, "plaintext");
}
if let Some(content) = &n.content {
emit!(self, content);
} else if !n.children.is_empty() {
let ctx = self.create_context_for_element(n);
let need_extra_newline =
n.namespace == Namespace::HTML && matches!(&*n.tag_name, "textarea" | "pre");
if need_extra_newline {
if let Some(Child::Text(Text { data, .. })) = &n.children.first() {
if data.contains('\n') {
newline!(self);
} else {
formatting_newline!(self);
}
}
}
if self.tag_omission {
self.with_ctx(ctx)
.emit_list_for_tag_omission(TagOmissionParent::Element(n))?;
} else {
self.with_ctx(ctx)
.emit_list(&n.children, ListFormat::NotDelimited)?;
}
}
let can_omit_end_tag = self.is_plaintext
|| (self.tag_omission
&& n.namespace == Namespace::HTML
&& match &*n.tag_name {
// Tag omission in text/html:
// An html element's end tag can be omitted if the html element is not
// immediately followed by a comment.
//
// A body element's end tag can be omitted if the body element is not
// immediately followed by a comment.
"html" | "body" => !matches!(next, Some(Child::Comment(..))),
// A head element's end tag can be omitted if the head element is not
// immediately followed by ASCII whitespace or a comment.
"head" => match next {
Some(Child::Text(text))
if text.data.chars().next().unwrap().is_ascii_whitespace() =>
{
false
}
Some(Child::Comment(..)) => false,
_ => true,
},
// A p element's end tag can be omitted if the p element is immediately followed
// by an address, article, aside, blockquote, details, div, dl, fieldset,
// figcaption, figure, footer, form, h1, h2, h3, h4, h5, h6, header, hgroup, hr,
// main, menu, nav, ol, p, pre, section, table, or ul element, or if there is no
// more content in the parent element and the parent element is an HTML element
// that is not an a, audio, del, ins, map, noscript, or video element, or an
// autonomous custom element.
"p" => match next {
Some(Child::Element(Element {
namespace,
tag_name,
..
})) if *namespace == Namespace::HTML
&& matches!(
&**tag_name,
"address"
| "article"
| "aside"
| "blockquote"
| "details"
| "div"
| "dl"
| "fieldset"
| "figcaption"
| "figure"
| "footer"
| "form"
| "h1"
| "h2"
| "h3"
| "h4"
| "h5"
| "h6"
| "header"
| "hgroup"
| "hr"
| "main"
| "menu"
| "nav"
| "ol"
| "p"
| "pre"
| "section"
| "table"
| "ul"
) =>
{
true
}
None if match parent {
Some(Element {
namespace,
tag_name,
..
}) if is_html_tag_name(*namespace, tag_name)
&& !matches!(
&**tag_name,
"a" | "audio"
| "acronym"
| "big"
| "del"
| "font"
| "ins"
| "tt"
| "strike"
| "map"
| "noscript"
| "video"
| "kbd"
| "rbc"
) =>
{
true
}
_ => false,
} =>
{
true
}
_ => false,
},
// An li element's end tag can be omitted if the li element is immediately
// followed by another li element or if there is no more content in the parent
// element.
"li" if match parent {
Some(Element {
namespace,
tag_name,
..
}) if *namespace == Namespace::HTML
&& matches!(&**tag_name, "ul" | "ol" | "menu") =>
{
true
}
_ => false,
} =>
{
match next {
Some(Child::Element(Element {
namespace,
tag_name,
..
})) if *namespace == Namespace::HTML && *tag_name == "li" => true,
None => true,
_ => false,
}
}
// A dt element's end tag can be omitted if the dt element is immediately
// followed by another dt element or a dd element.
"dt" => match next {
Some(Child::Element(Element {
namespace,
tag_name,
..
})) if *namespace == Namespace::HTML
&& (*tag_name == "dt" || *tag_name == "dd") =>
{
true
}
_ => false,
},
// A dd element's end tag can be omitted if the dd element is immediately
// followed by another dd element or a dt element, or if there is no more
// content in the parent element.
"dd" => match next {
Some(Child::Element(Element {
namespace,
tag_name,
..
})) if *namespace == Namespace::HTML
&& (*tag_name == "dd" || *tag_name == "dt") =>
{
true
}
None => true,
_ => false,
},
// An rt element's end tag can be omitted if the rt element is immediately
// followed by an rt or rp element, or if there is no more content in the parent
// element.
//
// An rp element's end tag can be omitted if the rp element is immediately
// followed by an rt or rp element, or if there is no more content in the parent
// element.
"rt" | "rp" => match next {
Some(Child::Element(Element {
namespace,
tag_name,
..
})) if *namespace == Namespace::HTML
&& (*tag_name == "rt" || *tag_name == "rp") =>
{
true
}
None => true,
_ => false,
},
// The end tag can be omitted if the element is immediately followed by an <rt>,
// <rtc>, or <rp> element or another <rb> element, or if there is no more
// content in the parent element.
"rb" => match next {
Some(Child::Element(Element {
namespace,
tag_name,
..
})) if *namespace == Namespace::HTML
&& (*tag_name == "rt"
|| *tag_name == "rtc"
|| *tag_name == "rp"
|| *tag_name == "rb") =>
{
true
}
None => true,
_ => false,
},
// The closing tag can be omitted if it is immediately followed by a <rb>,
// <rtc> or <rt> element opening tag or by its parent
// closing tag.
"rtc" => match next {
Some(Child::Element(Element {
namespace,
tag_name,
..
})) if *namespace == Namespace::HTML
&& (*tag_name == "rb" || *tag_name == "rtc" || *tag_name == "rt") =>
{
true
}
None => true,
_ => false,
},
// An optgroup element's end tag can be omitted if the optgroup element is
// immediately followed by another optgroup element, or if there is no more
// content in the parent element.
"optgroup" => match next {
Some(Child::Element(Element {
namespace,
tag_name,
..
})) if *namespace == Namespace::HTML && *tag_name == "optgroup" => true,
None => true,
_ => false,
},
// An option element's end tag can be omitted if the option element is
// immediately followed by another option element, or if it is immediately
// followed by an optgroup element, or if there is no more content in the parent
// element.
"option" => match next {
Some(Child::Element(Element {
namespace,
tag_name,
..
})) if *namespace == Namespace::HTML
&& (*tag_name == "option" || *tag_name == "optgroup") =>
{
true
}
None => true,
_ => false,
},
// A caption element's end tag can be omitted if the caption element is not
// immediately followed by ASCII whitespace or a comment.
//
// A colgroup element's end tag can be omitted if the colgroup element is not
// immediately followed by ASCII whitespace or a comment.
"caption" | "colgroup" => match next {
Some(Child::Text(text))
if text.data.chars().next().unwrap().is_ascii_whitespace() =>
{
false
}
Some(Child::Comment(..)) => false,
_ => true,
},
// A tbody element's end tag can be omitted if the tbody element is immediately
// followed by a tbody or tfoot element, or if there is no more content in the
// parent element.
"tbody" => match next {
Some(Child::Element(Element {
namespace,
tag_name,
..
})) if *namespace == Namespace::HTML
&& (*tag_name == "tbody" || *tag_name == "tfoot") =>
{
true
}
None => true,
_ => false,
},
// A thead element's end tag can be omitted if the thead element is immediately
// followed by a tbody or tfoot element.
"thead" => match next {
Some(Child::Element(Element {
namespace,
tag_name,
..
})) if *namespace == Namespace::HTML
&& (*tag_name == "tbody" || *tag_name == "tfoot") =>
{
true
}
_ => false,
},
// A tfoot element's end tag can be omitted if there is no more content in the
// parent element.
"tfoot" => next.is_none(),
// A tr element's end tag can be omitted if the tr element is immediately
// followed by another tr element, or if there is no more content in the parent
// element.
"tr" => match next {
Some(Child::Element(Element {
namespace,
tag_name,
..
})) if *namespace == Namespace::HTML && *tag_name == "tr" => true,
None => true,
_ => false,
},
// A th element's end tag can be omitted if the th element is immediately
// followed by a td or th element, or if there is no more content in the parent
// element.
"td" | "th" => match next {
Some(Child::Element(Element {
namespace,
tag_name,
..
})) if *namespace == Namespace::HTML
&& (*tag_name == "td" || *tag_name == "th") =>
{
true
}
None => true,
_ => false,
},
_ => false,
});
if can_omit_end_tag {
return Ok(());
}
write_raw!(self, "<");
write_raw!(self, "/");
write_raw!(self, &n.tag_name);
write_raw!(self, ">");
Ok(())
}
#[emitter]
fn emit_element(&mut self, n: &Element) -> Result {
self.basic_emit_element(n, None, None, None)?;
}
#[emitter]
fn emit_attribute(&mut self, n: &Attribute) -> Result {
let mut attribute = String::with_capacity(
if let Some(prefix) = &n.prefix {
prefix.len() + 1
} else {
0
} + n.name.len()
+ if let Some(value) = &n.value {
value.len() + 1
} else {
0
},
);
if let Some(prefix) = &n.prefix {
attribute.push_str(prefix);
attribute.push(':');
}
attribute.push_str(&n.name);
if let Some(value) = &n.value {
attribute.push('=');
if self.config.minify {
let (minifier, quote) = minify_attribute_value(value, self.quotes);
if let Some(quote) = quote {
attribute.push(quote);
}
attribute.push_str(&minifier);
if let Some(quote) = quote {
attribute.push(quote);
}
} else {
let normalized = escape_string(value, true);
attribute.push('"');
attribute.push_str(&normalized);
attribute.push('"');
}
}
write_multiline_raw!(self, n.span, &attribute);
}
#[emitter]
fn emit_text(&mut self, n: &Text) -> Result {
if self.ctx.need_escape_text {
if self.config.minify {
write_multiline_raw!(self, n.span, &minify_text(&n.data));
} else {
write_multiline_raw!(self, n.span, &escape_string(&n.data, false));
}
} else {
write_multiline_raw!(self, n.span, &n.data);
}
}
#[emitter]
fn emit_comment(&mut self, n: &Comment) -> Result {
let mut comment = String::with_capacity(n.data.len() + 7);
comment.push_str("<!--");
comment.push_str(&n.data);
comment.push_str("-->");
write_multiline_raw!(self, n.span, &comment);
}
fn create_context_for_element(&self, n: &Element) -> Ctx {
let need_escape_text = match &*n.tag_name {
"style" | "script" | "xmp" | "iframe" | "noembed" | "noframes" | "plaintext" => false,
"noscript" => !self.config.scripting_enabled,
_ if self.is_plaintext => false,
_ => true,
};
Ctx {
need_escape_text,
..self.ctx
}
}
fn emit_list_for_tag_omission(&mut self, parent: TagOmissionParent) -> Result {
let nodes = match &parent {
TagOmissionParent::Document(document) => &document.children,
TagOmissionParent::DocumentFragment(document_fragment) => &document_fragment.children,
TagOmissionParent::Element(element) => &element.children,
};
let parent = match parent {
TagOmissionParent::Element(element) => Some(element),
_ => None,
};
for (idx, node) in nodes.iter().enumerate() {
match node {
Child::Element(element) => {
let prev = if idx > 0 { nodes.get(idx - 1) } else { None };
let next = nodes.get(idx + 1);
self.basic_emit_element(element, parent, prev, next)?;
}
_ => {
emit!(self, node)
}
}
}
Ok(())
}
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::SpaceDelimited => {
space!(self)
}
_ => unreachable!(),
}
Ok(())
}
}
#[allow(clippy::unused_peekable)]
fn minify_attribute_value(value: &str, quotes: bool) -> (Cow<'_, str>, Option<char>) {
if value.is_empty() {
return (Cow::Borrowed(value), Some('"'));
}
// Fast-path
if !quotes
&& value.chars().all(|c| match c {
'&' | '`' | '=' | '<' | '>' | '"' | '\'' => false,
c if c.is_ascii_whitespace() => false,
_ => true,
})
{
return (Cow::Borrowed(value), None);
}
let mut minified = String::with_capacity(value.len());
let mut unquoted = true;
let mut dq = 0;
let mut sq = 0;
let mut chars = value.chars().peekable();
while let Some(c) = chars.next() {
match c {
'&' => {
let next = chars.next();
if let Some(next) = next {
if matches!(next, '#' | 'a'..='z' | 'A'..='Z') {
minified.push_str(&minify_amp(next, &mut chars));
} else {
minified.push('&');
minified.push(next);
}
} else {
minified.push('&');
}
continue;
}
c if c.is_ascii_whitespace() => {
unquoted = false;
}
'`' | '=' | '<' | '>' => {
unquoted = false;
}
'"' => {
unquoted = false;
dq += 1;
}
'\'' => {
unquoted = false;
sq += 1;
}
_ => {}
};
minified.push(c);
}
if !quotes && unquoted {
return (Cow::Owned(minified), None);
}
if dq > sq {
(Cow::Owned(minified.replace('\'', "'")), Some('\''))
} else {
(Cow::Owned(minified.replace('"', """)), Some('"'))
}
}
#[allow(clippy::unused_peekable)]
fn minify_text(value: &str) -> Cow<'_, str> {
// Fast-path
if value.is_empty() {
return Cow::Borrowed(value);
}
// Fast-path
if value.chars().all(|c| match c {
'&' | '<' => false,
_ => true,
}) {
return Cow::Borrowed(value);
}
let mut result = String::with_capacity(value.len());
let mut chars = value.chars().peekable();
while let Some(c) = chars.next() {
match c {
'&' => {
let next = chars.next();
if let Some(next) = next {
if matches!(next, '#' | 'a'..='z' | 'A'..='Z') {
result.push_str(&minify_amp(next, &mut chars));
} else {
result.push('&');
result.push(next);
}
} else {
result.push('&');
}
}
'<' => {
result.push_str("<");
}
_ => result.push(c),
}
}
Cow::Owned(result)
}
fn minify_amp(next: char, chars: &mut Peekable<Chars>) -> String {
let mut result = String::with_capacity(7);
match next {
hash @ '#' => {
match chars.next() {
// HTML CODE
// Prevent `&#38;` -> `&`
Some(number @ '0'..='9') => {
result.push_str("&");
result.push(hash);
result.push(number);
}
Some(x @ 'x' | x @ 'X') => {
match chars.peek() {
// HEX CODE
// Prevent `&#x38;` -> `8`
Some(c) if c.is_ascii_hexdigit() => {
result.push_str("&");
result.push(hash);
result.push(x);
}
_ => {
result.push('&');
result.push(hash);
result.push(x);
}
}
}
any => {
result.push('&');
result.push(hash);
if let Some(any) = any {
result.push(any);
}
}
}
}
// Named entity
// Prevent `&current` -> `¤t`
c @ 'a'..='z' | c @ 'A'..='Z' => {
let mut entity_temporary_buffer = String::with_capacity(33);
entity_temporary_buffer.push('&');
entity_temporary_buffer.push(c);
let mut found_entity = false;
// No need to validate input, because we reset position if nothing was found
for c in chars {
entity_temporary_buffer.push(c);
if HTML_ENTITIES.get(&entity_temporary_buffer).is_some() {
found_entity = true;
break;
} else {
// We stop when:
//
// - not ascii alphanumeric
// - we consume more characters than the longest entity
if !c.is_ascii_alphanumeric() || entity_temporary_buffer.len() > 32 {
break;
}
}
}
if found_entity {
result.push_str("&");
result.push_str(&entity_temporary_buffer[1..]);
} else {
result.push('&');
result.push_str(&entity_temporary_buffer[1..]);
}
}
any => {
result.push('&');
result.push(any);
}
}
result
}
// Escaping a string (for the purposes of the algorithm above) consists of
// running the following steps:
//
// 1. Replace any occurrence of the "&" character by the string "&".
//
// 2. Replace any occurrences of the U+00A0 NO-BREAK SPACE character by the
// string " ".
//
// 3. If the algorithm was invoked in the attribute mode, replace any
// occurrences of the """ character by the string """.
//
// 4. If the algorithm was not invoked in the attribute mode, replace any
// occurrences of the "<" character by the string "<", and any occurrences of
// the ">" character by the string ">".
fn escape_string(value: &str, is_attribute_mode: bool) -> Cow<'_, str> {
// Fast-path
if value.is_empty() {
return Cow::Borrowed(value);
}
if value.chars().all(|c| match c {
'&' | '\u{00A0}' => false,
'"' if is_attribute_mode => false,
'<' if !is_attribute_mode => false,
'>' if !is_attribute_mode => false,
_ => true,
}) {
return Cow::Borrowed(value);
}
let mut result = String::with_capacity(value.len());
for c in value.chars() {
match c {
'&' => {
result.push_str("&");
}
'\u{00A0}' => result.push_str(" "),
'"' if is_attribute_mode => result.push_str("""),
'<' if !is_attribute_mode => {
result.push_str("<");
}
'>' if !is_attribute_mode => {
result.push_str(">");
}
_ => result.push(c),
}
}
Cow::Owned(result)
}
fn is_html_tag_name(namespace: Namespace, tag_name: &Atom) -> bool {
if namespace != Namespace::HTML {
return false;
}
matches!(
&**tag_name,
"a" | "abbr"
| "acronym"
| "address"
| "applet"
| "area"
| "article"
| "aside"
| "audio"
| "b"
| "base"
| "basefont"
| "bdi"
| "bdo"
| "big"
| "blockquote"
| "body"
| "br"
| "button"
| "canvas"
| "caption"
| "center"
| "cite"
| "code"
| "col"
| "colgroup"
| "data"
| "datalist"
| "dd"
| "del"
| "details"
| "dfn"
| "dialog"
| "dir"
| "div"
| "dl"
| "dt"
| "em"
| "embed"
| "fieldset"
| "figcaption"
| "figure"
| "font"
| "footer"
| "form"
| "frame"
| "frameset"
| "h1"
| "h2"
| "h3"
| "h4"
| "h5"
| "h6"
| "head"
| "header"
| "hgroup"
| "hr"
| "html"
| "i"
| "iframe"
| "image"
| "img"
| "input"
| "ins"
| "isindex"
| "kbd"
| "keygen"
| "label"
| "legend"
| "li"
| "link"
| "listing"
| "main"
| "map"
| "mark"
| "marquee"
| "menu"
// Removed from spec, but we keep here to track it
// | "menuitem"
| "meta"
| "meter"
| "nav"
| "nobr"
| "noembed"
| "noframes"
| "noscript"
| "object"
| "ol"
| "optgroup"
| "option"
| "output"
| "p"
| "param"
| "picture"
| "plaintext"
| "pre"
| "progress"
| "q"
| "rb"
| "rbc"
| "rp"
| "rt"
| "rtc"
| "ruby"
| "s"
| "samp"
| "script"
| "section"
| "select"
| "small"
| "source"
| "span"
| "strike"
| "strong"
| "style"
| "sub"
| "summary"
| "sup"
| "table"
| "tbody"
| "td"
| "template"
| "textarea"
| "tfoot"
| "th"
| "thead"
| "time"
| "title"
| "tr"
| "track"
| "tt"
| "u"
| "ul"
| "var"
| "video"
| "wbr"
| "xmp"
)
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/src/list.rs | Rust | #![allow(non_upper_case_globals)]
use bitflags::bitflags;
bitflags! {
#[derive(PartialEq, Eq, Copy, Clone)]
pub struct ListFormat: u16 {
const None = 0;
// Line separators
/// Prints the list on a single line (default).
const SingleLine = 0;
/// Prints the list on multiple lines.
const MultiLine = 1 << 0;
/// Prints the list using line preservation if possible.
const PreserveLines = 1 << 1;
const LinesMask = Self::MultiLine.bits() | Self::PreserveLines.bits();
// Delimiters
const NotDelimited = 0;
const SpaceDelimited = 1 << 2;
const DelimitersMask = Self::SpaceDelimited.bits();
}
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/src/macros.rs | Rust | 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_multiline_raw {
($g:expr,$span:expr,$n:expr) => {{
$g.wr.write_multiline_raw($span, $n)?;
}};
}
macro_rules! newline {
($g:expr) => {{
$g.wr.write_newline()?;
}};
}
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! 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();
// }
// }};
// }
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/src/writer/basic.rs | Rust | use std::fmt::{Result, Write};
use rustc_hash::FxHashSet;
use swc_common::{BytePos, LineCol, Span};
use super::HtmlWriter;
#[derive(Clone, Copy, PartialEq, Eq, Debug, Default)]
pub enum IndentType {
Tab,
#[default]
Space,
}
#[derive(Clone, Copy, PartialEq, Eq, Debug, Default)]
pub enum LineFeed {
#[default]
LF,
CRLF,
}
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)>>,
srcmap_done: FxHashSet<(BytePos, u32, u32)>,
/// Used to avoid including whitespaces created by indention.
pending_srcmap: Option<BytePos>,
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,
pending_srcmap: Default::default(),
srcmap_done: Default::default(),
}
}
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 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(pending) = self.pending_srcmap.take() {
self.srcmap(pending);
}
}
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 srcmap(&mut self, byte_pos: BytePos) {
if byte_pos.is_dummy() {
return;
}
if let Some(ref mut srcmap) = self.srcmap {
if self
.srcmap_done
.insert((byte_pos, self.line as _, self.col as _))
{
let loc = LineCol {
line: self.line as _,
col: self.col as _,
};
srcmap.push((byte_pos, loc));
}
}
}
}
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 {
let pending = self.pending_srcmap.take();
if !self.line_start {
self.raw_write(self.linefeed)?;
self.line += 1;
self.col = 0;
self.line_start = true;
if let Some(pending) = pending {
self.srcmap(pending)
}
}
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_multiline_raw(&mut self, span: Span, s: &str) -> Result {
if !s.is_empty() {
if !span.is_dummy() {
self.srcmap(span.lo())
}
self.write(None, s)?;
let line_start_of_s = compute_line_starts(s);
if line_start_of_s.len() > 1 {
self.line = self.line + line_start_of_s.len() - 1;
let last_line_byte_index = line_start_of_s.last().cloned().unwrap_or(0);
self.col = s[last_line_byte_index..].chars().count();
}
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;
}
}
fn compute_line_starts(s: &str) -> Vec<usize> {
let mut res = Vec::new();
let mut line_start = 0;
let mut chars = s.char_indices().peekable();
while let Some((pos, c)) = chars.next() {
match c {
'\r' => {
if let Some(&(_, '\n')) = chars.peek() {
let _ = chars.next();
}
}
'\n' => {
res.push(line_start);
line_start = pos + 1;
}
_ => {}
}
}
// Last line.
res.push(line_start);
res
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/src/writer/mod.rs | Rust | 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_multiline_raw(&mut self, span: Span, s: &str) -> Result;
fn increase_indent(&mut self);
fn decrease_indent(&mut self);
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/document_fragment/basic/input.html | HTML | <div><h1>Test</h1><p>Test</p></div> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/document_fragment/basic/output.html | HTML | <div><h1>Test</h1><p>Test</p></div> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/document_fragment/basic/output.min.html | HTML | <div><h1>Test</h1><p>Test</div> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/document_fragment/element/style/input.html | HTML | <div>Test &</div>
<div>Test &</div>
<style>
a::before {
content: "&";
color: red;
}
</style> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/document_fragment/element/style/output.html | HTML | <div>Test &</div>
<div>Test &</div>
<style>
a::before {
content: "&";
color: red;
}
</style> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/document_fragment/element/style/output.min.html | HTML | <div>Test &</div>
<div>Test &</div>
<style>
a::before {
content: "&";
color: red;
}
</style> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture.rs | Rust | #![allow(clippy::needless_update)]
use std::{
mem::take,
path::{Path, PathBuf},
};
use swc_common::{FileName, Span};
use swc_html_ast::*;
use swc_html_codegen::{
writer::basic::{BasicHtmlWriter, BasicHtmlWriterConfig, IndentType, LineFeed},
CodeGenerator, CodegenConfig, Emit,
};
use swc_html_parser::{
parse_file_as_document, parse_file_as_document_fragment, parser::ParserConfig,
};
use swc_html_visit::{VisitMut, VisitMutWith};
use testing::{assert_eq, run_test2, NormalizedOutput};
fn print_document(
input: &Path,
parser_config: Option<ParserConfig>,
writer_config: Option<BasicHtmlWriterConfig>,
codegen_config: Option<CodegenConfig>,
) {
let dir = input.parent().unwrap();
let parser_config = parser_config.unwrap_or_default();
let writer_config = writer_config.unwrap_or_default();
let codegen_config = codegen_config.unwrap_or_default();
let output = if codegen_config.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();
let mut errors = Vec::new();
let mut document: Document =
parse_file_as_document(&fm, parser_config, &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, writer_config);
let mut gen = CodeGenerator::new(wr, codegen_config);
gen.emit(&document).unwrap();
let fm_output = cm.load_file(&output).unwrap();
NormalizedOutput::new_raw(html_str)
.compare_to_file(output)
.unwrap();
let mut errors = Vec::new();
let mut document_parsed_again =
parse_file_as_document(&fm_output, parser_config, &mut errors).map_err(|err| {
err.to_diagnostics(&handler).emit();
})?;
for error in take(&mut errors) {
error.to_diagnostics(&handler).emit();
}
document.visit_mut_with(&mut DropSpan);
document_parsed_again.visit_mut_with(&mut DropSpan);
assert_eq!(document, document_parsed_again);
Ok(())
})
.unwrap();
}
fn print_document_fragment(
input: &Path,
context_element: Element,
parser_config: Option<ParserConfig>,
writer_config: Option<BasicHtmlWriterConfig>,
codegen_config: Option<CodegenConfig>,
) {
let dir = input.parent().unwrap();
let parser_config = parser_config.unwrap_or_default();
let writer_config = writer_config.unwrap_or_default();
let codegen_config = codegen_config.unwrap_or_default();
let output = if codegen_config.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();
let mut errors = Vec::new();
let mut document_fragment = parse_file_as_document_fragment(
&fm,
&context_element,
DocumentMode::NoQuirks,
None,
parser_config,
&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, writer_config);
let mut gen = CodeGenerator::new(wr, codegen_config);
gen.emit(&document_fragment).unwrap();
let fm_output = cm.load_file(&output).unwrap();
NormalizedOutput::new_raw(html_str)
.compare_to_file(output)
.unwrap();
let mut errors = Vec::new();
let mut document_fragment_parsed_again = parse_file_as_document_fragment(
&fm_output,
&context_element,
DocumentMode::NoQuirks,
None,
parser_config,
&mut errors,
)
.map_err(|err| {
err.to_diagnostics(&handler).emit();
})?;
for error in take(&mut errors) {
error.to_diagnostics(&handler).emit();
}
document_fragment.visit_mut_with(&mut DropSpan);
document_fragment_parsed_again.visit_mut_with(&mut DropSpan);
assert_eq!(document_fragment, document_fragment_parsed_again);
Ok(())
})
.unwrap();
}
fn verify_document(
input: &Path,
parser_config: Option<ParserConfig>,
writer_config: Option<BasicHtmlWriterConfig>,
codegen_config: Option<CodegenConfig>,
ignore_errors: bool,
) {
let parser_config = parser_config.unwrap_or_default();
let writer_config = writer_config.unwrap_or_default();
let codegen_config = codegen_config.unwrap_or_default();
testing::run_test2(false, |cm, handler| {
let fm = cm.load_file(input).unwrap();
let mut errors = Vec::new();
let mut document =
parse_file_as_document(&fm, parser_config, &mut errors).map_err(|err| {
err.to_diagnostics(&handler).emit();
})?;
if !ignore_errors {
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, writer_config);
let mut gen = CodeGenerator::new(wr, codegen_config);
gen.emit(&document).unwrap();
let new_fm = cm.new_source_file(FileName::Anon.into(), html_str);
let mut parsed_errors = Vec::new();
let mut document_parsed_again =
parse_file_as_document(&new_fm, parser_config, &mut parsed_errors).map_err(|err| {
err.to_diagnostics(&handler).emit();
})?;
if !ignore_errors {
for err in parsed_errors {
err.to_diagnostics(&handler).emit();
}
}
document.visit_mut_with(&mut DropSpan);
document_parsed_again.visit_mut_with(&mut DropSpan);
assert_eq!(document, document_parsed_again);
Ok(())
})
.unwrap();
}
fn verify_document_fragment(
input: &Path,
context_element: Element,
parser_config: Option<ParserConfig>,
writer_config: Option<BasicHtmlWriterConfig>,
codegen_config: Option<CodegenConfig>,
ignore_errors: bool,
) {
let parser_config = parser_config.unwrap_or_default();
let writer_config = writer_config.unwrap_or_default();
let mut codegen_config = codegen_config.unwrap_or_default();
codegen_config.context_element = Some(&context_element);
testing::run_test2(false, |cm, handler| {
let fm = cm.load_file(input).unwrap();
let mut errors = Vec::new();
let mut document_fragment = parse_file_as_document_fragment(
&fm,
&context_element,
DocumentMode::NoQuirks,
None,
parser_config,
&mut errors,
)
.map_err(|err| {
err.to_diagnostics(&handler).emit();
})?;
if !ignore_errors {
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, writer_config);
let mut gen = CodeGenerator::new(wr, codegen_config);
gen.emit(&document_fragment).unwrap();
let new_fm = cm.new_source_file(FileName::Anon.into(), html_str);
let mut parsed_errors = Vec::new();
let mut document_fragment_parsed_again = parse_file_as_document_fragment(
&new_fm,
&context_element,
DocumentMode::NoQuirks,
None,
parser_config,
&mut parsed_errors,
)
.map_err(|err| {
err.to_diagnostics(&handler).emit();
})?;
if !ignore_errors {
for err in parsed_errors {
err.to_diagnostics(&handler).emit();
}
}
document_fragment.visit_mut_with(&mut DropSpan);
document_fragment_parsed_again.visit_mut_with(&mut DropSpan);
assert_eq!(document_fragment, document_fragment_parsed_again);
Ok(())
})
.unwrap();
}
struct DropSpan;
impl VisitMut for DropSpan {
fn visit_mut_document_type(&mut self, n: &mut DocumentType) {
n.visit_mut_children_with(self);
n.raw = None;
}
fn visit_mut_comment(&mut self, n: &mut Comment) {
n.visit_mut_children_with(self);
n.raw = None;
}
fn visit_mut_text(&mut self, n: &mut Text) {
n.visit_mut_children_with(self);
n.raw = None;
}
fn visit_mut_element(&mut self, n: &mut Element) {
n.visit_mut_children_with(self);
// In normal output we respect `is_self_closing`
// In minified output we always avoid end tag for SVG and MathML namespace
n.is_self_closing = Default::default();
}
fn visit_mut_attribute(&mut self, n: &mut Attribute) {
n.visit_mut_children_with(self);
n.raw_name = None;
n.raw_value = None;
}
fn visit_mut_span(&mut self, n: &mut Span) {
*n = Default::default()
}
}
#[testing::fixture("tests/fixture/**/input.html")]
fn test_document(input: PathBuf) {
print_document(
&input,
None,
None,
Some(CodegenConfig {
scripting_enabled: false,
minify: false,
..Default::default()
}),
);
print_document(
&input,
None,
None,
Some(CodegenConfig {
scripting_enabled: false,
minify: true,
..Default::default()
}),
);
}
#[testing::fixture("tests/document_fragment/**/input.html")]
fn test_document_fragment(input: PathBuf) {
let context_element = Element {
span: Default::default(),
tag_name: "template".into(),
namespace: Namespace::HTML,
attributes: Vec::new(),
is_self_closing: false,
children: Vec::new(),
content: None,
};
print_document_fragment(
&input,
context_element.clone(),
None,
None,
Some(CodegenConfig {
scripting_enabled: false,
minify: false,
..Default::default()
}),
);
print_document_fragment(
&input,
context_element,
None,
None,
Some(CodegenConfig {
scripting_enabled: false,
minify: true,
..Default::default()
}),
);
}
#[testing::fixture("tests/options/self_closing_void_elements/true/**/input.html")]
fn test_self_closing_void_elements_true(input: PathBuf) {
print_document(
&input,
None,
None,
Some(CodegenConfig {
scripting_enabled: false,
minify: false,
tag_omission: Some(false),
self_closing_void_elements: Some(true),
..Default::default()
}),
);
}
#[testing::fixture("tests/options/self_closing_void_elements/false/**/input.html")]
fn test_self_closing_void_elements_false(input: PathBuf) {
print_document(
&input,
None,
None,
Some(CodegenConfig {
scripting_enabled: false,
minify: false,
self_closing_void_elements: Some(false),
..Default::default()
}),
);
}
#[testing::fixture("tests/options/quotes/true/**/input.html")]
fn test_quotes_true(input: PathBuf) {
print_document(
&input,
None,
None,
Some(CodegenConfig {
scripting_enabled: false,
minify: true,
tag_omission: Some(false),
self_closing_void_elements: Some(true),
quotes: Some(true),
..Default::default()
}),
);
}
#[testing::fixture("tests/options/quotes/false/**/input.html")]
fn test_quotes_false(input: PathBuf) {
print_document(
&input,
None,
None,
Some(CodegenConfig {
scripting_enabled: false,
minify: true,
tag_omission: Some(false),
self_closing_void_elements: Some(true),
quotes: Some(false),
..Default::default()
}),
);
}
#[testing::fixture("tests/options/indent_type/**/input.html")]
fn test_indent_type_option(input: PathBuf) {
print_document(
&input,
None,
Some(BasicHtmlWriterConfig {
indent_type: IndentType::Tab,
indent_width: 2,
linefeed: LineFeed::default(),
}),
None,
);
}
#[testing::fixture("../swc_html_parser/tests/fixture/**/*.html")]
fn parser_verify(input: PathBuf) {
verify_document(&input, None, None, None, false);
verify_document(
&input,
None,
None,
Some(CodegenConfig {
scripting_enabled: false,
minify: true,
tag_omission: Some(false),
..Default::default()
}),
false,
);
verify_document(
&input,
None,
None,
Some(CodegenConfig {
scripting_enabled: false,
minify: true,
tag_omission: Some(true),
..Default::default()
}),
false,
);
}
#[testing::fixture(
"../swc_html_parser/tests/recovery/**/*.html",
exclude(
"document_type/bogus/input.html",
"document_type/wrong-name/input.html",
"text/cr-charref-novalid/input.html",
"element/foreign-context/input.html",
"element/a-4/input.html",
"element/b-3/input.html",
)
)]
fn parser_recovery_verify(input: PathBuf) {
verify_document(
&input,
None,
None,
Some(CodegenConfig {
scripting_enabled: false,
minify: true,
tag_omission: Some(false),
..Default::default()
}),
true,
);
verify_document(
&input,
None,
None,
Some(CodegenConfig {
scripting_enabled: false,
minify: true,
tag_omission: Some(true),
..Default::default()
}),
true,
);
}
// Tag omission only works for valid HTML documents (i.e. without errors)
static IGNORE_TAG_OMISSION: &[&str] = &[
"adoption01_dat.5.html",
"adoption01_dat.6.html",
"adoption01_dat.7.html",
"adoption01_dat.8.html",
"adoption02_dat.0.html",
"tests1_dat.68.html",
"tests1_dat.69.html",
"tests1_dat.70.html",
"tests1_dat.71.html",
"tests15_dat.0.html",
"tests15_dat.1.html",
"template_dat.68.html",
"tricky01_dat.6.html",
];
#[testing::fixture(
"../swc_html_parser/tests/html5lib-tests-fixture/**/*.html",
exclude(
"tests1_dat.30.html",
"tests1_dat.77.html",
"tests1_dat.90.html",
"tests1_dat.103.html",
"tests2_dat.12.html",
"tests16_dat.31.html",
"tests16_dat.32.html",
"tests16_dat.33.html",
"tests16_dat.34.html",
"tests16_dat.35.html",
"tests16_dat.36.html",
"tests16_dat.37.html",
"tests16_dat.48.html",
"tests16_dat.49.html",
"tests16_dat.50.html",
"tests16_dat.51.html",
"tests16_dat.52.html",
"tests16_dat.53.html",
"tests16_dat.130.html",
"tests16_dat.131.html",
"tests16_dat.132.html",
"tests16_dat.133.html",
"tests16_dat.134.html",
"tests16_dat.135.html",
"tests16_dat.136.html",
"tests16_dat.147.html",
"tests16_dat.148.html",
"tests16_dat.149.html",
"tests16_dat.150.html",
"tests16_dat.196.html",
"tests18_dat.7.html",
"tests18_dat.8.html",
"tests18_dat.9.html",
"tests18_dat.12.html",
"tests18_dat.21.html",
"tests19_dat.103.html",
"tests20_dat.42.html",
"tests26_dat.2.html",
"plain-text-unsafe_dat.0.html",
"template_dat.107.html",
)
)]
fn html5lib_tests_verify(input: PathBuf) {
let file_name = input.file_name().unwrap().to_string_lossy();
let scripting_enabled = file_name.contains("script_on");
let parser_config = ParserConfig {
scripting_enabled,
iframe_srcdoc: false,
allow_self_closing: false,
};
let codegen_config = CodegenConfig {
minify: false,
scripting_enabled,
..Default::default()
};
let minified_codegen_config = CodegenConfig {
minify: true,
tag_omission: Some(true),
scripting_enabled,
..Default::default()
};
let minified_codegen_config_no_tag_omission = CodegenConfig {
minify: true,
tag_omission: Some(false),
scripting_enabled,
..Default::default()
};
if file_name.contains("fragment") {
let mut context_element_namespace = Namespace::HTML;
let mut context_element_tag_name = "";
let mut splitted = file_name.split('.');
let index = splitted.clone().count() - 2;
let context_element = splitted
.nth(index)
.expect("failed to get context element from filename")
.replace("fragment_", "");
if context_element.contains('_') {
let mut splited = context_element.split('_');
if let Some(namespace) = splited.next() {
context_element_namespace = match namespace {
"math" => Namespace::MATHML,
"svg" => Namespace::SVG,
_ => {
unreachable!();
}
};
}
if let Some(tag_name) = splited.next() {
context_element_tag_name = tag_name;
}
} else {
context_element_tag_name = &context_element;
}
let context_element = Element {
span: Default::default(),
namespace: context_element_namespace,
tag_name: context_element_tag_name.into(),
attributes: Vec::new(),
is_self_closing: false,
children: Vec::new(),
content: None,
};
verify_document_fragment(
&input,
context_element.clone(),
Some(parser_config),
None,
Some(codegen_config),
true,
);
verify_document_fragment(
&input,
context_element.clone(),
Some(parser_config),
None,
Some(minified_codegen_config),
true,
);
verify_document_fragment(
&input,
context_element,
Some(parser_config),
None,
Some(minified_codegen_config_no_tag_omission),
true,
);
} else {
verify_document(
&input,
Some(parser_config),
None,
Some(codegen_config),
true,
);
verify_document(
&input,
Some(parser_config),
None,
Some(minified_codegen_config_no_tag_omission),
true,
);
let relative_path = input.to_string_lossy().replace('-', "_").replace('\\', "/");
if !IGNORE_TAG_OMISSION
.iter()
.any(|ignored| relative_path.contains(&**ignored))
{
verify_document(
&input,
Some(parser_config),
None,
Some(minified_codegen_config),
true,
);
}
}
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/attribute/input.html | HTML | <!DOCTYPE html>
<html>
<body>
<label><input type=checkbox checked name=cheese disabled> Cheese</label>
<label><input type=checkbox checked=checked name=cheese disabled=disabled> Cheese</label>
<label><input type='checkbox' checked name=cheese disabled=""> Cheese</label>
<label><input type= checkbox checked name = cheese disabled> Cheese</label>
<label><input type =checkbox checked name = cheese disabled> Cheese</label>
<label><input type = checkbox checked name = cheese disabled> Cheese</label>
<label ><input type='checkbox'checked name=cheese disabled="" > Cheese</label >
<p id="" class="" STYLE=" " title="
" lang="" dir="">x</p>
<p id='' class="" STYLE=' ' title='
' lang='' dir=''>x</p>
<p onclick="" ondblclick=" " onmousedown="" ONMOUSEUP="" onmouseover=" " onmousemove="" onmouseout="" onkeypress=
"
"
onkeydown=
"" onkeyup="">x</p>
<input onfocus="" onblur="" onchange=" " value=" boo ">
<input value="" name="foo">
<img src="" alt="">
<div data-foo class id style title lang dir onfocus onblur onchange onclick ondblclick onmousedown onmouseup onmouseover onmousemove onmouseout onkeypress onkeydown onkeyup></div>
<img src="" alt="">
<p class=" foo bar ">foo bar baz</p>
<p class=" foo ">foo bar baz</p>
<p class="
foo
">foo bar baz</p>
<p style=" color: red; background-color: rgb(100, 75, 200); "></p>
<p style="font-weight: bold ; "></p>
<br>x</br>
<p title="</p>">x</p>
<p title=" <!-- hello world --> ">x</p>
<p title=" <![CDATA[ \n\n foobar baz ]]> ">x</p>
<p foo-bar="baz">xxx</p>
<p foo:bar="baz">xxx</p>
<p foo.bar="baz">xxx</p>
<div><div><div><div><div><div><div><div><div><div>i'm 10 levels deep</div></div></div></div></div></div></div></div></div></div>
<a title="x"href=" ">foo</a>
<p id=""class=""title="">x</p>
<p x="x'">x</p>
<p x='x"'>x</p>
<a href="#"><p>Click me</p></a>
<span><button>Hit me</button></span>
<object type="image/svg+xml" data="image.svg"><div>[fallback image]</div></object>
<img class="user-image" src="http://adasdasdasd.cloudfront.net/users/2011/05/24/4asdasd/asdasd.jpg" />
<div data-foo></div>
<div data-foo=""></div>
<div data-foo=''></div>
<div data-foo="test"></div>
<div data-foo='test'></div>
<div data-test=foo class='bar'>test</div>
<div data-test='foo' class='bar'>test</div>
<div data-test="foo" class='bar'>test</div>
<div data-test="foo bar" class=bar>test</div>
<div data-test='foo " bar' class=bar>test</div>
<div data-test='foo ' bar' class=bar>test</div>
<div data-test="foo " bar" class=bar>test</div>
<div data-test="foo ' bar" class=bar>test</div>
<div data-test="foo """ bar" class=bar>test</div>
<div data-test="foo ''' bar" class=bar>test</div>
<div data-test='"foo"' class='bar'>test</div>
<div data-test="foo" class='bar'>test</div>
<div data-test='" foo "' class='bar'>test</div>
<div data-test=""foo"" class='bar'>test</div>
<div data-test="foo" class='bar'>test</div>
<div data-test="" foo "" class='bar'>test</div>
<div data-test=''foo'' class='bar'>test</div>
<div data-test="'foo'" class='bar'>test</div>
<div data-test='
foo
' class='bar'>test</div>
<div data-test='\foo' class='bar'>test</div>
<div data-test='\\foo' class='bar'>test</div>
<span title='test "with" &quot;'>test</span>
<span title='test "with" & quot'>test</span>
<span title='test "with" &test'>test</span>
<span title='test "with" &test'>test</span>
<span title='test "with" <'>test</span>
<span title='test "with" >'>test</span>
<span title=foo>Test</span>
<span title=foo<bar>Test</span>
<span title="foo=bar">Test</span>
<span title="foo>bar">Test</span>
<span title='foo"bar'>Test</span>
<span title="foo'bar">Test</span>
<div>
&quot;
</div>
<script>
let foo = "&";
</script>
<style>
.class::before {
content: "&";
}
</style>
<div>
foo & bar
foo&<i>bar</i>
foo&&& bar
</div>
<pre><code>Label current;
// Load effective address of current instruction into rcx.
__ leaq(rcx, Operand(&current));
__ bind(&current);
</code></pre>
<div>
&xxx; &xxx &thorn; &thorn &curren;t &current &current; &&
&gt
&unknown;
&current
&current;
&current
&current;
ø &osLash Ø
&ø &&osLash; &Ø
&ø &&osLash; &Ø
&oslash; &osLash; &Oslash;
&oslash; &osLash; &Oslash;
</div>
<a b=`''<<==/`/></a>
<a b=`'"<<==/`/></a>
<a b=`'"<<==/`/></a>
<a b=`'"""<<==/`/></a>
<a b='`"<<==/`/'></a>
<a b="`'<<==/`/"></a>
<a b="""></a>
<a b="'"></a>
<a b='''></a>
<a b='"'></a>
<a b='''''></a>
<a b="'''"></a>
<a b='"""'></a>
<a b="""""></a>
<a href=">"></a>
<a href="<"></a>
<a href="<"></a>
<a href="<"></a>
<a href=">"></a>
<a href=">"></a>
<a href=">"></a>
<a href=">"></a>
</body>
</html>
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/attribute/output.html | HTML | <!DOCTYPE html>
<html>
<head></head><body>
<label><input type="checkbox" checked name="cheese" disabled> Cheese</label>
<label><input type="checkbox" checked="checked" name="cheese" disabled="disabled"> Cheese</label>
<label><input type="checkbox" checked name="cheese" disabled=""> Cheese</label>
<label><input type="checkbox" checked name="cheese" disabled> Cheese</label>
<label><input type="checkbox" checked name="cheese" disabled> Cheese</label>
<label><input type="checkbox" checked name="cheese" disabled> Cheese</label>
<label><input type="checkbox" checked name="cheese" disabled=""> Cheese</label>
<p id="" class="" style=" " title="
" lang="" dir="">x</p>
<p id="" class="" style=" " title="
" lang="" dir="">x</p>
<p onclick="" ondblclick=" " onmousedown="" onmouseup="" onmouseover=" " onmousemove="" onmouseout="" onkeypress="
" onkeydown="" onkeyup="">x</p>
<input onfocus="" onblur="" onchange=" " value=" boo ">
<input value="" name="foo">
<img src="" alt="">
<div data-foo class id style title lang dir onfocus onblur onchange onclick ondblclick onmousedown onmouseup onmouseover onmousemove onmouseout onkeypress onkeydown onkeyup></div>
<img src="" alt="">
<p class=" foo bar ">foo bar baz</p>
<p class=" foo ">foo bar baz</p>
<p class="
foo
">foo bar baz</p>
<p style=" color: red; background-color: rgb(100, 75, 200); "></p>
<p style="font-weight: bold ; "></p>
<br>x<br>
<p title="</p>">x</p>
<p title=" <!-- hello world --> ">x</p>
<p title=" <![CDATA[ \n\n foobar baz ]]> ">x</p>
<p foo-bar="baz">xxx</p>
<p foo:bar="baz">xxx</p>
<p foo.bar="baz">xxx</p>
<div><div><div><div><div><div><div><div><div><div>i'm 10 levels deep</div></div></div></div></div></div></div></div></div></div>
<a title="x" href=" ">foo</a>
<p id="" class="" title="">x</p>
<p x="x'">x</p>
<p x="x"">x</p>
<a href="#"><p>Click me</p></a>
<span><button>Hit me</button></span>
<object type="image/svg+xml" data="image.svg"><div>[fallback image]</div></object>
<img class="user-image" src="http://adasdasdasd.cloudfront.net/users/2011/05/24/4asdasd/asdasd.jpg" />
<div data-foo></div>
<div data-foo=""></div>
<div data-foo=""></div>
<div data-foo="test"></div>
<div data-foo="test"></div>
<div data-test="foo" class="bar">test</div>
<div data-test="foo" class="bar">test</div>
<div data-test="foo" class="bar">test</div>
<div data-test="foo bar" class="bar">test</div>
<div data-test="foo " bar" class="bar">test</div>
<div data-test="foo ' bar" class="bar">test</div>
<div data-test="foo " bar" class="bar">test</div>
<div data-test="foo ' bar" class="bar">test</div>
<div data-test="foo """ bar" class="bar">test</div>
<div data-test="foo ''' bar" class="bar">test</div>
<div data-test=""foo"" class="bar">test</div>
<div data-test=""foo"" class="bar">test</div>
<div data-test="" foo "" class="bar">test</div>
<div data-test=""foo"" class="bar">test</div>
<div data-test=""foo"" class="bar">test</div>
<div data-test="" foo "" class="bar">test</div>
<div data-test="'foo'" class="bar">test</div>
<div data-test="'foo'" class="bar">test</div>
<div data-test="
foo
" class="bar">test</div>
<div data-test="\foo" class="bar">test</div>
<div data-test="\\foo" class="bar">test</div>
<span title="test "with" &quot;">test</span>
<span title="test "with" & quot">test</span>
<span title="test "with" &test">test</span>
<span title="test "with" &amptest">test</span>
<span title="test "with" <">test</span>
<span title="test "with" >">test</span>
<span title="foo">Test</span>
<span title="foo<bar">Test</span>
<span title="foo=bar">Test</span>
<span title="foo>bar">Test</span>
<span title="foo"bar">Test</span>
<span title="foo'bar">Test</span>
<div>
&quot;
</div>
<script>
let foo = "&";
</script>
<style>
.class::before {
content: "&";
}
</style>
<div>
foo & bar
foo&<i>bar</i>
foo&&& bar
</div>
<pre><code>Label current;
// Load effective address of current instruction into rcx.
__ leaq(rcx, Operand(&current));
__ bind(&current);
</code></pre>
<div>
&xxx; &xxx &thorn; &thorn &curren;t &current &current; &&
&gt
&unknown;
&current
&current;
&current
&current;
ø &osLash Ø
&ø &&osLash; &Ø
&ø &&osLash; &Ø
&oslash; &osLash; &Oslash;
&oslash; &osLash; &Oslash;
</div>
<a b="`''<<==/`/"></a>
<a b="`'"<<==/`/"></a>
<a b="`'"<<==/`/"></a>
<a b="`'"""<<==/`/"></a>
<a b="`"<<==/`/"></a>
<a b="`'<<==/`/"></a>
<a b="""></a>
<a b="'"></a>
<a b="'"></a>
<a b="""></a>
<a b="'''"></a>
<a b="'''"></a>
<a b="""""></a>
<a b="""""></a>
<a href=">"></a>
<a href="<"></a>
<a href="<"></a>
<a href="<"></a>
<a href=">"></a>
<a href=">"></a>
<a href=">"></a>
<a href=">"></a>
</body></html> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/attribute/output.min.html | HTML | <!doctype html><body>
<label><input type=checkbox checked name=cheese disabled> Cheese</label>
<label><input type=checkbox checked=checked name=cheese disabled=disabled> Cheese</label>
<label><input type=checkbox checked name=cheese disabled=""> Cheese</label>
<label><input type=checkbox checked name=cheese disabled> Cheese</label>
<label><input type=checkbox checked name=cheese disabled> Cheese</label>
<label><input type=checkbox checked name=cheese disabled> Cheese</label>
<label><input type=checkbox checked name=cheese disabled=""> Cheese</label>
<p id="" class="" style=" " title="
" lang="" dir="">x</p>
<p id="" class="" style=" " title="
" lang="" dir="">x</p>
<p onclick="" ondblclick=" " onmousedown="" onmouseup="" onmouseover=" " onmousemove="" onmouseout="" onkeypress="
" onkeydown="" onkeyup="">x</p>
<input onfocus="" onblur="" onchange=" " value=" boo ">
<input value="" name=foo>
<img src="" alt="">
<div data-foo class id style title lang dir onfocus onblur onchange onclick ondblclick onmousedown onmouseup onmouseover onmousemove onmouseout onkeypress onkeydown onkeyup></div>
<img src="" alt="">
<p class=" foo bar ">foo bar baz</p>
<p class=" foo ">foo bar baz</p>
<p class="
foo
">foo bar baz</p>
<p style=" color: red; background-color: rgb(100, 75, 200); "></p>
<p style="font-weight: bold ; "></p>
<br>x<br>
<p title="</p>">x</p>
<p title=" <!-- hello world --> ">x</p>
<p title=" <![CDATA[ \n\n foobar baz ]]> ">x</p>
<p foo-bar=baz>xxx</p>
<p foo:bar=baz>xxx</p>
<p foo.bar=baz>xxx</p>
<div><div><div><div><div><div><div><div><div><div>i'm 10 levels deep</div></div></div></div></div></div></div></div></div></div>
<a title=x href=" ">foo</a>
<p id="" class="" title="">x</p>
<p x="x'">x</p>
<p x='x"'>x</p>
<a href=#><p>Click me</p></a>
<span><button>Hit me</button></span>
<object type=image/svg+xml data=image.svg><div>[fallback image]</div></object>
<img class=user-image src=http://adasdasdasd.cloudfront.net/users/2011/05/24/4asdasd/asdasd.jpg>
<div data-foo></div>
<div data-foo=""></div>
<div data-foo=""></div>
<div data-foo=test></div>
<div data-foo=test></div>
<div data-test=foo class=bar>test</div>
<div data-test=foo class=bar>test</div>
<div data-test=foo class=bar>test</div>
<div data-test="foo bar" class=bar>test</div>
<div data-test='foo " bar' class=bar>test</div>
<div data-test="foo ' bar" class=bar>test</div>
<div data-test='foo " bar' class=bar>test</div>
<div data-test="foo ' bar" class=bar>test</div>
<div data-test='foo """ bar' class=bar>test</div>
<div data-test="foo ''' bar" class=bar>test</div>
<div data-test='"foo"' class=bar>test</div>
<div data-test='"foo"' class=bar>test</div>
<div data-test='" foo "' class=bar>test</div>
<div data-test='"foo"' class=bar>test</div>
<div data-test='"foo"' class=bar>test</div>
<div data-test='" foo "' class=bar>test</div>
<div data-test="'foo'" class=bar>test</div>
<div data-test="'foo'" class=bar>test</div>
<div data-test="
foo
" class=bar>test</div>
<div data-test=\foo class=bar>test</div>
<div data-test=\\foo class=bar>test</div>
<span title='test "with" &quot;'>test</span>
<span title='test "with" & quot'>test</span>
<span title='test "with" &test'>test</span>
<span title='test "with" &amptest'>test</span>
<span title='test "with" <'>test</span>
<span title='test "with" >'>test</span>
<span title=foo>Test</span>
<span title="foo<bar">Test</span>
<span title="foo=bar">Test</span>
<span title="foo>bar">Test</span>
<span title='foo"bar'>Test</span>
<span title="foo'bar">Test</span>
<div>
&quot;
</div>
<script>
let foo = "&";
</script>
<style>
.class::before {
content: "&";
}
</style>
<div>
foo & bar
foo&<i>bar</i>
foo&&& bar
</div>
<pre><code>Label current;
// Load effective address of current instruction into rcx.
__ leaq(rcx, Operand(&current));
__ bind(&current);
</code></pre>
<div>
&xxx; &xxx &thorn; &thorn &curren;t &current &current; &&
&gt
&unknown;
&current
&current;
&current
&current;
ø &osLash Ø
&ø &&osLash; &Ø
&ø &&osLash; &Ø
&oslash; &osLash; &Oslash;
&oslash; &osLash; &Oslash;
</div>
<a b="`''<<==/`/"></a>
<a b="`'"<<==/`/"></a>
<a b="`'"<<==/`/"></a>
<a b='`'"""<<==/`/'></a>
<a b='`"<<==/`/'></a>
<a b="`'<<==/`/"></a>
<a b='"'></a>
<a b="'"></a>
<a b="'"></a>
<a b='"'></a>
<a b="'''"></a>
<a b="'''"></a>
<a b='"""'></a>
<a b='"""'></a>
<a href=">"></a>
<a href="<"></a>
<a href="<"></a>
<a href="<"></a>
<a href=">"></a>
<a href=">"></a>
<a href=">"></a>
<a href=">"></a>
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/base/input.html | HTML | <!DOCTYPE html><body><base>A | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/base/output.html | HTML | <!DOCTYPE html>
<html>
<head></head><body><base>A</body></html> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/base/output.min.html | HTML | <!doctype html><body><base>A | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/body-comment/input.html | HTML | <!doctype html>
<html lang="en">
<head>
<title>Document</title>
</head>
<body><!-- test --></body>
</html> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/body-comment/output.html | HTML | <!DOCTYPE html>
<html lang="en">
<head>
<title>Document</title>
</head>
<body><!-- test -->
</body></html> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/body-comment/output.min.html | HTML | <!doctype html><html lang=en><head>
<title>Document</title>
</head>
<body><!-- test -->
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/body-meta/input.html | HTML | <!doctype html>
<html lang="en">
<head>
<title>Document</title>
</head>
<body>
<meta content="text/css">
</body>
</html> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/body-meta/output.html | HTML | <!DOCTYPE html>
<html lang="en">
<head>
<title>Document</title>
</head>
<body>
<meta content="text/css">
</body></html> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/body-meta/output.min.html | HTML | <!doctype html><html lang=en><head>
<title>Document</title>
</head>
<body>
<meta content=text/css>
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/body-noscript/input.html | HTML | <!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Test</title>
</head>
<body><noscript>This app requires JavaScript.</noscript></body>
</html>
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/body-noscript/output.html | HTML | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Test</title>
</head>
<body><noscript>This app requires JavaScript.</noscript>
</body></html> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/body-noscript/output.min.html | HTML | <!doctype html><html lang=en><head>
<meta charset=utf-8>
<title>Test</title>
</head>
<body><noscript>This app requires JavaScript.</noscript>
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/body-script/input.html | HTML | <!doctype html>
<html lang="en">
<head>
<title>Document</title>
</head>
<body><script>console.log("test")</script></body>
</html> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/body-script/output.html | HTML | <!DOCTYPE html>
<html lang="en">
<head>
<title>Document</title>
</head>
<body><script>console.log("test")</script>
</body></html> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/body-script/output.min.html | HTML | <!doctype html><html lang=en><head>
<title>Document</title>
</head>
<body><script>console.log("test")</script>
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/body-space/input.html | HTML | <!doctype html>
<html lang="en">
<head>
<title>Document</title>
</head>
<body> <div>test</div></body>
</html> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/body-space/output.html | HTML | <!DOCTYPE html>
<html lang="en">
<head>
<title>Document</title>
</head>
<body> <div>test</div>
</body></html> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/body-space/output.min.html | HTML | <!doctype html><html lang=en><head>
<title>Document</title>
</head>
<body> <div>test</div>
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/body-template/input.html | HTML | <!doctype html>
<html lang="en">
<head>
<title>Document</title>
</head>
<body><template><div>test</div></template></body>
</html> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/body-template/output.html | HTML | <!DOCTYPE html>
<html lang="en">
<head>
<title>Document</title>
</head>
<body><template><div>test</div></template>
</body></html> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/body-template/output.min.html | HTML | <!doctype html><html lang=en><head>
<title>Document</title>
</head>
<body><template><div>test</div></template>
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/broken-svg/input.html | HTML | <!doctype html>
<html lang="en">
<head>
<title>Document</title>
</head>
<body>
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20">
<rect width="20" height="3" y="2" fill="#fff"/>
<rect width="20" height="3" y="8.5" fill="#fff"/>
<rect width="20" height="3" y="15" fill="#fff"/>
</svg>
</body>
</html> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/broken-svg/output.html | HTML | <!DOCTYPE html>
<html lang="en">
<head>
<title>Document</title>
</head>
<body>
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20">
<rect width="20" height="3" y="2" fill="#fff" />
<rect width="20" height="3" y="8.5" fill="#fff" />
<rect width="20" height="3" y="15" fill="#fff" />
</svg>
</body></html> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/broken-svg/output.min.html | HTML | <!doctype html><html lang=en><head>
<title>Document</title>
</head>
<body>
<svg xmlns=http://www.w3.org/2000/svg width=20 height=20>
<rect width=20 height=3 y=2 fill=#fff />
<rect width=20 height=3 y=8.5 fill=#fff />
<rect width=20 height=3 y=15 fill=#fff />
</svg>
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/cdata/input.html | HTML | <!doctype html>
<html lang="en">
<head>
<title>Document</title>
</head>
<body>
<svg viewBox="0 0 100 100">
<text><![CDATA[content]]></text>
</svg>
</body>
</html> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/cdata/output.html | HTML | <!DOCTYPE html>
<html lang="en">
<head>
<title>Document</title>
</head>
<body>
<svg viewBox="0 0 100 100">
<text>content</text>
</svg>
</body></html> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/cdata/output.min.html | HTML | <!doctype html><html lang=en><head>
<title>Document</title>
</head>
<body>
<svg viewBox="0 0 100 100">
<text>content</text>
</svg>
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/comment/after-html-1/input.html | HTML | <html><body></body></html><!-- Hi there --> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/comment/after-html-1/output.html | HTML | <html>
<head></head><body></body></html><!-- Hi there --> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/comment/after-html-1/output.min.html | HTML | </html><!-- Hi there --> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/comment/after-html/input.html | HTML | <html><!-- comment --><head><title>Comment before head</title></head><body>Test</body>
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/comment/after-html/output.html | HTML | <html>
<!-- comment --><head><title>Comment before head</title></head><body>Test
</body></html> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/comment/after-html/output.min.html | HTML | <html><!-- comment --><title>Comment before head</title>Test
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/comment/basic/input.html | HTML | <!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link href="main.css" rel="stylesheet" type="text/css">
<!--[if IE 7]>
<link href="ie7.css" rel="stylesheet" type="text/css">
<![endif]-->
<!--[if IE 6]>
<link href="ie6.css" rel="stylesheet" type="text/css">
<![endif]-->
<!--[if IE 5]>
<link href="ie5.css" rel="stylesheet" type="text/css">
<![endif]-->
</head>
<body>
<!-- test -->
<div>
<!-- test -->
test
<!-- test -->
</div>
<p class="accent">
<!--[if IE]>
According to the conditional comment this is IE<br />
<![endif]-->
<!--[if IE 6]>
According to the conditional comment this is IE 6<br />
<![endif]-->
<!--[if IE 7]>
According to the conditional comment this is IE 7<br />
<![endif]-->
<!--[if IE 8]>
According to the conditional comment this is IE 8<br />
<![endif]-->
<!--[if IE 9]>
According to the conditional comment this is IE 9<br />
<![endif]-->
<!--[if gte IE 8]>
According to the conditional comment this is IE 8 or higher<br />
<![endif]-->
<!--[if lt IE 9]>
According to the conditional comment this is IE lower than 9<br />
<![endif]-->
<!--[if lte IE 7]>
According to the conditional comment this is IE lower or equal to 7<br />
<![endif]-->
<!--[if gt IE 6]>
According to the conditional comment this is IE greater than 6<br />
<![endif]-->
<!--[if !IE]> -->
According to the conditional comment this is not IE 5-9<br />
<!-- <![endif]-->
</p>
</body>
</html> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/comment/basic/output.html | HTML | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link href="main.css" rel="stylesheet" type="text/css">
<!--[if IE 7]>
<link href="ie7.css" rel="stylesheet" type="text/css">
<![endif]-->
<!--[if IE 6]>
<link href="ie6.css" rel="stylesheet" type="text/css">
<![endif]-->
<!--[if IE 5]>
<link href="ie5.css" rel="stylesheet" type="text/css">
<![endif]-->
</head>
<body>
<!-- test -->
<div>
<!-- test -->
test
<!-- test -->
</div>
<p class="accent">
<!--[if IE]>
According to the conditional comment this is IE<br />
<![endif]-->
<!--[if IE 6]>
According to the conditional comment this is IE 6<br />
<![endif]-->
<!--[if IE 7]>
According to the conditional comment this is IE 7<br />
<![endif]-->
<!--[if IE 8]>
According to the conditional comment this is IE 8<br />
<![endif]-->
<!--[if IE 9]>
According to the conditional comment this is IE 9<br />
<![endif]-->
<!--[if gte IE 8]>
According to the conditional comment this is IE 8 or higher<br />
<![endif]-->
<!--[if lt IE 9]>
According to the conditional comment this is IE lower than 9<br />
<![endif]-->
<!--[if lte IE 7]>
According to the conditional comment this is IE lower or equal to 7<br />
<![endif]-->
<!--[if gt IE 6]>
According to the conditional comment this is IE greater than 6<br />
<![endif]-->
<!--[if !IE]> -->
According to the conditional comment this is not IE 5-9<br />
<!-- <![endif]-->
</p>
</body></html> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/comment/basic/output.min.html | HTML | <!doctype html><html lang=en><head>
<meta charset=UTF-8>
<meta name=viewport content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv=X-UA-Compatible content="ie=edge">
<title>Document</title>
<link href=main.css rel=stylesheet type=text/css>
<!--[if IE 7]>
<link href="ie7.css" rel="stylesheet" type="text/css">
<![endif]-->
<!--[if IE 6]>
<link href="ie6.css" rel="stylesheet" type="text/css">
<![endif]-->
<!--[if IE 5]>
<link href="ie5.css" rel="stylesheet" type="text/css">
<![endif]-->
</head>
<body>
<!-- test -->
<div>
<!-- test -->
test
<!-- test -->
</div>
<p class=accent>
<!--[if IE]>
According to the conditional comment this is IE<br />
<![endif]-->
<!--[if IE 6]>
According to the conditional comment this is IE 6<br />
<![endif]-->
<!--[if IE 7]>
According to the conditional comment this is IE 7<br />
<![endif]-->
<!--[if IE 8]>
According to the conditional comment this is IE 8<br />
<![endif]-->
<!--[if IE 9]>
According to the conditional comment this is IE 9<br />
<![endif]-->
<!--[if gte IE 8]>
According to the conditional comment this is IE 8 or higher<br />
<![endif]-->
<!--[if lt IE 9]>
According to the conditional comment this is IE lower than 9<br />
<![endif]-->
<!--[if lte IE 7]>
According to the conditional comment this is IE lower or equal to 7<br />
<![endif]-->
<!--[if gt IE 6]>
According to the conditional comment this is IE greater than 6<br />
<![endif]-->
<!--[if !IE]> -->
According to the conditional comment this is not IE 5-9<br>
<!-- <![endif]-->
</p>
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/comment/ie/input.html | HTML | <!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<!--[if !IE]>-->
<p>This is shown in downlevel browsers.</p>
<!--<![endif]-->
</body>
</html> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/comment/ie/output.html | HTML | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<!--[if !IE]>-->
<p>This is shown in downlevel browsers.</p>
<!--<![endif]-->
</body></html> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/comment/ie/output.min.html | HTML | <!doctype html><html lang=en><head>
<meta charset=UTF-8>
<meta name=viewport content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv=X-UA-Compatible content="ie=edge">
<title>Document</title>
</head>
<body>
<!--[if !IE]>-->
<p>This is shown in downlevel browsers.</p>
<!--<![endif]-->
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/custom-component/basic/input.html | HTML | <!DOCTYPE html>
<html>
<body>
<popup-info img="img/alt.png" data-text="Your card validation code (CVC)
is an extra security feature — it is the last 3 or 4 numbers on the
back of your card."></popup-info>
</body>
</html>
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/custom-component/basic/output.html | HTML | <!DOCTYPE html>
<html>
<head></head><body>
<popup-info img="img/alt.png" data-text="Your card validation code (CVC)
is an extra security feature — it is the last 3 or 4 numbers on the
back of your card."></popup-info>
</body></html> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/custom-component/basic/output.min.html | HTML | <!doctype html><body>
<popup-info img=img/alt.png data-text="Your card validation code (CVC)
is an extra security feature — it is the last 3 or 4 numbers on the
back of your card."></popup-info>
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/document-type/html4-strict/input.html | HTML | <!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>
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/document-type/html4-strict/output.html | HTML | <!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> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/document-type/html4-strict/output.min.html | HTML | <!doctype html public "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><head>
<title>!DOCTYPE</title>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
</head>
<body>
<p>Разум — это Будда, а прекращение умозрительного мышления — это путь.
Перестав мыслить понятиями и размышлять о путях существования и небытия,
о душе и плоти, о пассивном и активном и о других подобных вещах,
начинаешь осознавать, что разум — это Будда,
что Будда — это сущность разума,
и что разум подобен бесконечности.</p>
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/document-type/name-lowercase/input.html | HTML | <!doctype html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
The content of the document......
</body>
</html>
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/document-type/name-lowercase/output.html | HTML | <!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
The content of the document......
</body></html> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/document-type/name-lowercase/output.min.html | HTML | <!doctype html><head>
<title>Title of the document</title>
</head>
<body>
The content of the document......
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/document-type/name-uppercase/input.html | HTML | <!DOCTYPE HTML>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
The content of the document......
</body>
</html>
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/document-type/name-uppercase/output.html | HTML | <!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
The content of the document......
</body></html> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/document-type/name-uppercase/output.min.html | HTML | <!doctype html><head>
<title>Title of the document</title>
</head>
<body>
The content of the document......
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/document-type/public-double-quote/input.html | HTML | <!DOCTYPE HTML public "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head><title>Test</title></head>
<body><div>Test</div></body>
</html> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/document-type/public-double-quote/output.html | HTML | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head><title>Test</title></head>
<body><div>Test</div>
</body></html> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/document-type/public-double-quote/output.min.html | HTML | <!doctype html public "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><title>Test</title></head>
<div>Test</div>
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/document-type/public-lowercase/input.html | HTML | <!DOCTYPE HTML public "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head><title>Test</title></head>
<body><div>Test</div></body>
</html> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/document-type/public-lowercase/output.html | HTML | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head><title>Test</title></head>
<body><div>Test</div>
</body></html> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/document-type/public-lowercase/output.min.html | HTML | <!doctype html public "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><title>Test</title></head>
<div>Test</div>
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/document-type/public-single-quote/input.html | HTML | <!DOCTYPE HTML public '-//W3C//DTD HTML 4.01//EN' 'http://www.w3.org/TR/html4/strict.dtd'>
<html>
<head><title>Test</title></head>
<body><div>Test</div></body>
</html>
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/document-type/public-single-quote/output.html | HTML | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head><title>Test</title></head>
<body><div>Test</div>
</body></html> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/document-type/public-single-quote/output.min.html | HTML | <!doctype html public "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><title>Test</title></head>
<div>Test</div>
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/document-type/public-uppercase/input.html | HTML | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head><title>Test</title></head>
<body><div>Test</div></body>
</html>
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/document-type/public-uppercase/output.html | HTML | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head><title>Test</title></head>
<body><div>Test</div>
</body></html> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/document-type/public-uppercase/output.min.html | HTML | <!doctype html public "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><title>Test</title></head>
<div>Test</div>
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/document-type/system-double-quote/input.html | HTML | <!DOCTYPE document system "subjects.dtd">
<html>
<head><title>Test</title></head>
<body><div>Test</div></body>
</html> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/document-type/system-double-quote/output.html | HTML | <!DOCTYPE document SYSTEM "subjects.dtd">
<html>
<head><title>Test</title></head>
<body><div>Test</div>
</body></html> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/document-type/system-double-quote/output.min.html | HTML | <!doctype document system "subjects.dtd"><title>Test</title></head>
<div>Test</div>
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/document-type/system-lowercase/input.html | HTML | <!DOCTYPE document system "subjects.dtd">
<html>
<head><title>Test</title></head>
<body><div>Test</div></body>
</html> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/document-type/system-lowercase/output.html | HTML | <!DOCTYPE document SYSTEM "subjects.dtd">
<html>
<head><title>Test</title></head>
<body><div>Test</div>
</body></html> | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_html_codegen/tests/fixture/document-type/system-lowercase/output.min.html | HTML | <!doctype document system "subjects.dtd"><title>Test</title></head>
<div>Test</div>
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.