clerk

mkvlr 2025-12-07T01:38:35.111299Z

thinking about https://github.com/nextjournal/clerk/issues/783 a bit more triggered by the conversation with @narimiran above. When I was trying to write the docs I realized that it’s pretty hard to give the right advise as the feature is too complicated atm. I’m thinking it’s unfortunate that we introduced nextjournal.clerk.viewer/doc-url with different semantics compared to normal html linking (`doc-url` is relative to Clerk’s root, not to the document). It also feels wrong that we’re asking folks to use doc-url, it’s just really tedious not being able to use normal links in markdown etc anymore. I’m thinking the way forward is to build a new helper fn e.g. clerk/href that uses the normal html linking semantics and automatically apply that to links in markdown so these work also when publishing to :single-file. Maybe we should combine the linking with a way to validate link targets exist. We also want clerk’s static bundles to co-exist with things outside clerk so this validation needs to be extensible. One complication with relative links is the trailing slash being optional, so relative links being different when accessing /notebook/rule_30 vs /notebook/rule_30/. Any ideas for how to address this?

teodorlu 2025-12-07T11:57:19.567209Z

I'd like to link via Clojure namespaces. Why? Because then I can rely on LSP / Kondo for analysis (including backlinks) and refactoring. I stunted a system like this for Civitas (which is based on Clay), but ended up removing it because it caused trouble for the library we used to read the forms. The gist is:

(ns civitas.why.explanations-are-value-laden
  (:require [civitas.why.growing-explanations-together :as-alias growing-explanations-together]
            [civitas.why.village.scene :as-alias search-for-meaning]
            [scicloj.kindly.v4.kind :as kind]))

(defn infer-html-location [anchor]
  ;; Full details in
  ;; 
  )

(defn link [anchor linktext]
  [:a {:href (infer-html-location anchor)} linktext])

(kind/hiccup
 [:p "Timothy Pratley recently wrote about "
  (link ::search-for-meaning/anchor
        [:span "the pursuit of " [:em "meaning"]])
  " on civitas."
  " Before that; I argued that "
  (link ::growing-explanations-together/anchor
        "Civitas is a great place to grow explanations together")
  "."])
I care a lot about not breaking links. Out on the public Internet, https://www.w3.org/Provider/Style/URI. But when I'm working through an idea (as one or more drafts), I like being able to move things around. On my personal website, I avoid breaking internals links giving all documents a UUID, create links that point to that UUID and "resolve" links on HTML generation with a postwalk. Ultimately, I prefer qualified keywords to UUIDs because the keyword name and the keyword namespace convey meaning. UUIDs just take up space. — However, "links as qualified keywords" doesn't directly address your question. I've also struggled to understand how Clerk links are meant to work. My process as been to try things, click links, export, then click links. So hearing that links are up for discussion makes me happy. My suggestion on > One complication with relative links is the trailing slash being optional, so relative links being different when accessing /notebook/rule_30 vs /notebook/rule_30/. Any ideas for how to address this? would be to always export a folder. Crude but clear.

mkvlr 2025-12-07T23:59:40.077969Z

using symbols or keywords as links is interesting. In your system you were using namespaced keywords but threw away the name? That also feels a bit strange to me. Also not every notebook needs a namespace, pure markdown docs are also fine…

mkvlr 2025-12-08T00:01:58.958369Z

on the trailing slash, we do always export a folder but don’t expect a trailing slash when accessing a doc. I feel it would be unexpected to link between different files in the same directory using a ../ prefix?

🤝 1
☝️ 1
teodorlu 2025-12-09T11:47:57.373749Z

> on the trailing slash, we do always export a folder but don’t expect a trailing slash when accessing a doc. I feel it would be unexpected to link between different files in the same directory using a ../ prefix? That's what I have done previously, and how I expect it to work. If that's not desired, then (the way I see it), we're stuck with a bit of ambiguity.

teodorlu 2025-12-09T11:57:12.732349Z

> using symbols or keywords as links is interesting. In your system you were using namespaced keywords but threw away the name? That also feels a bit strange to me. I intended that :teodorlu.rainbow-tables/prerequisites would refer to /teodorlu/rainbow-tables/#prerequisites. In other word, the name of the keyword correspons to the name of an HTML anchor (`<a name="prerequisites">...</a>`). It looks funny for links without an anchor in the linked document, but in my estimation, anchors are important enough to warrant proper support (for example ) > Also not every notebook needs a namespace, pure markdown docs are also fine… In that case, require :as-alias and keywords for anchor still works! Pure markdown docs still need to be published in the same URL namespace as Clojure notebooks.

teodorlu 2025-12-09T11:58:36.987559Z

I realize that you make have different goals / intentions with this than the things I'm suggesting. Just wanted to share my thoughts! I still think Clerk is great — I just desire more REPL/editor oriented ways of working with cross document links.

mkvlr 2025-12-10T03:27:04.298019Z

I’m onboard with that clerk should let you do this

mkvlr 2025-12-10T03:30:30.009489Z

not sure this should be the default / built-in. One way to allow this would be to have a default clerk/href or similar which would be called for all links in markdown etc and letting you provide your own fn. Then you could implement the behavior you want.