emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Lawrence Mitchell <wence@gmx.li>
To: emacs-orgmode@gnu.org
Subject: [PATCH] Prefer matching line beginnings in org-export-latex-special-chars
Date: Mon, 28 Mar 2011 16:17:32 +0100	[thread overview]
Message-ID: <m3pqpbz33n.fsf@e4300lm.epcc.ed.ac.uk> (raw)
In-Reply-To: 20110327034819.29b9ee51@bhishma.homelinux.net

* lisp/org-latex.el (org-export-latex-special-chars): Fix regexp for
`single' special characters and ellipsis.

Repeated special characters are exported differently depending on
their position in the buffer.  A "&&" string at the start of a line is
exported as "&\&" whereas in the middle of a line you get "\&\&".  The
former is incorrect.  Fix this by matching the beginning of a line
before a character.  While we're at it, amalgamate the regexps for the
different special characters.
---

Suvayu Ali wrote:
> Hi Orgers,

> I wanted to insert comments in the exported tex file for latex export.
> Is there an standard way to do that? I found normal '%text' gets
> exported as '\%text'. However I can export comments by putting
> '%%text', it gets exported as '%\%text'.

Although this feels like a potentially useful feature, I believe
it is a bug.  Doubled special characters are exported differently
depending on where they are on a line:

&& foo

=> &\& foo

whereas

foo &&

=> foo \&\&

This is because the regexp for finding special characters prefers
matching a character over the start of a line \\(.\\|^\\)\\(&\\)
will set (match-string 1) to & and (match-string 2) to & if &&
occurs at the start of a line, although the intention is that
(match-string 1) should be the empty line-start string and
(match-string 2) the first ampersand.  We can fix this by
changing the regexp to \\(^\\|.\\)\\(&\\) as in this patch.

Cheers,
Lawrence

 lisp/org-latex.el |    8 +-------
 1 files changed, 1 insertions(+), 7 deletions(-)

diff --git a/lisp/org-latex.el b/lisp/org-latex.el
index 605795c..30f7b4a 100644
--- a/lisp/org-latex.el
+++ b/lisp/org-latex.el
@@ -1684,13 +1684,7 @@ See the `org-export-latex.el' code for a complete conversion table."
 	  "\\(\\(\\\\?\\$\\)\\)"
 	  "\\([a-zA-Z0-9()]+\\|[ \t\n]\\|\\b\\|\\\\\\)\\(_\\|\\^\\)\\({[^{}]+}\\|[a-zA-Z0-9]+\\|[ \t\n]\\|[:punct:]\\|)\\|{[a-zA-Z0-9]+}\\|([a-zA-Z0-9]+)\\)"
 	  "\\(.\\|^\\)\\(\\\\\\)\\([ \t\n]\\|\\([&#%{}\"]\\|[a-zA-Z][a-zA-Z0-9]*\\)\\)"
-	  "\\(.\\|^\\)\\(&\\)"
-	  "\\(.\\|^\\)\\(#\\)"
-	  "\\(.\\|^\\)\\(%\\)"
-	  "\\(.\\|^\\)\\({\\)"
-	  "\\(.\\|^\\)\\(}\\)"
-	  "\\(.\\|^\\)\\(~\\)"
-	  "\\(.\\|^\\)\\(\\.\\.\\.\\)"
+	  "\\(^\\|.\\)\\([&#%{}~]\\|\\.\\.\\.\\)"
 	  ;; (?\< . "\\textless{}")
 	  ;; (?\> . "\\textgreater{}")
 	  )))
-- 
1.7.4.rc2.18.gb20e9

      parent reply	other threads:[~2011-03-28 15:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-27 10:48 Escaping to insert comments in exported text Suvayu Ali
2011-03-27 16:36 ` Thomas S. Dye
2011-03-27 20:03   ` Suvayu Ali
2011-03-28 15:17 ` Lawrence Mitchell [this message]

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.orgmode.org/

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

  git send-email \
    --in-reply-to=m3pqpbz33n.fsf@e4300lm.epcc.ed.ac.uk \
    --to=wence@gmx.li \
    --cc=emacs-orgmode@gnu.org \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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