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

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

Re: Convert the shell command used in emacs init-file into its normal ve


From: Yuri Khan
Subject: Re: Convert the shell command used in emacs init-file into its normal version.
Date: Wed, 9 Jun 2021 14:23:07 +0700

On Wed, 9 Jun 2021 at 13:49, Hongyi Zhao <hongyi.zhao@gmail.com> wrote:

> I found the following command from
> <https://github.com/jethrokuan/mathpix.el/blob/02016ca4aee9ffce32e730372f45de35c00a3657/mathpix.el#L49>:
>
> "curl -s https://api.mathpix.com/v3/latex -X POST -H \"app_id: %s\" -H
> \"app_key: %s\" -H \"Content-Type: application/json\" --data
> \"{\\\"src\\\":\\\"%s\\\",\\\"formats\\\":
> [\\\"latex_styled\\\"],\\\"format_options\\\":{\\\"latex_styled\\\":
> {\\\"transforms\\\": [\\\"rm_spaces\\\"]}}}\""
>
> I want to obtain its normal version and test it under the system's
> shell terminal. Any hints for deleting the escape characters correctly
> from the above command in Emacs way?

You have basically two options:

1. Knowing the string syntax rules, you can interpret the escapes in
your head, removing the double quotes at start and end and replacing
each \" → " and \\ → \.

2. Or you can use an Emacs function that accepts a string and causes
its interpreted contents to be inserted into some buffer, e.g.
(message "…") or (insert "…").

$ emacs -Q

(insert "curl -s https://api.mathpix.com/v3/latex -X POST -H \"app_id:
%s\" -H \"app_key: %s\" -H \"Content-Type: application/json\" --data
\"{\\\"src\\\":\\\"%s\\\",\\\"formats\\\":[\\\"latex_styled\\\"],\\\"format_options\\\":{\\\"latex_styled\\\":{\\\"transforms\\\":
[\\\"rm_spaces\\\"]}}}\"")

Either way, you get:

curl -s https://api.mathpix.com/v3/latex -X POST -H "app_id: %s" -H
"app_key: %s" -H "Content-Type: application/json" --data
"{\"src\":\"%s\",\"formats\":[\"latex_styled\"],\"format_options\":{\"latex_styled\":{\"transforms\":
[\"rm_spaces\"]}}}"

Before you can try this in your terminal, you’ll need to substitute
the %s placeholders.



reply via email to

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