#!/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/vendor/toastui-editor-all.min.js" toastui_css="$root_dir/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/base.css" \ "css/base.css" \ "css/editor.css" \ "css/toc.css" \ "css/markdown.css" \ > "$css_temp" # JavaScript files to concatenate in order concat_files \ "../shared/zddc.js" \ "../shared/theme.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 ' 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 sequence). We close with # the real because only that exact string terminates a script # block per the HTML5 spec. print "" next } { print } ' "$src_html" > "$output_html" echo "Wrote $output_html ($(wc -c < "$output_html") bytes)" if [ "$is_release" = "1" ]; then promote_release "mdedit" fi