From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lawrence Mitchell Subject: [PATCH] Prefer matching line beginnings in org-export-latex-special-chars Date: Mon, 28 Mar 2011 16:17:32 +0100 Message-ID: References: <20110327034819.29b9ee51@bhishma.homelinux.net> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from [140.186.70.92] (port=37977 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q4ECW-00060A-FC for emacs-orgmode@gnu.org; Mon, 28 Mar 2011 11:17:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q4ECU-0007Dj-Rn for emacs-orgmode@gnu.org; Mon, 28 Mar 2011 11:17:51 -0400 Received: from lo.gmane.org ([80.91.229.12]:51333) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q4ECU-0007DV-Ez for emacs-orgmode@gnu.org; Mon, 28 Mar 2011 11:17:50 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1Q4ECT-0002QM-FL for emacs-orgmode@gnu.org; Mon, 28 Mar 2011 17:17:49 +0200 Received: from e4300lm.epcc.ed.ac.uk ([129.215.63.156]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 28 Mar 2011 17:17:49 +0200 Received: from wence by e4300lm.epcc.ed.ac.uk with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 28 Mar 2011 17:17:49 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org * 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