System-default font stack ('-apple-system, BlinkMacSystemFont, Segoe UI,
…') is the textbook generic admin-tool look. The tools have a real point
of view (engineering documents, traceability, immutability); the
typography should reflect that.
Picks:
--font → IBM Plex Sans (400 + 600). UI body text. Distinctive
engineering sans with tabular nums and proper figures.
--font-display → Source Serif 4 (600). Headings, page titles,
.app-header__title. Reads as "document" not "UI label."
--font-mono → unchanged. Platform mono fonts are already excellent
and engineering tools rarely benefit from a custom mono.
Wiring:
- Raw .woff2 files live in shared/fonts/ (~60 KB total, latin subset,
SIL OFL 1.1 — both families)
- shared/fonts.css is base64-inlined data URIs for those three fonts
(~80 KB after b64 overhead). Generated once from the snippet in
shared/fonts/README.md.
- Every tool's build.sh prepends shared/fonts.css before shared/base.css
so @font-face is parsed before any rule references the family names.
- Headings (h1-h6) and .app-header__title now use var(--font-display);
.app-header__title bumped 17→18px and letter-spacing reset since the
serif doesn't need the original sans-text tightening.
- table/code/.tabular-nums get font-variant-numeric: tabular-nums so
tracking-number columns align vertically.
"Ship the record player with the record": zero CDN dependency at render
time. Tools render identically offline and online. Per-tool dist sizes
grew by ~80 KB.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
146 lines
4.2 KiB
Bash
146 lines
4.2 KiB
Bash
#!/bin/sh
|
|
set -eu
|
|
|
|
root_dir=$(cd "$(dirname "$0")" && pwd)
|
|
. "$root_dir/../shared/build-lib.sh"
|
|
|
|
src_html="$root_dir/template.html"
|
|
output_dir="$root_dir/dist"
|
|
output_html="$output_dir/mdedit.html"
|
|
|
|
# Vendor files (bundled dependencies — no CDN required at runtime)
|
|
# Note: Tailwind is NOT a vendor file — it's replaced by css/tailwind-utils.css,
|
|
# a hand-written subset of only the utility classes used in template.html.
|
|
toastui_js="$root_dir/../shared/vendor/toastui-editor-all.min.js"
|
|
toastui_css="$root_dir/../shared/vendor/toastui-editor.min.css"
|
|
|
|
mkdir -p "$output_dir"
|
|
ensure_exists "$src_html"
|
|
ensure_exists "$toastui_js"
|
|
ensure_exists "$toastui_css"
|
|
|
|
css_temp=$(mktemp)
|
|
js_raw=$(mktemp)
|
|
js_temp=$(mktemp)
|
|
toastui_js_safe=$(mktemp)
|
|
cleanup() { rm -f "$css_temp" "$js_raw" "$js_temp" "$toastui_js_safe"; }
|
|
trap cleanup EXIT
|
|
|
|
# CSS files to concatenate in order
|
|
concat_files \
|
|
"css/tailwind-utils.css" \
|
|
"../shared/fonts.css" \
|
|
"../shared/base.css" \
|
|
"../shared/toast.css" \
|
|
"../shared/nav.css" \
|
|
"../shared/logo.css" \
|
|
"css/base.css" \
|
|
"css/editor.css" \
|
|
"css/toc.css" \
|
|
"css/markdown.css" \
|
|
> "$css_temp"
|
|
|
|
# JavaScript files to concatenate in order
|
|
concat_files \
|
|
"../shared/vendor/jszip.min.js" \
|
|
"../shared/vendor/docx-preview.min.js" \
|
|
"../shared/vendor/xlsx.full.min.js" \
|
|
"../shared/vendor/utif.min.js" \
|
|
"../shared/zddc.js" \
|
|
"../shared/zddc-source.js" \
|
|
"../shared/theme.js" \
|
|
"../shared/toast.js" \
|
|
"../shared/nav.js" \
|
|
"../shared/logo.js" \
|
|
"../shared/preview-lib.js" \
|
|
"js/app.js" \
|
|
"js/utils.js" \
|
|
"js/front-matter.js" \
|
|
"js/file-ops.js" \
|
|
"js/file-system.js" \
|
|
"js/file-tree.js" \
|
|
"js/editor.js" \
|
|
"js/toc.js" \
|
|
"js/resizer.js" \
|
|
"js/events.js" \
|
|
"js/main.js" \
|
|
"../shared/help.js" \
|
|
> "$js_raw"
|
|
|
|
# Escape '</' in app JS and the Toast UI vendor JS so neither can prematurely
|
|
# close the inline <script> blocks they get embedded in.
|
|
escape_js_close_tags "$js_raw" "$js_temp"
|
|
escape_js_close_tags "$toastui_js" "$toastui_js_safe"
|
|
|
|
compute_build_label "mdedit" "${1:-}" "${2:-}"
|
|
|
|
# Process template:
|
|
# - Strip the Tailwind CDN <script> tag (css/tailwind-utils.css replaces it)
|
|
# - Replace CDN <link> for Toast UI CSS with inline bundled CSS
|
|
# - Replace CDN <script src="...toastui..."> with inline bundled Toast UI JS
|
|
# - Inject custom CSS/JS at {{CSS_PLACEHOLDER}} and {{JS_PLACEHOLDER}}
|
|
# - Substitute {{BUILD_LABEL}}
|
|
awk \
|
|
-v css_file="$css_temp" \
|
|
-v js_file="$js_temp" \
|
|
-v toastui_js="$toastui_js_safe" \
|
|
-v toastui_css="$toastui_css" \
|
|
-v build_label="$build_label" \
|
|
-v is_red="$is_red" \
|
|
-v favicon_uri="$favicon_data_uri" \
|
|
'
|
|
/\{\{CSS_PLACEHOLDER\}\}/ {
|
|
while ((getline line < css_file) > 0) print line
|
|
close(css_file)
|
|
next
|
|
}
|
|
/\{\{JS_PLACEHOLDER\}\}/ {
|
|
while ((getline line < js_file) > 0) print line
|
|
close(js_file)
|
|
next
|
|
}
|
|
/\{\{BUILD_LABEL\}\}/ {
|
|
if (is_red == "1") {
|
|
gsub(/\{\{BUILD_LABEL\}\}/, "<span style=\"color:red;font-weight:bold\">" build_label "</span>")
|
|
} else {
|
|
gsub(/\{\{BUILD_LABEL\}\}/, build_label)
|
|
}
|
|
print
|
|
next
|
|
}
|
|
/\{\{FAVICON\}\}/ {
|
|
gsub(/\{\{FAVICON\}\}/, favicon_uri)
|
|
print
|
|
next
|
|
}
|
|
/<script src="https:\/\/cdn\.tailwindcss\.com"/ {
|
|
# Stripped: Tailwind utility classes are in css/tailwind-utils.css instead
|
|
next
|
|
}
|
|
/<link rel="stylesheet" href="https:\/\/uicdn\.toast\.com\/editor\/[^"]*\/toastui-editor\.min\.css"/ {
|
|
# Inline the bundled Toast UI CSS
|
|
print "<style>"
|
|
while ((getline line < toastui_css) > 0) print line
|
|
close(toastui_css)
|
|
print "</style>"
|
|
next
|
|
}
|
|
/<script src="https:\/\/uicdn\.toast\.com\/editor\/[^"]*\/toastui-editor/ {
|
|
# Inline the bundled Toast UI JS (already passed through escape_js_close_tags
|
|
# so its content cannot contain a literal </script> sequence). We close with
|
|
# the real </script> because only that exact string terminates a script
|
|
# block per the HTML5 spec.
|
|
print "<script>"
|
|
while ((getline line < toastui_js) > 0) print line
|
|
close(toastui_js)
|
|
print "</script>"
|
|
next
|
|
}
|
|
{ print }
|
|
' "$src_html" > "$output_html"
|
|
|
|
echo "Wrote $output_html ($(wc -c < "$output_html") bytes)"
|
|
|
|
if [ "$is_release" = "1" ]; then
|
|
promote_release "mdedit"
|
|
fi
|