2019-07-05 19:49:56 +00:00
|
|
|
|
# -*- mode: org; -*-
|
|
|
|
|
#+AUTHOR: Lucien Cartier-Tilet
|
|
|
|
|
#+EMAIL: phundrak@phundrak.fr
|
2019-06-29 09:48:36 +00:00
|
|
|
|
#+CREATOR: Lucien Cartier-Tilet
|
|
|
|
|
#+LANGUAGE: fr
|
2019-07-05 19:49:56 +00:00
|
|
|
|
|
|
|
|
|
# ### LaTeX ####################################################################
|
|
|
|
|
|
2019-06-29 09:48:36 +00:00
|
|
|
|
#+LATEX_CLASS: article
|
2019-08-03 16:45:03 +00:00
|
|
|
|
#+LaTeX_CLASS_OPTIONS: [a5paper,twoside]
|
|
|
|
|
#+LATEX_HEADER: \usepackage{xltxtra,fontspec,xunicode}
|
2019-08-06 13:54:24 +00:00
|
|
|
|
#+LATEX_HEADER: \usepackage[total={11cm,17cm}]{geometry}
|
2019-08-03 16:45:03 +00:00
|
|
|
|
#+LATEX_HEADER: \setromanfont{Charis SIL}
|
|
|
|
|
#+LATEX_HEADER: \usepackage{xcolor}
|
|
|
|
|
#+LATEX_HEADER: \usepackage{hyperref}
|
2019-06-29 09:48:36 +00:00
|
|
|
|
#+LATEX_HEADER: \hypersetup{colorlinks=true,linkbordercolor=red,linkcolor=blue,pdfborderstyle={/S/U/W 1}}
|
2019-08-03 16:45:03 +00:00
|
|
|
|
#+LATEX_HEADER: \usepackage{multicol}
|
|
|
|
|
#+LATEX_HEADER: \usepackage{indentfirst}
|
|
|
|
|
#+LATEX_HEADER: \sloppy
|
2019-07-05 19:49:56 +00:00
|
|
|
|
|
|
|
|
|
# ### HTML #####################################################################
|
|
|
|
|
|
2019-06-29 09:48:36 +00:00
|
|
|
|
#+HTML_DOCTYPE: html5
|
2019-08-24 23:28:24 +00:00
|
|
|
|
#+HTML_HEAD: <script src="https://kit.fontawesome.com/4d42d0c8c5.js"></script>
|
2019-08-25 02:48:03 +00:00
|
|
|
|
#+HTML_HEAD: <script src="https://cdn.jsdelivr.net/npm/js-cookie@2/src/js.cookie.min.js"></script>
|
2019-06-29 09:48:36 +00:00
|
|
|
|
#+HTML_HEAD: <link rel="shortcut icon" href="https://cdn.phundrak.fr/img/mahakala-128x128.png" type="img/png" media="screen" />
|
|
|
|
|
#+HTML_HEAD: <link rel="shortcut icon" href="https://cdn.phundrak.fr/img/favicon.ico" type="image/x-icon" media="screen" />
|
|
|
|
|
#+HTML_HEAD: <meta property="og:image" content="https://cdn.phundrak.fr/img/rich_preview.png" />
|
|
|
|
|
#+HTML_HEAD: <meta name="twitter:card" content="summary" />
|
|
|
|
|
#+HTML_HEAD: <meta name="twitter:site" content="@phundrak" />
|
|
|
|
|
#+HTML_HEAD: <meta name="twitter:creator" content="@phundrak" />
|
2019-07-05 19:49:56 +00:00
|
|
|
|
|
2019-07-11 15:30:24 +00:00
|
|
|
|
# ### CODE #####################################################################
|
|
|
|
|
|
2019-08-14 00:55:02 +00:00
|
|
|
|
#+NAME: tree-dot
|
|
|
|
|
#+BEGIN_SRC emacs-lisp :noweb yes :exports none :eval yes :cache yes
|
|
|
|
|
(defun declare-node (node-text node-generation)
|
|
|
|
|
"Declares a node in the graphviz source code. The node’s identifier will be
|
|
|
|
|
~node-generation~, and it will bear the label ~node-text~."
|
|
|
|
|
(concat (number-to-string node-generation)
|
|
|
|
|
"[label=\""
|
|
|
|
|
node-text
|
|
|
|
|
"\"];"))
|
2019-07-11 15:30:24 +00:00
|
|
|
|
|
2019-08-14 00:55:02 +00:00
|
|
|
|
(defun make-link (previous-node current-node)
|
|
|
|
|
"This creates a link in the graphviz source code between the two nodes
|
|
|
|
|
bearing ~previous-node~ and ~current-node~ respectively as their node
|
|
|
|
|
identifier."
|
|
|
|
|
(concat (number-to-string previous-node) " -- "
|
|
|
|
|
(number-to-string current-node) ";"))
|
2019-07-11 15:30:24 +00:00
|
|
|
|
|
2019-08-14 00:55:02 +00:00
|
|
|
|
(defun tree-to-dot-helper (tree current-generation previous-generation)
|
|
|
|
|
"Helper to ~tree-to-dot~ that translates an Elisp tree with any number of
|
|
|
|
|
children per node to a corresponding graphviz file that can be executed from
|
|
|
|
|
dot.
|
|
|
|
|
Arguments:
|
|
|
|
|
- tree :: tree-to-convert
|
|
|
|
|
- current-generation :: Generation number, incremented when changing from a node
|
|
|
|
|
to another node from the same generation, multiplied by 10 when going from
|
|
|
|
|
a node to one of its children.
|
|
|
|
|
- previous-generation :: generation number from previous named node"
|
|
|
|
|
(cond
|
|
|
|
|
((null tree) "")
|
|
|
|
|
((atom (car tree)) ;; '("text" () () ())
|
|
|
|
|
(concat (declare-node (car tree) current-generation)
|
|
|
|
|
(make-link previous-generation current-generation)
|
|
|
|
|
(tree-to-dot-helper (cdr tree)
|
|
|
|
|
(+ 1 (* 10 current-generation))
|
|
|
|
|
current-generation)))
|
|
|
|
|
((listp (car tree)) ;; '(() () ())
|
|
|
|
|
(concat (tree-to-dot-helper (car tree) ;; child of current node
|
|
|
|
|
current-generation
|
|
|
|
|
previous-generation)
|
|
|
|
|
(tree-to-dot-helper (cdr tree)
|
|
|
|
|
(+ 1 current-generation)
|
|
|
|
|
previous-generation)))))
|
2019-07-11 15:30:24 +00:00
|
|
|
|
|
2019-08-14 00:55:02 +00:00
|
|
|
|
(defun tree-to-dot (tree)
|
|
|
|
|
"Returns a graphviz’s dot compatible string representing an Elisp tree"
|
|
|
|
|
(if (null tree) ""
|
|
|
|
|
(concat
|
|
|
|
|
"graph{node[shape=plaintext];graph[bgcolor=\"transparent\"];"
|
|
|
|
|
(declare-node (car tree) 0)
|
|
|
|
|
(tree-to-dot-helper (cdr tree) 1 0)
|
|
|
|
|
"}")))
|
2019-07-11 15:30:24 +00:00
|
|
|
|
#+END_SRC
|
|
|
|
|
|
2019-07-05 19:49:56 +00:00
|
|
|
|
# ### MACROS ###################################################################
|
2019-06-29 09:48:36 +00:00
|
|
|
|
#+MACRO: newline @@latex:\hspace{0pt}\\@@ @@html:<br>@@
|
|
|
|
|
#+MACRO: newpage @@latex:\newpage@@
|
2019-08-24 23:28:24 +00:00
|
|
|
|
#+MACRO: latex-html @@latex:$1@@@@html:$2@@
|
|
|
|
|
#+MACRO: phon @@latex:/$1/@@@@html:/$1/@@
|
|
|
|
|
#+MACRO: v @@latex:\rotatebox[origin=c]{270}{$1}@@@@html:<span class=vertical>$1</span>@@
|
2019-07-17 12:49:52 +00:00
|
|
|
|
#+MACRO: begin-largetable @@html:<div class="largetable">@@
|
|
|
|
|
#+MACRO: end-largetable @@html:</div>@@
|
2019-07-11 01:22:20 +00:00
|
|
|
|
#+OPTIONS: H:4 broken_links:mark email:t ^:{}
|