emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* DITAA and Unicode characters [babel]
@ 2011-04-24 23:38 Juan Pechiar
  2011-04-25 19:13 ` Eric Schulte
  0 siblings, 1 reply; 4+ messages in thread
From: Juan Pechiar @ 2011-04-24 23:38 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 960 bytes --]

Hi,

Out of the box, ob-ditaa does not work with non-ascii characters.

I looked into the problem in order to answer a user request on
StackOverflow (yes, there are org-mode questions posted there instead
of here!).

http://stackoverflow.com/questions/5758498/problem-with-ditaa-and-foreign-characters-in-org-mode

In order for ditaa to accept UTF-8 characters in the input file, it
must be called with the corresponding property setting:

   java -Dfile.encoding=UTF-8 -jar path/to/ditaa.jar ...

Attached is a dirty patch for hard-coding this property setting.

I don't know what the proper way of setting this property should be:

 - somehow setting it system-wide (any Java guru out there?).

 - or adding a customization to ob-ditaa.el for this property

 - or adding magic to ob-ditaa so that the same encoding of the buffer
   gets set to this Java property

I can help with the implementation if given some feedback on the above
options.

Regards,
.j.

[-- Attachment #2: ob-ditaa.el.diff --]
[-- Type: text/x-diff, Size: 506 bytes --]

diff --git a/lisp/ob-ditaa.el b/lisp/ob-ditaa.el
index 20b5c42..dc17a4d 100644
--- a/lisp/ob-ditaa.el
+++ b/lisp/ob-ditaa.el
@@ -55,7 +55,7 @@ This function is called by `org-babel-execute-src-block'."
 		    (cdr (assoc :file params))))
 	 (cmdline (cdr (assoc :cmdline params)))
 	 (in-file (org-babel-temp-file "ditaa-"))
