emacs-orgmode
[Top][All Lists]
Advanced

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

[O] [PATCH] Prefer matching line beginnings in org-export-latex-special-


From: Lawrence Mitchell
Subject: [O] [PATCH] Prefer matching line beginnings in org-export-latex-special-chars
Date: Mon, 28 Mar 2011 16:17:32 +0100
User-agent: Gnus/5.110014 (No Gnus v0.14) Emacs/24.0.50 (gnu/linux)

* 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




reply via email to

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