From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ben Feldman Subject: Custom source block for concept map markdown Date: Fri, 1 Jul 2016 15:14:27 +0200 Message-ID: <414D99AA-8249-430E-A5F2-D50E690624D0@gmx.de> Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53460) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIyHD-0002Px-K9 for emacs-orgmode@gnu.org; Fri, 01 Jul 2016 09:14:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bIyH9-0007f5-Cj for emacs-orgmode@gnu.org; Fri, 01 Jul 2016 09:14:34 -0400 Received: from mout.gmx.net ([212.227.17.21]:64266) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIyH9-0007eZ-1h for emacs-orgmode@gnu.org; Fri, 01 Jul 2016 09:14:31 -0400 Received: from olivers-mbp.fritz.box ([78.48.18.235]) by mail.gmx.com (mrgmx103) with ESMTPSA (Nemesis) id 0MTjMy-1asTC73rRQ-00QU8B for ; Fri, 01 Jul 2016 15:14:28 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org Hi, my goal is to create a custom source block to create concept maps. The = source block contains my custom made pseudo code. When exporting the org-file to LaTeX and PDF = this pseudo code must be translated to DOT code. This DOT code is interpreted by the = dot2texi package. The reason for the pseudo code is that it is more easy human readable. = The reason for dot2texi is that vanilla DOT does not allow for labels on edges, i.e. labels that = cross the edge. Here is an example of a concept map: = https://upload.wikimedia.org/wikipedia/commons/c/c3/Electricity_Concept_Ma= p.gif This is an example of my pseudo code for a single connection between two = concepts and a label for that connection: (Electricity) {is a form of} (Energy) As you see it looks like a sentence. The DOT code for this would look like this: "Electricity" -> "Energy" [label=3D"is a form of"]; Clearly, this doesn=E2=80=99t look like a proper sentence. Therefore I = concocted the following function that takes a region containing my pseudo code and translates it = to DOT code: (defun concept2dot (rStart rEnd) (interactive "r") (save-restriction (narrow-to-region rStart rEnd) (goto-char (point-min)) (while (re-search-forward "(\\([[:word:]].*\\)) = +{\\([[:word:]].*\\)} +(\\([[:word:]].*\\))" nil t) (replace-match (concat "\"" (match-string 1) "\"" " -> " "\"" = (match-string 3) "\"" " [label=3D\"" (match-string 2) "\"];") t nil)) ) ) After translating my pseudo code to DOT code a LaTeX source block with = that DOT code would look like this: #+LATEX_HEADER: \usepackage{dot2texi} #+LATEX_HEADER: \usepackage{tikz} #+LATEX_HEADER: \usetikzlibrary{shapes, arrows} #+BEGIN_LATEX \begin{dot2tex}[tikz, tikzedgelabels, options=3D{-t raw = --nodeoptions=3D'every node/.style=3D{text width=3D2cm, text centered, = rounded corners, fill=3Dblack!10}' --edgeoptions=3D"every = node/.style=3D{fill=3Dwhite, inner sep=3D1pt}"}] digraph G { node [shape=3Dbox, fixedsize=3Dtrue, width=3D1.2]; "Electricity" -> "Energy" [label=3D"is a form of"]; } \end{dot2tex} #+END_LATEX However, I want to avoid firstly translating my pseudo code manually by = selecting a region and applying my function to it. Secondly, I want to get rid of all the LaTeX code. Ideally the end result should look like = this: #+BEGIN_SRC conceptmap (Electricity) {is a form of} (Energy) (Energy) {that can exist in the form} (Lightning) (Energy) {that can exist in the form of} (Thunder) #+END_SRC When I export my org-file to LaTeX the translation into DOT code occurs = automatically. What would be the easiest way to achieve this result?=20 Thanks, B.F.