[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Chaining strings between babel blocks: why so many '\'?
From: |
Alan Schmitt |
Subject: |
Re: [O] Chaining strings between babel blocks: why so many '\'? |
Date: |
Thu, 27 Mar 2014 13:41:03 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (darwin) |
Hello Nicolas,
Nicolas Goaziou <address@hidden> writes:
> Hello,
>
> Alan Schmitt <address@hidden> writes:
>
>> I've been playing with block chaining to generate some dot file then to
>> export then as images. I had a little trouble finding the number of '\'
>> I need to put in front of a quote if I want the quote to be quoted. Here
>> is a way to make it work:
>>
>> #+name: foo
>> #+begin_src emacs-lisp :exports none
>> "bar [label = \"\\\\\"test1\\\\\"\"]\nbaz [label = \"\\\\\"test2\\\\\"\"]"
>> #+end_src
>>
>> #+results: foo
>> : bar [label = "\\"test1\\""]
>> : baz [label = "\\"test2\\""]
>>
>> #+begin_src dot :file ~/tmp/test-dot.png :var input=foo :exports results
>> graph {
>> $input
>> }
>> #+end_src
>>
>> My question is: why can't I simply use this:
>>
>> #+name: foo
>> #+begin_src emacs-lisp :exports none
>> "bar [label = \"\\\"test1\\\"\"]\nbaz [label = \"\\\"test2\\\"\"]"
>> #+end_src
>>
>> #+results: foo
>> : bar [label = "\"test1\""]
>> : baz [label = "\"test2\""]
>>
>> (I guess the answer is in the error in replace-regexp-in-string:
>> (error "Invalid use of `\\' in replacement text")
>> .)
>
> Indeed. This function, unless told not to, treats backslashes characters
> specially.
>
>> Would it be problematic to first transform every "\\" into a "\\\\" in
>> org-babel-expand-body:dot, before the call to
>> replace-regexp-in-string?
>
> I think `replace-regexp-in-string' should be called with a non-nil
> LITERAL argument in this case.
Yes. I think it should also not try to mach the case (i.e., FIXEDCASE
should be non-nil). Here is a patch to do that.
0001-ob-dot.el-Substitute-variables-literally.patch
Description: Text Data
Best,
Alan