Skip to content

feat: README images reach the site, and GitHub alerts render as callouts - #4

Merged
burinc merged 1 commit into
mainfrom
feat/readme-assets-and-alerts
Nov 7, 2026
Merged

burinc merged 1 commit into
mainfrom
feat/readme-assets-and-alerts

Conversation

@burinc

@burinc burinc commented Nov 7, 2026

Copy link
Copy Markdown
Member

Two things champaca's site got wrong on its README homepage, both fixed in the engine so any project with the same README shape gets them.

README images

A homepage rendered from README.md kept the README's paths, which are relative to the repository root. Champaca's README shows its logo with <img src="docs/images/logo.svg">, which is right on GitHub. On the site it resolved to /champaca/docs/images/logo.svg, a 404, because :asset-dirs ["images"] copies docs/images to /champaca/images.

generic-home/rewrite-readme-asset-links now points src and href values that start with docs/<entry>/ or ./docs/<entry>/ at <site-base>/<entry>/, for each configured :asset-dirs entry, in either quote style. That covers raw HTML <img>, markdown ![]() and plain links. A path into a directory that isn't listed is left as written, since the build doesn't copy it. Guide pages aren't touched: their ../images/x paths already resolve.

GitHub alerts

> [!WARNING] rendered as an ordinary blockquote starting with the literal [!WARNING]. markdown/github-alerts now renders the five GitHub kinds (NOTE, TIP, IMPORTANT, WARNING, CAUTION, any case) as GitHub does: div.markdown-alert.markdown-alert-<kind> with a p.markdown-alert-title. The colours reuse the syntax-highlighting tokens, so the callouts follow the light and dark themes, with the dark value as a fallback before the head script sets data-theme.

It works on the rendered HTML, which has two differences from GitHub, noted in the docstring: > [!TIP] text on one line becomes an alert here but stays a quote on GitHub, and a blockquote nested inside an alert ends the alert early. A marker inside a code block is never touched, because markdown-clj has already escaped it.

Checked

  • bb test: 110 tests, 286 assertions, 0 failures (107 before). The new tests cover all five kinds plus a lowercase marker, a plain quote, an unknown marker and a fenced block left alone, and a README homepage built end to end with raw-HTML, markdown and ./ image paths, a link, and an unlisted directory.
  • A copy of champaca's README.md and docs/, with :asset-dirs ["images"] added, built and served: /champaca/images/logo.svg and /champaca/images/champaca-1880.jpg return 200 (image/svg+xml, image/jpeg), and the warning renders as a callout with no [!WARNING] text left.

The README documents both. Champaca itself still needs the one-line :asset-dirs ["images"] in its docs/site.edn, which its own session will add.

A homepage rendered from README.md kept the README's repo-root paths, so
<img src="docs/images/logo.svg"> pointed at <base>/docs/images/logo.svg
while :asset-dirs copies docs/images to <base>/images. Links that start with
docs/<entry>/ or ./docs/<entry>/ for a configured entry now point at that
copy. Anything else is left as written.

A blockquote opening with [!NOTE], [!TIP], [!IMPORTANT], [!WARNING] or
[!CAUTION] rendered as a plain quote showing the marker. It now renders as
GitHub does, a div.markdown-alert with a title, styled from the existing
syntax colours so it follows the light and dark themes.

Found on champaca's site, whose README has both.
@burinc
burinc merged commit 151e06d into main Nov 7, 2026
1 check passed
@burinc
burinc deleted the feat/readme-assets-and-alerts branch November 7, 2026 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant