on master help sign in
Add padding-top, padding-bottom, padding-left, padding-right attributes
48c90a7iko
crates/htmlang-core/src/codegen.rs+20
@@ -2661,6 +2661,26 @@ fn attrs_to_css(
2661 push_css(&mut css, "padding-block", &css_px(v));
2661 push_css(&mut css, "padding-block", &css_px(v));
2662 }
2662 }
2663 }
2663 }
2664+ "padding-top" => {
2665+ if let Some(v) = val {
2666+ push_css(&mut css, "padding-top", &css_px(v));
2667+ }
2668+ }
2669+ "padding-bottom" => {
2670+ if let Some(v) = val {
2671+ push_css(&mut css, "padding-bottom", &css_px(v));
2672+ }
2673+ }
2674+ "padding-left" => {
2675+ if let Some(v) = val {
2676+ push_css(&mut css, "padding-left", &css_px(v));
2677+ }
2678+ }
2679+ "padding-right" => {
2680+ if let Some(v) = val {
2681+ push_css(&mut css, "padding-right", &css_px(v));
2682+ }
2683+ }
2664
2684
2665 // Sizing
2685 // Sizing
2666 "width" => {
2686 "width" => {
crates/htmlang-core/src/parser.rs+8
@@ -3688,6 +3688,10 @@ const KNOWN_ATTRS: &[&str] = &[
3688 "padding",
3688 "padding",
3689 "padding-x",
3689 "padding-x",
3690 "padding-y",
3690 "padding-y",
3691+ "padding-top",
3692+ "padding-bottom",
3693+ "padding-left",
3694+ "padding-right",
3691 "width",
3695 "width",
3692 "height",
3696 "height",
3693 "min-width",
3697 "min-width",
@@ -4017,6 +4021,10 @@ const NUMERIC_ATTRS: &[&str] = &[
4017 "padding",
4021 "padding",
4018 "padding-x",
4022 "padding-x",
4019 "padding-y",
4023 "padding-y",
4024+ "padding-top",
4025+ "padding-bottom",
4026+ "padding-left",
4027+ "padding-right",
4020 "min-width",
4028 "min-width",
4021 "max-width",
4029 "max-width",
4022 "min-height",
4030 "min-height",
src/main.rs+25−4
@@ -290,15 +290,29 @@ fn base64_encode(data: &[u8]) -> String {
290}
290}
291
291
292fn copy_non_hl_files(src_dir: &Path, out_dir: &Path) {
292fn copy_non_hl_files(src_dir: &Path, out_dir: &Path) {
293+ let skip = out_dir.canonicalize().ok();
293− copy_non_hl_recursive(src_dir, src_dir, out_dir);
294+ copy_non_hl_recursive(src_dir, src_dir, out_dir, skip.as_deref());
294}
295}
295
296
296−fn copy_non_hl_recursive(base: &Path, dir: &Path, out_dir: &Path) {
297+fn copy_non_hl_recursive(base: &Path, dir: &Path, out_dir: &Path, skip_canonical: Option<&Path>) {
297 if let Ok(entries) = fs::read_dir(dir) {
298 if let Ok(entries) = fs::read_dir(dir) {
298 for entry in entries.flatten() {
299 for entry in entries.flatten() {
299 let path = entry.path();
300 let path = entry.path();
300 if path.is_dir() {
301 if path.is_dir() {
302+ // Skip hidden directories (.htmlang-cache, .git, etc.)
303+ if path
304+ .file_name()
305+ .is_some_and(|n| n.to_str().is_some_and(|s| s.starts_with('.')))
306+ {
307+ continue;
308+ }
309+ // Skip the output directory to avoid copying it into itself
310+ if let Some(skip) = skip_canonical {
311+ if path.canonicalize().ok().as_deref() == Some(skip) {
312+ continue;
313+ }
314+ }
301− copy_non_hl_recursive(base, &path, out_dir);
315+ copy_non_hl_recursive(base, &path, out_dir, skip_canonical);
302 } else if path.is_file() && path.extension().is_none_or(|e| e != "hl") {
316 } else if path.is_file() && path.extension().is_none_or(|e| e != "hl") {
303 let rel = path.strip_prefix(base).unwrap_or(&path);
317 let rel = path.strip_prefix(base).unwrap_or(&path);
304 let dest = out_dir.join(rel);
318 let dest = out_dir.join(rel);
@@ -518,6 +532,13 @@ fn collect_hl_recursive_inner(dir: &Path, files: &mut Vec<PathBuf>) {
518 for entry in entries.flatten() {
532 for entry in entries.flatten() {
519 let path = entry.path();
533 let path = entry.path();
520 if path.is_dir() {
534 if path.is_dir() {
535+ // Skip hidden directories (.htmlang-cache, .git, etc.)
536+ if path
537+ .file_name()
538+ .is_some_and(|n| n.to_str().is_some_and(|s| s.starts_with('.')))
539+ {
540+ continue;
541+ }
521 collect_hl_recursive_inner(&path, files);
542 collect_hl_recursive_inner(&path, files);
522 } else if path.is_file() && path.extension().is_some_and(|e| e == "hl") {
543 } else if path.is_file() && path.extension().is_some_and(|e| e == "hl") {
523 files.push(path);
544 files.push(path);
@@ -1220,7 +1241,7 @@ fn main() {
1220 let build_minify = build_minify || config.minify.unwrap_or(false);
1241 let build_minify = build_minify || config.minify.unwrap_or(false);
1221 let build_compat = build_compat || config.compat.unwrap_or(false);
1242 let build_compat = build_compat || config.compat.unwrap_or(false);
1222 let build_strict = build_strict || config.strict.unwrap_or(false);
1243 let build_strict = build_strict || config.strict.unwrap_or(false);
1223− let out_dir = out_dir.or(config.output.as_deref());
1244+ let out_dir = out_dir.or(config.output.as_deref()).or(Some("out"));
1224 let hl_files = collect_hl_files_recursive(dir);
1245 let hl_files = collect_hl_files_recursive(dir);
1225 if hl_files.is_empty() {
1246 if hl_files.is_empty() {
1226 eprintln!("no .hl files found in {}", src);
1247 eprintln!("no .hl files found in {}", src);