[Orgmode] Patch for latex export supporting nested emphasis

2010-08-20 Thread Robert Hennig
Dear Orgmode maintainers,

I would like to provide a patch which allows nested emphasis
for the latex export. The problem of handling nested emphasis
was solved by applying the org-export-latex-fontify recursively.
The example

  Now *you /can/ write* /nested/ */emphasis/ recursively!*

will be translated to:

  Now \textbf{you \emph{can} write} \emph{nested}
  \textbf{\emph{emphasis} recursively!}

Best regards, yours faithful

Robert Hennig
--- org-latex.el	2010-08-20 15:58:28.0 +0200
+++ org-latex.mod.el	2010-08-20 16:06:26.0 +0200
@@ -1795,8 +1795,24 @@
 
 (defun org-export-latex-fontify ()
   Convert fontification to LaTeX.
+  ;; max recursive level set to 2, 
+  ;; so one level of nested emphasis works
+  (org-export-latex-fontify-recursive 2)
+)
+
+(defun org-export-latex-fontify-recursive (reclevel)
+  Convert fontification to LaTeX, recursive part.
   (goto-char (point-min))
   (while (re-search-forward org-emph-re nil t)
+(if ( reclevel 1)
+(let ((mdata (match-data)))
+  (unwind-protect
+  ;; now it is ok to change the original match data.
+  (save-excursion
+(save-restriction
+  (narrow-to-region (match-beginning 4) (match-end 4))
+  (org-export-latex-fontify-recursive (1- reclevel
+(set-match-data mdata
 ;; The match goes one char after the *string*, except at the end of a line
 (let ((emph (assoc (match-string 3)
 		   org-export-latex-emphasis-alist))
___
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


Re: [Orgmode] Patch for latex export supporting nested emphasis

2010-08-20 Thread Scot Becker
That's very useful.

On Fri, Aug 20, 2010 at 3:30 PM, Robert Hennig robert.hen...@freylax.dewrote:

 Dear Orgmode maintainers,

 I would like to provide a patch which allows nested emphasis
 for the latex export. The problem of handling nested emphasis
 was solved by applying the org-export-latex-fontify recursively.
 The example

  Now *you /can/ write* /nested/ */emphasis/ recursively!*

 will be translated to:

  Now \textbf{you \emph{can} write} \emph{nested}
  \textbf{\emph{emphasis} recursively!}

 Best regards, yours faithful

 Robert Hennig

 ___
 Emacs-orgmode mailing list
 Please use `Reply All' to send replies to the list.
 Emacs-orgmode@gnu.org
 http://lists.gnu.org/mailman/listinfo/emacs-orgmode


___
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode