Add function for generating graphviz trees from Org lists
This commit is contained in:
		
							parent
							
								
									77799b0e96
								
							
						
					
					
						commit
						c1ee222337
					
				@ -55,6 +55,38 @@ bear the label `T-NODE-TEXT'."
 | 
			
		||||
          t-node-generation
 | 
			
		||||
          t-node-text))
 | 
			
		||||
 | 
			
		||||
(defun conlanging--declare-node-for-list (t-name t-label)
 | 
			
		||||
    (format "\"%s\"[label=\"%s\"];"
 | 
			
		||||
            t-name
 | 
			
		||||
            t-label))
 | 
			
		||||
 | 
			
		||||
;;;###autoload
 | 
			
		||||
(defun conlanging-list-to-graphviz (t-list &optional t-previous-node)
 | 
			
		||||
  (cond
 | 
			
		||||
   ((null t-previous-node)
 | 
			
		||||
    (let* ((list (car t-list))
 | 
			
		||||
           (label (car list))
 | 
			
		||||
           (label-name (concat label "-" (org-id-time-to-b36))))
 | 
			
		||||
      (concat "graph{graph[dpi=300,bgcolor=\"transparent\"];node[shape=plaintext];"
 | 
			
		||||
              (conlanging--declare-node-for-list label-name label)
 | 
			
		||||
              (conlanging-list-to-graphviz (cdadr list) label-name)
 | 
			
		||||
              "}")))
 | 
			
		||||
   ((null t-list) "")
 | 
			
		||||
   ((listp t-list)
 | 
			
		||||
    (let* ((graph-str ""))
 | 
			
		||||
      (dolist (elem t-list graph-str)
 | 
			
		||||
        (let* ((label (car elem))
 | 
			
		||||
               (label-name (concat label "-" (org-id-time-to-b36))))
 | 
			
		||||
          (setf graph-str
 | 
			
		||||
                (format "%s%s\"%s\"--\"%s\";%s"
 | 
			
		||||
                        graph-str
 | 
			
		||||
                        (conlanging--declare-node-for-list label-name label)
 | 
			
		||||
                        t-previous-node
 | 
			
		||||
                        label-name
 | 
			
		||||
                        (conlanging-list-to-graphviz (cdadr elem)
 | 
			
		||||
                                                     label-name)))))))))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
;;;###autoload
 | 
			
		||||
(defun conlanging-tree-to-dot (t-tree &optional t-current-generation t-previous-generation)
 | 
			
		||||
  "Translate an Elisp tree into a graphviz tree.
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user