86 lines
3.7 KiB
Org Mode
86 lines
3.7 KiB
Org Mode
# -*- mode: org; -*-
|
|
#+AUTHOR: Lucien Cartier-Tilet
|
|
#+EMAIL: phundrak@phundrak.fr
|
|
#+CREATOR: Lucien Cartier-Tilet
|
|
#+LANGUAGE: fr
|
|
|
|
# ### LaTeX ####################################################################
|
|
|
|
#+LATEX_CLASS: article
|
|
#+LaTeX_CLASS_OPTIONS: [a5paper,twoside]
|
|
#+LATEX_HEADER: \usepackage{xltxtra,fontspec,xunicode}
|
|
#+LATEX_HEADER: \usepackage[total={11cm,17cm}]{geometry}
|
|
#+LATEX_HEADER: \setromanfont{Charis SIL}
|
|
#+LATEX_HEADER: \usepackage{xcolor}
|
|
#+LATEX_HEADER: \usepackage{hyperref}
|
|
#+LATEX_HEADER: \hypersetup{colorlinks=true,linkbordercolor=red,linkcolor=blue,pdfborderstyle={/S/U/W 1}}
|
|
#+LATEX_HEADER: \usepackage{multicol}
|
|
#+LATEX_HEADER: \usepackage{indentfirst}
|
|
#+LATEX_HEADER: \sloppy
|
|
|
|
# ### HTML #####################################################################
|
|
|
|
#+HTML_DOCTYPE: html5
|
|
#+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" />
|
|
|
|
# ### CODE #####################################################################
|
|
|
|
#+NAME: process-tree
|
|
#+BEGIN_SRC scheme :noweb yes :exports none :eval yes :cache yes
|
|
;; Original commented source code hosted on Phundrak Labs:
|
|
;; https://labs.phundrak.fr/phundrak/features-tree
|
|
|
|
(define (atom? elem)
|
|
(not (pair? elem)))
|
|
|
|
(define (declare-node node-text node-generation)
|
|
(string-append ;; "node"
|
|
(number->string node-generation)
|
|
"[label=\""
|
|
node-text
|
|
"\"];"))
|
|
|
|
(define (make-link previous-node current-node)
|
|
(string-append (number->string previous-node) " -- "
|
|
(number->string current-node) ";"))
|
|
|
|
(define (tree-to-dot-helper tree current-generation previous-generation)
|
|
(cond ((null? tree) "")
|
|
((atom? (car tree))
|
|
(string-append (declare-node (car tree) current-generation)
|
|
(make-link previous-generation current-generation)
|
|
(tree-to-dot-helper (cdr tree)
|
|
(+ 1 (* 10 current-generation))
|
|
current-generation)))
|
|
((list? (car tree))
|
|
(string-append (tree-to-dot-helper (car tree)
|
|
current-generation
|
|
previous-generation)
|
|
(tree-to-dot-helper (cdr tree)
|
|
(+ 1 current-generation)
|
|
previous-generation)))))
|
|
|
|
(define (tree-to-dot tree)
|
|
(if (null? tree) ""
|
|
(string-append
|
|
"graph{node[shape=plaintext];graph[bgcolor=\"transparent\"];"
|
|
(declare-node (car tree) 0)
|
|
(tree-to-dot-helper (cdr tree) 1 0)
|
|
"}")))
|
|
#+END_SRC
|
|
|
|
# ### MACROS ###################################################################
|
|
#+MACRO: newline @@latex:\hspace{0pt}\\@@ @@html:<br>@@
|
|
#+MACRO: newpage @@latex:\newpage@@
|
|
#+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>@@
|
|
#+MACRO: begin-largetable @@html:<div class="largetable">@@
|
|
#+MACRO: end-largetable @@html:</div>@@
|
|
#+OPTIONS: H:4 broken_links:mark email:t ^:{}
|