-	 (cmd (concat "java -jar "
+	 (cmd (concat "java -Dfile.encoding=UTF-8 -jar "
 		      (shell-quote-argument
 		       (expand-file-name org-ditaa-jar-path))
 		      " " cmdline

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: DITAA and Unicode characters [babel]
  2011-04-24 23:38 DITAA and Unicode characters [babel] Juan Pechiar
@ 2011-04-25 19:13 ` Eric Schulte
  2011-04-26  0:27   ` Juan Pechiar
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Schulte @ 2011-04-25 19:13 UTC (permalink / raw)
  To: Juan Pechiar; +Cc: emacs-orgmode

Hi Juan,

Juan Pechiar <juan@pechiar.com> writes:

> Hi,
>
> Out of the box, ob-ditaa does not work with non-ascii characters.
>
> I looked into the problem in order to answer a user request on
> StackOverflow (yes, there are org-mode questions posted there instead
> of here!).
>
> http://stackoverflow.com/questions/5758498/problem-with-ditaa-and-foreign-characters-in-org-mode
>

Thanks for catching questions in these other forums.

>
> In order for ditaa to accept UTF-8 characters in the input file, it
> must be called with the corresponding property setting:
>
>    java -Dfile.encoding=UTF-8 -jar path/to/ditaa.jar ...
>

I just pushed up a change to ob-ditaa which adds a new header argument,
namely :java through which options can be passed to the java command.
With that patch the following should work

#+begin_src ditaa :file ... :cmdline -e utf-8 -r -v :java -Dfile.encoding=UTF-8
  ...
#+end_src

>
> Attached is a dirty patch for hard-coding this property setting.
>
> I don't know what the proper way of setting this property should be:
>
>  - somehow setting it system-wide (any Java guru out there?).
>
>  - or adding a customization to ob-ditaa.el for this property
>
>  - or adding magic to ob-ditaa so that the same encoding of the buffer
>    gets set to this Java property
>
> I can help with the implementation if given some feedback on the above
> options.
>

Now that there is a :java header argument for ditaa code, the following
could be put in a user's init file to set this flag for *all* ditaa code
run on their system.

#+begin_src emacs-lisp
  (push '(:java . "-Dfile.encoding=UTF-8") org-babel-default-header-args:ditaa)
#+end_src

I wonder if there would be any downside to adding this as a default
value?  This could be added to `org-babel-default-header-args:ditaa' in
ob-ditaa.el.

Best -- Eric

>
> Regards,
> .j.
>

-- 
Eric Schulte
http://cs.unm.edu/~eschulte/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: DITAA and Unicode characters [babel]
  2011-04-25 19:13 ` Eric Schulte
@ 2011-04-26  0:27   ` Juan Pechiar
  2011-04-26  0:58     ` Eric Schulte
  0 siblings, 1 reply; 4+ messages in thread
From: Juan Pechiar @ 2011-04-26  0:27 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode

On Mon, Apr 25, 2011 at 01:13:41PM -0600, Eric Schulte wrote:
> I just pushed up a change to ob-ditaa which adds a new header argument,
> namely :java through which options can be passed to the java command.
> With that patch the following should work
>
> #+begin_src ditaa :file ... :cmdline -e utf-8 -r -v :java -Dfile.encoding=UTF-8
>   ...
> #+end_src
>
> Now that there is a :java header argument for ditaa code, the following
> could be put in a user's init file to set this flag for *all* ditaa code
> run on their system.
>
> #+begin_src emacs-lisp
>   (push '(:java . "-Dfile.encoding=UTF-8") org-babel-default-header-args:ditaa)
> #+end_src

Works perfectly! Thanks!

> I wonder if there would be any downside to adding this as a default
> value?  This could be added to `org-babel-default-header-args:ditaa' in
> ob-ditaa.el.

I think it'd be a reasonable default that will work out-of-the-box for
most users.

In case of not using UTF-8, the user can override this setting at
will as you show above.

Regards,
.j.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: DITAA and Unicode characters [babel]
  2011-04-26  0:27   ` Juan Pechiar
@ 2011-04-26  0:58     ` Eric Schulte
  0 siblings, 0 replies; 4+ messages in thread
From: Eric Schulte @ 2011-04-26  0:58 UTC (permalink / raw)
  To: Juan Pechiar; +Cc: emacs-orgmode

Juan Pechiar <juan@pechiar.com> writes:

> On Mon, Apr 25, 2011 at 01:13:41PM -0600, Eric Schulte wrote:
>> I just pushed up a change to ob-ditaa which adds a new header argument,
>> namely :java through which options can be passed to the java command.
>> With that patch the following should work
>>
>> #+begin_src ditaa :file ... :cmdline -e utf-8 -r -v :java -Dfile.encoding=UTF-8
>>   ...
>> #+end_src
>>
>> Now that there is a :java header argument for ditaa code, the following
>> could be put in a user's init file to set this flag for *all* ditaa code
>> run on their system.
>>
>> #+begin_src emacs-lisp
>>   (push '(:java . "-Dfile.encoding=UTF-8") org-babel-default-header-args:ditaa)
>> #+end_src
>
> Works perfectly! Thanks!
>
>> I wonder if there would be any downside to adding this as a default
>> value?  This could be added to `org-babel-default-header-args:ditaa' in
>> ob-ditaa.el.
>
> I think it'd be a reasonable default that will work out-of-the-box for
> most users.
>

OK, this is now part of the default ditaa header arguments, we'll see if
anyone complains...

Best -- Eric

>
> In case of not using UTF-8, the user can override this setting at
> will as you show above.
>
> Regards,
> .j.

-- 
Eric Schulte
http://cs.unm.edu/~eschulte/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-04-26  0:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-24 23:38 DITAA and Unicode characters [babel] Juan Pechiar
2011-04-25 19:13 ` Eric Schulte
2011-04-26  0:27   ` Juan Pechiar
2011-04-26  0:58     ` Eric Schulte

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).