ethica

Spinozas ethics and various translations, edited for easy post processing.
git clone https://git.repetitions.de/ethica
commit ff594dd7b406b79aed5a2e1b43c23b7a2e9ad04d
parent 993ed81cc46e3ce53b1b75cc10380e59de6c7a4b
Author: lou woell <lou@repetitions.de>
Date:   Fri, 23 Oct 2026 01:01:01 +0200

implement node tag

Diffstat:
Mhtml/ethics.chtml | 4+---
Mhtml/node.chtml | 94+++++++++++++++++++++++++++++++++++++------------------------------------------
Mlisp/ethics.lisp | 27+++++++++++++++++++++++----
3 files changed, 68 insertions(+), 57 deletions(-)

diff --git a/html/ethics.chtml b/html/ethics.chtml @@ -13,9 +13,7 @@ <hr> </nav> <div class="container"> - <c:h> - (ethics::make-node tree vkey types) - </c:h> + <c:node node="tree" vkey="vkey" types="types"/> </div> </body> </html> diff --git a/html/node.chtml b/html/node.chtml @@ -1,50 +1,44 @@ -<c:let vkey="vkey" - node="node" - level="level" - types="types" - id="(gethash &quot;id&quot; node)" - type="(gethash &quot;type&quot; node)" - refs="(gethash &quot;ref&quot; node)" - backlinks="(gethash :links node)" - children="(gethash :child-nodes node)"> - <div class="node" - lquery="(attr :id id) (add-class type)"> - <c:expand class="headline" lquery="(attr :as (format nil &quot;h~a&quot; level))"> - <c:s>(format nil "~a ~a" (gethash type types) (or (gethash "number" node) ""))</c:s> - <a class="anchor" href="#{id}" fill="href *">#<c:s>id</c:s></a> - </c:expand> - <c:when test="backlinks"> - <div class="backlinks"> - <label>Referenced by:</label> - <c:splice iterate="backlinks"> - <c:let target="*"> - <a href="#{target}" - fill="href *" - lquery="(text target)"> - </a> - </c:let> - </c:splice> - </div> - </c:when> - <c:md class="node-body" - md="(gethash vkey node)"/> - <c:when test="refs"> - <div class="refs" > - <label>References:</label> - <c:splice iterate="refs"> - <c:let target="*"> - <a href="#{target}" - fill="href *" - lquery="(text target)"> - </a> - </c:let> - </c:splice> - </div> - </c:when> - <when test="children"> - <div class="node-children" iterate="children"> - <c:h>(ethics::make-node * (** :vkey) (** :types) (+ (** :level) 1))</c:h> - </div> - </when> - </div> -</c:let> +<div class = "node" lquery = "(attr :id id) (add-class type)"> + <c:expand class="headline" lquery="(attr :as (format nil &quot;h~a&quot; level))"> + <c:s> + (format nil "~a ~a" (gethash type types) (or (gethash "number" node) "")) + </c:s> + <a class="anchor" href="#{id}" fill="href *">#<c:s>id</c:s></a> + </c:expand> + <c:when test="backlinks"> + <div class="backlinks"> + <label>Referenced by:</label> + <c:splice iterate="backlinks"> + <c:let target="*"> + <a href="#{target}" + fill="href *" + lquery="(text target)"> + </a> + </c:let> + </c:splice> + </div> + </c:when> + <c:md class="node-body" + md="(gethash vkey node)"/> + <c:when test="refs"> + <div class="refs" > + <label>References:</label> + <c:splice iterate="refs"> + <c:let target="*"> + <a href="#{target}" + fill="href *" + lquery="(text target)"> + </a> + </c:let> + </c:splice> + </div> + </c:when> + <when test="children"> + <div class="node-children" iterate="children"> + <c:node node="*" + vkey="(** :vkey)" + types="(** :types)" + level="(** :level)"/> + </div> + </when> +</div> diff --git a/lisp/ethics.lisp b/lisp/ethics.lisp @@ -99,7 +99,12 @@ :node node :level level :vkey vkey - :types types)) + :types types + :id (gethash "id" node) + :type (gethash "type" node) + :refs (gethash "refs" node) + :backlinks (gethash :links node) + :children (gethash :child-nodes node))) (defun write-ethics (config) (destructuring-bind (ethica &rest versions) @@ -121,14 +126,28 @@ :language (getf version :language) :types (getf version :types)))))) +;; --- tag defs + (clip:define-tag-processor md (xml-node) (clip:process-attributes xml-node) (setf (plump:tag-name xml-node) "div") - (lquery:$1 xml-node (html (markdown:parse - (or (clip:resolve-attribute xml-node "md") - "")))) + (let ((md (clip:resolve-attribute xml-node "md" ""))) + (lquery:$1 xml-node (html (markdown:parse md)))) (plump:remove-attribute xml-node "md")) +(clip:define-tag-processor node (xml-node) + (clip:process-attributes xml-node) + (lquery:$1 xml-node + (html (make-node (clip:resolve-attribute xml-node "node") + (clip:resolve-attribute xml-node "vkey") + (clip:resolve-attribute xml-node "types") + (+ 1 (clip:resolve-attribute xml-node "level" 0))))) + (plump:remove-attribute xml-node "node") + (plump:remove-attribute xml-node "level") + (plump:remove-attribute xml-node "vkey") + (plump:remove-attribute xml-node "types") + (clip:process-tag "splice" xml-node)) + ;; --- plumbing (defmacro parse-args (&rest args)