Reformatting

This commit is contained in:
Wilson Lin 2020-01-26 13:35:57 +13:00
parent 90148f5f9b
commit ee2d9e22cf
3 changed files with 119 additions and 119 deletions

View File

@ -1,3 +1,5 @@
use core::fmt;
use std::fmt::{Debug, Formatter};
use std::ops::{Index, IndexMut};
use fastrie::Fastrie;
@ -9,8 +11,6 @@ use crate::proc::MatchCond::*;
use crate::proc::MatchMode::*;
use crate::proc::range::ProcessorRange;
use crate::spec::codepoint::is_whitespace;
use std::fmt::{Debug, Formatter};
use core::fmt;
pub mod checkpoint;
pub mod range;
@ -345,6 +345,7 @@ impl Debug for Processor<'_> {
};
};
let max_line_no_width = (line_no as f64).log10().ceil() as usize;
// Don't use for_each as otherwise we can't return errors.
for l in lines
.iter()
.map(|(line_no, line)| if *line_no == -1 {
@ -352,7 +353,6 @@ impl Debug for Processor<'_> {
} else {
format!("{:>indent$}|{}\n", line_no, line, indent = max_line_no_width)
})
// Don't use for_each as otherwise we can't return errors.
{
f.write_str(l.as_str())?;
}

View File

@ -1,19 +1,19 @@
use phf::{phf_set, Set};
pub static VOID_TAGS: Set<&'static [u8]> = phf_set! {
b"area",
b"base",
b"br",
b"col",
b"embed",
b"hr",
b"img",
b"input",
b"keygen",
b"link",
b"meta",
b"param",
b"source",
b"track",
b"wbr",
b"area",
b"base",
b"br",
b"col",
b"embed",
b"hr",
b"img",
b"input",
b"keygen",
b"link",
b"meta",
b"param",
b"source",
b"track",
b"wbr",
};

View File

