unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Marcin Borkowski <mbork@mbork.pl>
To: Teemu Likonen <tlikonen@iki.fi>
Cc: Help Gnu Emacs mailing list <help-gnu-emacs@gnu.org>
Subject: Re: How to translate LaTeX into UTF-8 in Elisp?
Date: Tue, 04 Jul 2017 07:57:53 +0200	[thread overview]
Message-ID: <87o9t0217i.fsf@jane> (raw)
In-Reply-To: <87bmp1ykzh.fsf@imladris.arda>


On 2017-07-03, at 10:37, Teemu Likonen <tlikonen@iki.fi> wrote:

> 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))))

Thanks, I didn't know about recode.  But it doesn't work all that well:
c{\c c}c does not remove braces, for instance, and what's even worse, it
apparently doesn't know about \k.

But thanks anyway, this is a good thing to remember, even though in my
case I perceive it as even more hackish than my approach (I'd prefer
Emacs to do the job, not an external utility).

Best,

-- 
Marcin Borkowski



  reply	other threads:[~2017-07-04  5:57 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-08 17:04 How to translate LaTeX into UTF-8 in Elisp? Marcin Borkowski
2016-12-08 18:21 ` Carlos Konstanski
2016-12-08 19:13   ` Marcin Borkowski
2016-12-08 22:12 ` Stefan Monnier
2017-01-27 11:48   ` Marcin Borkowski
2017-01-28  8:15 ` Kendall Shaw
2017-07-03  4:56 ` Marcin Borkowski
2017-07-03  5:43   ` Emanuel Berg
2017-07-03  9:16     ` Marcin Borkowski
2017-07-03  9:31       ` tomas
2017-07-04  5:55         ` Marcin Borkowski
2017-07-03 10:24       ` Emanuel Berg
2017-07-03 17:36         ` Marcin Borkowski
2017-07-03 20:01           ` Emanuel Berg
2017-07-04 10:23           ` Héctor Lahoz
2017-07-03  8:37   ` Teemu Likonen
2017-07-04  5:57     ` Marcin Borkowski [this message]
2017-07-04  7:13       ` Udyant Wig
2017-07-04  9:27         ` Thien-Thi Nguyen
2017-07-04 20:37           ` Emanuel Berg
2017-07-05  7:05           ` Udyant Wig
2017-07-05 16:06             ` Emanuel Berg
2017-07-13 17:45             ` Thien-Thi Nguyen
2017-07-14  1:48               ` Udyant Wig
2017-07-04 11:18   ` Joost Kremers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87o9t0217i.fsf@jane \
    --to=mbork@mbork.pl \
    --cc=help-gnu-emacs@gnu.org \
    --cc=tlikonen@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).