[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] [PATCH] Fix for double-escaping # and ![ in ox-md
From: |
Nicolas Goaziou |
Subject: |
Re: [O] [PATCH] Fix for double-escaping # and ![ in ox-md |
Date: |
Wed, 20 Dec 2017 23:07:39 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) |
Hello,
Kaushal Modi <address@hidden> 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