@ -50,113 +50,113 @@ static DEFAULT: &WhitespaceMinification = &WhitespaceMinification {
static TAG_WHITESPACE_MINIFICATION: Map<&'static [u8], &'static WhitespaceMinification> = phf_map! {
// Content tags.
b"address" => CONTENT,
b"audio" => CONTENT,
b"button" => CONTENT,
b"canvas" => CONTENT,
b"caption" => CONTENT,
b"figcaption" => CONTENT,
b"h1" => CONTENT,
b"h2" => CONTENT,
b"h3" => CONTENT,
b"h4" => CONTENT,
b"h5" => CONTENT,
b"h6" => CONTENT,
b"legend" => CONTENT,
b"meter" => CONTENT,
b"object" => CONTENT,
b"option" => CONTENT,
b"p" => CONTENT,
b"summary" => CONTENT,
b"textarea" => CONTENT,
b"video" => CONTENT,
b"address" => CONTENT,
b"audio" => CONTENT,
b"button" => CONTENT,
b"canvas" => CONTENT,
b"caption" => CONTENT,
b"figcaption" => CONTENT,
b"h1" => CONTENT,
b"h2" => CONTENT,
b"h3" => CONTENT,
b"h4" => CONTENT,
b"h5" => CONTENT,
b"h6" => CONTENT,
b"legend" => CONTENT,
b"meter" => CONTENT,
b"object" => CONTENT,
b"option" => CONTENT,
b"p" => CONTENT,
b"summary" => CONTENT,
b"textarea" => CONTENT,
b"video" => CONTENT,
// Content-first tags.
b"dd" => CONTENT_FIRST,
b"details" => CONTENT_FIRST,
b"dt" => CONTENT_FIRST,
b"iframe" => CONTENT_FIRST,
b"label" => CONTENT_FIRST,
b"li" => CONTENT_FIRST,
b"noscript" => CONTENT_FIRST,
b"output" => CONTENT_FIRST,
b"progress" => CONTENT_FIRST,
b"slot" => CONTENT_FIRST,
b"td" => CONTENT_FIRST,
b"template" => CONTENT_FIRST,
b"th" => CONTENT_FIRST,
// Content-first tags.
b"dd" => CONTENT_FIRST,
b"details" => CONTENT_FIRST,
b"dt" => CONTENT_FIRST,
b"iframe" => CONTENT_FIRST,
b"label" => CONTENT_FIRST,
b"li" => CONTENT_FIRST,
b"noscript" => CONTENT_FIRST,
b"output" => CONTENT_FIRST,
b"progress" => CONTENT_FIRST,
b"slot" => CONTENT_FIRST,
b"td" => CONTENT_FIRST,
b"template" => CONTENT_FIRST,
b"th" => CONTENT_FIRST,
// Formatting tags.
// Formatting tags.
// Sourced from https://developer.mozilla.org/en-US/docs/Web/HTML/Element#Inline_text_semantics.
// Differences to tags listed in table at above URL: -br, +del, +ins.
b"a" => FORMATTING,
b"abbr" => FORMATTING,
b"b" => FORMATTING,
b"bdi" => FORMATTING,
b"bdo" => FORMATTING,
b"cite" => FORMATTING,
b"data" => FORMATTING,
b"del" => FORMATTING,
b"dfn" => FORMATTING,
b"em" => FORMATTING,
b"i" => FORMATTING,
b"ins" => FORMATTING,
b"kbd" => FORMATTING,
b"mark" => FORMATTING,
b"q" => FORMATTING,
b"rp" => FORMATTING,
b"rt" => FORMATTING,
b"rtc" => FORMATTING,
b"ruby" => FORMATTING,
b"s" => FORMATTING,
b"samp" => FORMATTING,
b"small" => FORMATTING,
b"span" => FORMATTING,
b"strong" => FORMATTING,
b"sub" => FORMATTING,
b"sup" => FORMATTING,
b"time" => FORMATTING,
b"u" => FORMATTING,
b"var" => FORMATTING,
b"wbr" => FORMATTING,
b"a" => FORMATTING,
b"abbr" => FORMATTING,
b"b" => FORMATTING,
b"bdi" => FORMATTING,
b"bdo" => FORMATTING,
b"cite" => FORMATTING,
b"data" => FORMATTING,
b"del" => FORMATTING,
b"dfn" => FORMATTING,
b"em" => FORMATTING,
b"i" => FORMATTING,
b"ins" => FORMATTING,
b"kbd" => FORMATTING,
b"mark" => FORMATTING,
b"q" => FORMATTING,
b"rp" => FORMATTING,
b"rt" => FORMATTING,
b"rtc" => FORMATTING,
b"ruby" => FORMATTING,
b"s" => FORMATTING,
b"samp" => FORMATTING,
b"small" => FORMATTING,
b"span" => FORMATTING,
b"strong" => FORMATTING,
b"sub" => FORMATTING,
b"sup" => FORMATTING,
b"time" => FORMATTING,
b"u" => FORMATTING,
b"var" => FORMATTING,
b"wbr" => FORMATTING,
// Layout tags.
b"article" => LAYOUT,
b"aside" => LAYOUT,
b"blockquote" => LAYOUT,
b"body" => LAYOUT,
b"colgroup" => LAYOUT,
b"datalist" => LAYOUT,
b"dialog" => LAYOUT,
b"div" => LAYOUT,
b"dl" => LAYOUT,
b"fieldset" => LAYOUT,
b"figure" => LAYOUT,
b"footer" => LAYOUT,
b"form" => LAYOUT,
b"head" => LAYOUT,
b"header" => LAYOUT,
b"hgroup" => LAYOUT,
b"html" => LAYOUT,
b"main" => LAYOUT,
b"map" => LAYOUT,
b"menu" => LAYOUT,
b"nav" => LAYOUT,
b"ol" => LAYOUT,
b"optgroup" => LAYOUT,
b"picture" => LAYOUT,
b"section" => LAYOUT,
b"select" => LAYOUT,
b"table" => LAYOUT,
b"tbody" => LAYOUT,
b"tfoot" => LAYOUT,
b"thead" => LAYOUT,
b"tr" => LAYOUT,
b"ul" => LAYOUT,
// Layout tags.
b"article" => LAYOUT,
b"aside" => LAYOUT,
b"blockquote" => LAYOUT,
b"body" => LAYOUT,
b"colgroup" => LAYOUT,
b"datalist" => LAYOUT,
b"dialog" => LAYOUT,
b"div" => LAYOUT,
b"dl" => LAYOUT,
b"fieldset" => LAYOUT,
b"figure" => LAYOUT,
b"footer" => LAYOUT,
b"form" => LAYOUT,
b"head" => LAYOUT,
b"header" => LAYOUT,
b"hgroup" => LAYOUT,
b"html" => LAYOUT,
b"main" => LAYOUT,
b"map" => LAYOUT,
b"menu" => LAYOUT,
b"nav" => LAYOUT,
b"ol" => LAYOUT,
b"optgroup" => LAYOUT,
b"picture" => LAYOUT,
b"section" => LAYOUT,
b"select" => LAYOUT,
b"table" => LAYOUT,
b"tbody" => LAYOUT,
b"tfoot" => LAYOUT,
b"thead" => LAYOUT,
b"tr" => LAYOUT,
b"ul" => LAYOUT,
// Whitespace-sensitive tags.
b"code" => WHITESPACE_SENSITIVE,
b"pre" => WHITESPACE_SENSITIVE,
// Whitespace-sensitive tags.
b"code" => WHITESPACE_SENSITIVE,
b"pre" => WHITESPACE_SENSITIVE,
};
pub fn get_whitespace_minification_for_tag(tag_name: Option<&[u8]>) -> &'static WhitespaceMinification {