london-clojurians 2026-11-13

Thank you James and Mark for doing the dojo last Tuesday. 🙌 Happy to say that our org macro parsing feature, we did during the session, was merged upstream to bzg/organ 🎉✨ Fyi: I managed later refine the main regexp and remove comma-marker and extra string/replace(s). Diff if interested:

-(def comma-marker "XXX-c716608a-XXX" )
-
 (defn- try-parse-macro [text i]
   (when-let [[full macro-name args]
-             (re-find-at #"^\{\{\{([^(\}]*)(\(([^\(\}]*)\))?\}\}\}" text i)]
+             (re-find-at #"^\{\{\{([\w\-]+)(?:\((.+?)\))?\}\}\}" text i)]
     [(cond-> {:type :macro :args [] :name macro-name}
-       args (assoc :args
-                   (map #(string/replace % comma-marker ",")
-                        (-> args
-                            (string/replace #"^\(" "")
-                            (string/replace #"\)$" "")
-                            (string/replace #"\\," comma-marker)
-                            (string/split #",")))))
+       args (assoc :args (mapv #(str/replace % #"\\," ",")
+                               (str/split args #"(?<!\\),"))))
      (+ i (count full))]))
(In the final merged version the maintainer did few changes for compatibility with org-mode version and for performance.) Looking forward to the next dojo!

👏 1
🙌 2

Good stuff - yes even at the event I was thinking there must be a rexexp that would catch this case, but I had forgotten how to do it at t time.

glad you found it