* Patch for latex export supporting nested emphasis
@ 2010-08-20 14:30 Robert Hennig
2010-08-20 19:43 ` Scot Becker
0 siblings, 1 reply; 2+ messages in thread
From: Robert Hennig @ 2010-08-20 14:30 UTC (permalink / raw)
To: Org Mode
[-- Attachment #1: Type: text/plain, Size: 447 bytes --]
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
[-- Attachment #2: org-latex.el.diff --]
[-- Type: text/x-patch, Size: 1086 bytes --]
--- org-latex.el 2010-08-20 15:58:28.000000000 +0200
+++ org-latex.mod.el 2010-08-20 16:06:26.000000000 +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))
[-- Attachment #3: Type: text/plain, Size: 201 bytes --]
_______________________________________________
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Patch for latex export supporting nested emphasis
2010-08-20 14:30 Patch for latex export supporting nested emphasis Robert Hennig
@ 2010-08-20 19:43 ` Scot Becker
0 siblings, 0 replies; 2+ messages in thread
From: Scot Becker @ 2010-08-20 19:43 UTC (permalink / raw)
To: Robert Hennig; +Cc: Org Mode
[-- Attachment #1.1: Type: text/plain, Size: 791 bytes --]
That's very useful.
On Fri, Aug 20, 2010 at 3:30 PM, Robert Hennig <robert.hennig@freylax.de>wrote:
> 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
>
>
[-- Attachment #1.2: Type: text/html, Size: 1299 bytes --]
[-- Attachment #2: Type: text/plain, Size: 201 bytes --]
_______________________________________________
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-08-20 19:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-20 14:30 Patch for latex export supporting nested emphasis Robert Hennig
2010-08-20 19:43 ` Scot Becker
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).