emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Robert Hennig <robert.hennig@freylax.de>
To: Org Mode <emacs-orgmode@gnu.org>
Subject: Patch for latex export supporting nested emphasis
Date: Fri, 20 Aug 2010 16:30:19 +0200	[thread overview]
Message-ID: <4C6E917B.30004@freylax.de> (raw)

[-- 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

             reply	other threads:[~2010-08-20 14:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-20 14:30 Robert Hennig [this message]
2010-08-20 19:43 ` Patch for latex export supporting nested emphasis Scot Becker

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=4C6E917B.30004@freylax.de \
    --to=robert.hennig@freylax.de \
    --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).