From a47718416371343759e11a4733b34e1efe2c6cbe Mon Sep 17 00:00:00 2001 From: Hannah Robertson Date: Tue, 8 Oct 2024 22:13:17 -0400 Subject: [PATCH] =?UTF-8?q?Update=20.vscode=20settings=20to=20generate=20b?= =?UTF-8?q?log=20html=20on=20save=20AND=20fix=20borked=20CSS=20?= =?UTF-8?q?=F0=9F=98=B1=20=20(#34)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * run html generation on file save * update script to update for single file * fix borked css --- .vscode/settings.json | 20 ++++++++++ assets/css/main.css | 20 ---------- blog/driven-developments/index.html | 8 ++-- build-blogs/run.jl | 60 ++++++++++++++++++++--------- 4 files changed, 65 insertions(+), 43 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..ab53494 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,20 @@ +{ + "liveServer.settings.port": 5502, + "emeraldwalk.runonsave": { + "commands": [ + // { + // "match": ".*", + // "isAsync": true, + // "cmd": "echo 'I run for all files.'" + // }, + { + "match": "blog/.*/src.md$", + "cmd": "echo 'I am a .md file ${file}.'; julia build-blogs/run.jl ${file}" + }, + { + "match": "blog/__template/.*$", + "cmd": "echo 'A __template file has been saved ${file}.'; julia build-blogs/run.jl" + }, + ] + } +} diff --git a/assets/css/main.css b/assets/css/main.css index 21ca69f..0728ac3 100644 --- a/assets/css/main.css +++ b/assets/css/main.css @@ -80,7 +80,6 @@ body { font-weight: bolder; } -.blog { .blog { line-height: 150%; } @@ -94,7 +93,6 @@ h2, h3 { margin-bottom: 3px; } -.blog > h1 { .blog > h1 { line-height: 1.2em; } @@ -103,11 +101,6 @@ a.footnote-ref { text-decoration: none; } -a > sup { -a.footnote-ref { - text-decoration: none; -} - a > sup { vertical-align: baseline; position: relative; @@ -121,17 +114,6 @@ a.footnote-back { text-underline-offset: .1em; } -.footnotes > ol { - font-size: smaller; - text-decoration: underline; - text-underline-offset: .1em; -} - -a.footnote-back { - text-decoration: underline; - text-underline-offset: .1em; -} - .footnotes > ol { font-size: smaller; } @@ -285,7 +267,6 @@ img.home-img { margin-bottom: 1.6em; } -pre { pre { background: #eeeff1; border: 2px solid #ddd; @@ -312,7 +293,6 @@ pre { font-family: "Jura Bold"; } -.blog img { .blog img { display: block; margin-left: auto; diff --git a/blog/driven-developments/index.html b/blog/driven-developments/index.html index 536f862..82c8339 100644 --- a/blog/driven-developments/index.html +++ b/blog/driven-developments/index.html @@ -194,24 +194,24 @@

Service-driven development coming!

FAQs

Q: Ooh, I have a great idea for a DD! What -now?
A: Bring it to life by using it! And/or +now?
A: Bring it to life by using it! And/or write it up in a blog post of your own (and share the link with me, please)!

Q: Okay, but I have a job to do. What about, like, paycheck-driven development? Or healthcare-driven -development?
A: Those are great DDs if they +development?
A: Those are great DDs if they work for you! Personally I find that I usually need a more specific technique to drive my efforts on an minute-by-minute basis, but it’s all context dependent.

Q: It seems like an awful lot of these overlap, or maybe are even exactly the same, with a different name. Or like you’d -use multiple at once.
A: That isn’t a +use multiple at once.
A: That isn’t a question, but you’re totally right. For example, I am often powered by both DDD and TDD, with an occasional background smattering of SDD! I contain multitudes. You probably do too.

Q: I have a really cool idea for one: string-theory driven development! But the acronym is…not ideal. What -gives?
A: That’s on you, friend. I have +gives?
A: That’s on you, friend. I have confidence that you can use a trusty thesaurus to find an alternate name. Or don’t, and own it!

Footnotes""" text = replace(text, fnote_predecessor => fnote_predecessor * fnote_heading) + # the formatter will yell otherwise... + text = replace(text, "
" => "
") + # Strip out image captions # This is...a truly hacky approach. ¯\_(ツ)_/¯ in_caption = false - str_start = "
" + str_start = "
" str_stop = "
" - lines = map(split(text, "\n")) do line + lines = map(split(text, "\n")) do line # Making some real assumptions that there'll never be multiple of these in one line # ...but if there are, we'll see it in git, so it'll still be okay # Single line contains both start and stop if !in_caption && contains(line, str_start) && contains(line, str_stop) - line = split(line, str_start; limit=2)[1] - return split(line, str_stop; limit=2)[end] + line = split(line, str_start; limit=2)[1] + return split(line, str_stop; limit=2)[end] end # Multiline caption @@ -54,31 +60,47 @@ function tweak_html!!(text) end in_caption && return missing if contains(line, str_start) - in_caption = true + in_caption = true line = split(line, str_start; limit=2)[1] - end - return line + end + return line end lines = filter(!ismissing, lines) return join(lines, "\n") end +function generate_blog_html(md_file; overwrite_existing=true) + if !isfile(md_file) + @warn "Expected blog source file not found: `$(md_file)`; skipping" + return nothing + end + + @info "Converting $(basename(dirname(md_file)))..." + html_outfile = replace(md_file, "src.md" => "index.html") + convert_to_html(md_file, html_outfile; overwrite_existing) + return nothing +end + function generate_all_blogposts(; overwrite_existing=true) for dir in readdir(blog_dir; join=true) isfile(dir) && continue isequal(joinpath(blog_dir, "__template"), dir) && continue # contains(dir, "list") || continue - + md_file = joinpath(dir, "src.md") - if !isfile(md_file) - @warn "Expected blog source file not found: `$(md_file)`; skipping" - continue - end - @info "Converting $(basename(dirname(md_file)))..." - html_outfile = joinpath(dir, "index.html") - convert_to_html(md_file, html_outfile; overwrite_existing) + generate_blog_html(md_file; overwrite_existing) end return nothing end -generate_all_blogposts(; overwrite_existing=true) +# Run from commandline? +if abspath(PROGRAM_FILE) == @__FILE__ + if isempty(ARGS) + generate_all_blogposts(; overwrite_existing=true) + elseif isfile(ARGS[1]) + generate_blog_html(ARGS[1]; overwrite_existing=true) + else + @warn "Unknown argument $(ARGS[1])" + end + return nothing +end