From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: Kaushal Modi <kaushal.modi@gmail.com>
Cc: emacs-org list <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] Fix for double-escaping # and ![ in ox-md
Date: Wed, 20 Dec 2017 23:07:39 +0100 [thread overview]
Message-ID: <87shc5hx3o.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <CAFyQvY1ZMxjcj4nA3TADUuahx6wJNmjYvzOaJpBpLGmdM=YE6g@mail.gmail.com> (Kaushal Modi's message of "Wed, 20 Dec 2017 18:02:33 +0000")
Hello,
Kaushal Modi <kaushal.modi@gmail.com> writes:
> Note that the # and ![ are double-escaped. So any markdown->HTML renderer
> will print that "\" as it is.
>
> Digging through ox-md.el, I found that the order of
> replace-regexp-in-string was incorrect in org-md-plain-text.
>
> Here's the diff:
>
> =====
> diff --git a/lisp/ox-md.el b/lisp/ox-md.el
> index 12188387355..927a73b780c 100644
> --- a/lisp/ox-md.el
> +++ b/lisp/ox-md.el
> @@ -500,14 +500,15 @@ TEXT is the string to transcode. INFO is a plist
> holding
> contextual information."
> (when (plist-get info :with-smart-quotes)
> (setq text (org-export-activate-smart-quotes text :html info)))
> + ;; The below series of replacements in `text' is order sensitive.
> + ;; Protect `, *, _, and \
> + (setq text (replace-regexp-in-string "[`*_\\]" "\\\\\\&" text))
> ;; Protect ambiguous #. This will protect # at the beginning of
> ;; a line, but not at the beginning of a paragraph. See
> ;; `org-md-paragraph'.
> (setq text (replace-regexp-in-string "\n#" "\n\\\\#" text))
> ;; Protect ambiguous !
> (setq text (replace-regexp-in-string "\\(!\\)\\[" "\\\\!" text nil nil
> 1))
> - ;; Protect `, *, _ and \
> - (setq text (replace-regexp-in-string "[`*_\\]" "\\\\\\&" text))
> ;; Handle special strings, if required.
> (when (plist-get info :with-special-strings)
> (setq text (org-html-convert-special-strings text)))
> =====
>
> After applying this patch, the same portion exported doesn't have
> double-escaping before # and ![.
>
> If this looks good, I can commit this to maint.
It looks good. Thank you.
Regards,
--
Nicolas Goaziou
next prev parent reply other threads:[~2017-12-20 22:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-20 18:02 [PATCH] Fix for double-escaping # and ![ in ox-md Kaushal Modi
2017-12-20 22:07 ` Nicolas Goaziou [this message]
2017-12-20 22:17 ` Kaushal Modi
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87shc5hx3o.fsf@nicolasgoaziou.fr \
--to=mail@nicolasgoaziou.fr \
--cc=emacs-orgmode@gnu.org \
--cc=kaushal.modi@gmail.com \
/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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.