help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: How to translate LaTeX into UTF-8 in Elisp?


From: Teemu Likonen
Subject: Re: How to translate LaTeX into UTF-8 in Elisp?
Date: Mon, 03 Jul 2017 11:37:22 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

Marcin Borkowski [2017-07-03 06:56:36+02] wrote:

> On 2016-12-08, at 18:04, Marcin Borkowski <mbork@mbork.pl> wrote:
>> I have a string with embedded sequences like "\'e" or "\H{o}".  The
>> Emacs TeX input method knows how to convert them into "é" or "ő" (when
>> typing, of course).  Is there a way to use that to perform similar
>> conversions in a string?

> I'm revisiting this old thread now.

> It is a horrible hack, but it should work.  Any better ideas?

I would filter buffer's content through recode command.

    [Highlight a region.]

    C-u M-x shell-command-on-region RET recode tex.. RET

You wanted to do this for a string so we can write a function that uses
a temporary buffer and returns its content as a string. Here is a quick
example:

    (defun convert-from-latex (string)
      (with-temp-buffer
        (insert string)
        (call-process-region (point-min) (point-max)
                             "recode" t t nil "tex..")
        (buffer-substring-no-properties (point-min) (point-max))))

-- 
/// Teemu Likonen   - .-..   <https://keybase.io/tlikonen> //
// PGP: 4E10 55DC 84E9 DFF6 13D7 8557 719D 69D3 2453 9450 ///

Attachment: signature.asc
Description: PGP signature


reply via email to

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