emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] export code with backslashes


From: hymie
Subject: Re: [O] export code with backslashes
Date: Mon, 16 Mar 2015 19:11:31 -0400

"Charles C. Berry" writes:
>On Mon, 16 Mar 2015, hymie! wrote:

>> useradd -U -G wheel -p \<newline>
>> '$6$wcMRrkcdGeNHLT5b$password0ISmGZSsILOyV/WJnpassword//' \<newline>
>> accountname <newline>
>>
>> Is such a thing possible?
>
>Yes.
>
>#+BEGIN_SRC emacs-lisp
>   (defun org-export-ascii-filter-code (text back-end info)
>   "Replace `\\n' with `\\' in ascii code."
>     (if (eq back-end 'ascii)
>         (replace-regexp-in-string
>          "\n" "\\\n"
>          (org-babel-chomp
>           (org-export-string-as text 'ascii t))
>          nil t)
>       text))
>   (add-to-list 'org-export-filter-code-functions
>                'org-export-ascii-filter-code)
>#+END_SRC

Awesome -- this is perfect.  (Note that, to be perfect, the
continuation lines need at least one leading space.)

>When I run this on your example, I get only one line break, but it is 
>preceeded by a backslash.

My original post had a much much longer password string, but the
web-to-news gateway demanded 80 characters or less, so I trimmed the
password but left in the line breaks.

>Naturally, you will need to adapt this up for other backends as a single 
>backslash might not be what is wanted.

I hope my programming skills are up to the task.  But it's certainly
a great jumping-off point.

Thank you.

--hymie!     http://lactose.homelinux.net/~hymie    address@hidden
My fitbit says I've walked 7009 steps today (as of 19:02).



reply via email to

[Prev in Thread] Current Thread [Next in Thread]