summaryrefslogtreecommitdiffstats
path: root/site/cleopatra
diff options
context:
space:
mode:
authorThomas Letan <lthms@soap.coffee>2020-02-26 22:10:54 +0100
committerThomas Letan <lthms@soap.coffee>2020-02-26 22:14:37 +0100
commite6cd97fc89131f10787e39b7c68368a67b6709af (patch)
treea975a48816a128b765b85d71063caff60f51189a /site/cleopatra
parentImproving the end of the Bootstrapping cleopatra document (diff)
Display source blocks names and tangle filenames in HTML output
Diffstat (limited to 'site/cleopatra')
-rw-r--r--site/cleopatra/Bootstrap.org9
-rw-r--r--site/cleopatra/Contents/Org.org46
2 files changed, 52 insertions, 3 deletions
diff --git a/site/cleopatra/Bootstrap.org b/site/cleopatra/Bootstrap.org
index 67073a5..e0dd453 100644
--- a/site/cleopatra/Bootstrap.org
+++ b/site/cleopatra/Bootstrap.org
@@ -67,7 +67,6 @@ In a nutshell,
#+BEGIN_SRC org
#+BEGIN_SRC makefile :tangle ../../Makefile :noweb yes
#+END_SRC
-
- ~CLEODIR~ ::
Tell *~cleopatra~* where its sources live. If you place it inside the ~site/~
directory (as it is intended), and you enable the use of ~org~ files to author
@@ -244,7 +243,9 @@ ${PROC}.mk ${AUX} &:\\
CONFIGURE += ${PROC}.mk ${AUX}
-.PHONY : ${PROC}-prebuild ${PROC}-build ${PROC}-postbuild
+.PHONY : ${PROC}-prebuild \\
+ ${PROC}-build \\
+ ${PROC}-postbuild
EOF
#+END_SRC
@@ -388,7 +389,9 @@ echo ${END_MARKER} >> .gitignore
#+BEGIN_SRC makefile :tangle bootstrap.mk
ignore :
@echo " update gitignore"
- @scripts/update-gitignore.sh ${ARTIFACTS} ${CONFIGURE}
+ @scripts/update-gitignore.sh \
+ ${ARTIFACTS} \
+ ${CONFIGURE}
clean :
@rm -rf ${ARTIFACTS}
diff --git a/site/cleopatra/Contents/Org.org b/site/cleopatra/Contents/Org.org
index cdb0ad6..db1b534 100644
--- a/site/cleopatra/Contents/Org.org
+++ b/site/cleopatra/Contents/Org.org
@@ -53,6 +53,37 @@
(setq org-confirm-babel-evaluate nil)
(setq org-export-with-toc nil)
+(setq org-babel-exp-code-template
+ (concat "#+BEGIN_SRC %lang%switches%flags "
+ ":tangle %tangle :name %name\n"
+ "%body\n"
+ "#+END_SRC"))
+
+(defun cleopatra-html-src-block (oldfun src-block contents info)
+ (let*
+ ((old-ret (funcall oldfun src-block contents info))
+ (pars (org-babel-parse-header-arguments
+ (org-element-property :parameters src-block)))
+ (tangle (cdr (assoc :tangle pars)))
+ (name (cdr (assoc :name pars))))
+ (cond
+ (name
+ (concat
+ "<div class=\"org-literate-programming\">"
+ (format "<div class=\"org-src-name\">&lt;&lt%s&gt;&gt :=</div>" name)
+ old-ret
+ "</div>"))
+ ((not (string= tangle "no"))
+ (concat
+ "<div class=\"org-literate-programming\">"
+ old-ret
+ (format "<div class=\"org-src-tangled-to\">%s</div>" tangle)
+ "</div>"))
+ (t old-ret))))
+
+(advice-add 'org-html-src-block
+ :around #'cleopatra-html-src-block)
+
(org-html-export-to-html nil nil nil t)
#+END_SRC
@@ -110,4 +141,19 @@ dl
font-weight: bold
dd p
margin-top: 0
+
+.org-literate-programming
+ .org-src-name
+ font-family: 'Fira Code', monospace
+ font-weight: bold
+ font-size: 80%
+
+ .org-src-tangled-to:before
+ content: "той"
+
+ .org-src-tangled-to
+ font-family: 'Fira Code', monospace
+ font-weight: bold
+ font-size: 80%
+ text-align: right
#+END_SRC