Compare commits

..
3 Commits
Author SHA1 Message Date
phundrak 72da663163 Variables documentation 2020-01-29 22:01:38 +01:00
phundrak 6f26d36bae Simplified tree-to-dot 2020-01-29 21:49:21 +01:00
phundrak a14464f407 Now a proper variable with documentation 2020-01-29 21:48:56 +01:00
+157 -148
View File
@@ -15,52 +15,43 @@
(defun conlanging//declare-node (node-text node-generation) (defun conlanging//declare-node (node-text node-generation)
"Declares a node in the graphviz source code. The node’s identifier will be "Declares a node in the graphviz source code. The node’s identifier will be
~node-generation~, and it will bear the label ~node-text~." ~node-generation~, and it will bear the label ~node-text~."
(concat (number-to-string node-generation) (format "%d[label=\"%s\"];\n" node-generation
"[label=\"" node-text))
node-text
"\"];"))
(defun conlanging//make-link (previous-node current-node) (defun conlanging/tree-to-dot (tree &optional current-generation previous-generation)
"This creates a link in the graphviz source code between the two nodes "Translates an Elisp tree with any number of children per node
bearing ~previous-node~ and ~current-node~ respectively as their node to a corresponding graphviz file that can be executed from dot.
identifier."
(concat (number-to-string previous-node) " -- "
(number-to-string current-node) ";"))
(defun conlanging//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: Arguments:
- tree :: tree-to-convert - `tree': tree to convert
- current-generation :: Generation number, incremented when changing from a node - `current-generation': generation number, incremented when
to another node from the same generation, multiplied by 10 when going from changing from a node to another node from the same generation,
a node to one of its children. multiplied by 10 when going from a node to one of its children.
- previous-generation :: generation number from previous named node" - `previous-generation': generation number from previous named
node"
(cond (cond
((null tree) "") ((null previous-generation) ;; first call
((atom (car tree)) ;; '("text" () () ()) (concat "graph{graph[dpi=300];node[shape=plaintext];graph[bgcolor=\"transparent\"];\n"
(concat (conlanging//declare-node (car tree) current-generation) (conlanging//declare-node (car tree) 0)
(conlanging//make-link previous-generation current-generation) (conlanging/tree-to-dot (cdr tree) 1 0)
(conlanging//tree-to-dot-helper (cdr tree) "}"))
(+ 1 (* 10 current-generation)) ((null tree) "") ;; last call in this branch
current-generation))) ((atom (car tree)) ;; '("text" () () ()) manage the label
((listp (car tree)) ;; '(() () ()) (concat (conlanging//declare-node (car tree)
(concat (conlanging//tree-to-dot-helper (car tree) ;; child of current node current-generation)
current-generation ;; make link
previous-generation) (concat (number-to-string previous-generation) " -- "
(conlanging//tree-to-dot-helper (cdr tree) (number-to-string current-generation) ";\n")
(+ 1 current-generation) (conlanging/tree-to-dot (cdr tree)
previous-generation))))) (+ 1
(* 10 current-generation))
(defun conlanging/tree-to-dot (tree) current-generation)))
"Returns a graphviz’s dot compatible string representing an Elisp tree" ((listp (car tree)) ;; '(() () ()) manage the branches
(if (null tree) "" (concat (conlanging/tree-to-dot (car tree) ;; child of current node
(concat current-generation
"graph{graph[dpi=300];node[shape=plaintext];graph[bgcolor=\"transparent\"];" previous-generation)
(conlanging//declare-node (car tree) 0) (conlanging/tree-to-dot (cdr tree)
(conlanging//tree-to-dot-helper (cdr tree) 1 0) (+ 1 current-generation)
"}"))) previous-generation)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Common ; ; Common ;
@@ -120,70 +111,81 @@ whose first element equals `elem'"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Mattér ; ; Mattér ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq conlanging//matter-latin-to-runes '((", *" . "᛬") (defvar conlanging//matter-latin-to-runes '((", *" . "᛬")
("\\. *" . "᛭") ("\\. *" . "᛭")
(" +" . "᛫") (" +" . "᛫")
("ċ" . "ᛇ") ("ċ" . "ᛇ")
("ch" . "ᛇ") ("ch" . "ᛇ")
("ae" . "ᚫ") ("ae" . "ᚫ")
("æ" . "ᚫ") ("æ" . "ᚫ")
("dh" . "ᛋ") ("dh" . "ᛋ")
("z" . "ᛋ") ("z" . "ᛋ")
("ð" . "ᛋ") ("ð" . "ᛋ")
("th" . "ᚦ") ("th" . "ᚦ")
("s" . "ᚦ") ("s" . "ᚦ")
("þ" . "ᚦ") ("þ" . "ᚦ")
("w" . "ᚹ") ("w" . "ᚹ")
("ƿ" . "ᚹ") ("ƿ" . "ᚹ")
("g" . "ᚷ") ("g" . "ᚷ")
("ᵹ" . "ᚷ") ("ᵹ" . "ᚷ")
("ea" . "ᛠ") ("ea" . "ᛠ")
("f" . "ᚠ") ("f" . "ᚠ")
("u" . "ᚢ") ("u" . "ᚢ")
("o" . "ᚩ") ("o" . "ᚩ")
("r" . "ᚱ") ("r" . "ᚱ")
("c" . "ᚳ") ("c" . "ᚳ")
("h" . "ᚻ") ("h" . "ᚻ")
("n" . "ᚾ") ("n" . "ᚾ")
("i" . "ᛁ") ("i" . "ᛁ")
("j" . "ᛄ") ("j" . "ᛄ")
("p" . "ᛈ") ("p" . "ᛈ")
("v" . "ᛝ") ("v" . "ᛝ")
("t" . "ᛏ") ("t" . "ᛏ")
("b" . "ᛒ") ("b" . "ᛒ")
("e" . "ᛖ") ("e" . "ᛖ")
("m" . "ᛗ") ("m" . "ᛗ")
("l" . "ᛚ") ("l" . "ᛚ")
("d" . "ᛞ") ("d" . "ᛞ")
("é" . "ᛟ") ("é" . "ᛟ")
("a" . "ᚪ") ("a" . "ᚪ")
("y" . "ᚣ"))) ("y" . "ᚣ"))
"Equivalence between the Mattér orthography in the Latin script
and the Runic script. The first element of a pair is the Latin
script orthography, the second is the Runic equivalent.")
(setq conlanging//matter-latin-to-native '((" +" . " ") (defvar conlanging//matter-latin-to-native '((" +" . " ")
("ch" . "ċ") ("ch" . "ċ")
("ae" . "æ") ("ae" . "æ")
("th" . "þ") ("th" . "þ")
("s" . "þ") ("s" . "þ")
("dh" . "ð") ("dh" . "ð")
("z" . "ð") ("z" . "ð")
("w" . "ƿ") ("w" . "ƿ")
("j" . "i"))) ("j" . "i"))
"Equivalence between the Mattér orthography in its native Latin
script and the transliterated Mattér Latin script. The first
element of a pair is the transliterated Latin script orthography,
the second is the native Latin script equivalent.")
(setq conlanging//matter-latin-to-latex '((", *" . ":") (defvar conlanging//matter-latin-to-latex '((", *" . ":")
("\\. *" . "*") ("\\. *" . "*")
(" +" . ".") (" +" . ".")
("ch" . "I") ("ch" . "I")
("ċ" . "I") ("ċ" . "I")
("ae" . "æ") ("ae" . "æ")
("ea" . "\\\\ea") ("ea" . "\\\\ea")
("ƿ" . "w") ("ƿ" . "w")
("dh" . "s") ("dh" . "s")
("z" . "s") ("z" . "s")
("ð" . "s") ("ð" . "s")
("th" . "þ") ("th" . "þ")
("s" . "þ") ("s" . "þ")
("v" . "\\\\ng") ("v" . "\\\\ng")
("é " . "\\\\oe"))) ("é " . "\\\\oe"))
"Equivalence between the Mattér orthography in the Latin script
and the LaTeX code for the Runic script. The first element of a
pair is the Latin script orthography, the second is the Runic
LaTeX code equivalent.")
(defun conlanging/matter-to-runes () (defun conlanging/matter-to-runes ()
"Replaces transliterated Mattér with its runic writing system" "Replaces transliterated Mattér with its runic writing system"
@@ -202,8 +204,8 @@ latin writing system"
(conlanging//replace-char-by-table conlanging//matter-latin-to-latex)) (conlanging//replace-char-by-table conlanging//matter-latin-to-latex))
(defun conlanging/matter-org-export-runes (text) (defun conlanging/matter-org-export-runes (text)
"Replaces transliterated Mattér with its corresponding runes during org-mode "Replaces the transliterated Mattér `text' with its
export" corresponding runes during org-mode export"
(interactive) (interactive)
(if (org-export-derived-backend-p org-export-current-backend (if (org-export-derived-backend-p org-export-current-backend
'latex) 'latex)
@@ -215,48 +217,55 @@ export"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Eittlanda ; ; Eittlanda ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq conlanging//eittlanda-latin-to-latex '((", *" . "\\\\tripledot") (defvar conlanging//eittlanda-latin-to-latex '((", *" . "\\\\tripledot")
("\\. *" . "\\\\tripledot") ("\\. *" . "\\\\tripledot")
(" +" . ":") (" +" . ":")
("hv" . "x") ("hv" . "x")
("ø" . "\\\\o") ("ø" . "\\\\o")
("œ" . "\\\\oO") ("œ" . "\\\\oO")
("v" . "w") ("v" . "w")
("ó" . "v") ("ó" . "v")
("ń" . "\\\\ndot"))) ("ń" . "\\\\ndot"))
"Equivalence between the Eittlandic orthography in the Latin
script and the LaTeX code for the Runic script. The first element
of a pair is the Latin script orthography, the second is the
Runic LaTeX code equivalent.")
(setq conlanging//eittlanda-latin-to-runes '((", *" . "⁝") (defvar conlanging//eittlanda-latin-to-runes '((", *" . "⁝")
("\\. *" . "⁝") ("\\. *" . "⁝")
(" +" . "᛬") (" +" . "᛬")
(":" . "᛬") (":" . "᛬")
("hv" . "ᛪ") ("hv" . "ᛪ")
("i" . "ᛁ") ("i" . "ᛁ")
("y" . "ᛦ") ("y" . "ᛦ")
("u" . "ᚢ") ("u" . "ᚢ")
("e" . "ᛂ") ("e" . "ᛂ")
("ø" . "ᚯ") ("ø" . "ᚯ")
("o" . "ᚮ") ("o" . "ᚮ")
("œ" . "ᚰ") ("œ" . "ᚰ")
("ó" . "ᚤ") ("ó" . "ᚤ")
("æ" . "ᛅ") ("æ" . "ᛅ")
("a" . "ᛆ") ("a" . "ᛆ")
("m" . "ᛘ") ("m" . "ᛘ")
("n" . "ᚾ") ("n" . "ᚾ")
("ń" . "ᛀ") ("ń" . "ᛀ")
("p" . "ᛔ") ("p" . "ᛔ")
("b" . "ᛒ") ("b" . "ᛒ")
("t" . "ᛐ") ("t" . "ᛐ")
("d" . "ᛑ") ("d" . "ᛑ")
("k" . "ᚴ") ("k" . "ᚴ")
("g" . "ᚵ") ("g" . "ᚵ")
("f" . "ᚠ") ("f" . "ᚠ")
("þ" . "ᚦ") ("þ" . "ᚦ")
("ð" . "ᚧ") ("ð" . "ᚧ")
("s" . "ᛋ") ("s" . "ᛋ")
("h" . "ᚼ") ("h" . "ᚼ")
("v" . "ᚥ") ("v" . "ᚥ")
("r" . "ᚱ") ("r" . "ᚱ")
("l" . "ᛚ"))) ("l" . "ᛚ"))
"Equivalence between the Eittlandic orthography in the Latin
script and the Runic script. The first element of a pair is the
Latin script orthography, the second is the Runic equivalent.")
(defun conlanging/eittlanda-to-runes () (defun conlanging/eittlanda-to-runes ()
"Replaces transliterated Eittlandic with its runic writing system" "Replaces transliterated Eittlandic with its runic writing system"