From: Jambunathan K <kjambunathan@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH 4/5] Simplify org-export-format-source-code-or-example
Date: Thu, 23 Jun 2011 21:26:37 +0530 [thread overview]
Message-ID: <81sjr07d8q.fsf@gmail.com> (raw)
In-Reply-To: <81aad88s5j.fsf@gmail.com> (Jambunathan K.'s message of "Thu, 23 Jun 2011 21:19:12 +0530")
[-- Attachment #1: Type: text/plain, Size: 149 bytes --]
PATCH-4/5 org-odt compatibility patch
Addtional Note: Diff looks primarily because of
un-indentation. Effective changes are just couple of lines.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0004-Simplify-org-export-format-source-code-or-example.patch --]
[-- Type: text/x-patch, Size: 6604 bytes --]
From 923402f12f30a39d54e16c0b105db2b1f20c2a7c Mon Sep 17 00:00:00 2001
From: Jambunathan K <kjambunathan@gmail.com>
Date: Thu, 23 Jun 2011 12:06:33 +0530
Subject: [PATCH 4/5] Simplify org-export-format-source-code-or-example.
* lisp/org-exp.el (org-export-format-source-code-or-example):
Simplify. Also add `org-native-text' as a text property to the
formatted text and throw error for unknown backends.
---
lisp/org-exp.el | 142 +++++++++++++++++++++++++++----------------------------
1 files changed, 70 insertions(+), 72 deletions(-)
diff --git a/lisp/org-exp.el b/lisp/org-exp.el
index 5008b65..83216dc 100644
--- a/lisp/org-exp.el
+++ b/lisp/org-exp.el
@@ -2540,12 +2540,9 @@ INDENT was the original indentation of the block."
cont rpllbl fmt))
((eq org-export-current-backend 'docbook)
(setq rtn (org-export-number-lines rtn 0 0 num cont rpllbl fmt))
- (concat "\n#+BEGIN_DOCBOOK\n"
- (org-add-props (concat "<programlisting><![CDATA["
- rtn
- "]]></programlisting>\n")
- '(org-protected t org-example t))
- "#+END_DOCBOOK\n"))
+ (concat "<programlisting><![CDATA["
+ rtn
+ "]]></programlisting>\n"))
((eq org-export-current-backend 'html)
;; We are exporting to HTML
(when lang
@@ -2615,78 +2612,79 @@ INDENT was the original indentation of the block."
(setq rtn (org-export-number-lines rtn 1 1 num cont rpllbl fmt)))
(if (string-match "\\(\\`<[^>]*>\\)\n" rtn)
(setq rtn (replace-match "\\1" t nil rtn)))
- (concat "\n#+BEGIN_HTML\n" (org-add-props rtn '(org-protected t org-example t)) "\n#+END_HTML\n\n"))
+ rtn)
((eq org-export-current-backend 'latex)
(setq rtn (org-export-number-lines rtn 0 0 num cont rpllbl fmt))
- (concat
- "#+BEGIN_LaTeX\n"
- (org-add-props
- (cond
- ((and lang org-export-latex-listings)
- (flet ((make-option-string
- (pair)
- (concat (first pair)
- (if (> (length (second pair)) 0)
- (concat "=" (second pair))))))
- (let* ((lang-sym (intern lang))
- (minted-p (eq org-export-latex-listings 'minted))
- (listings-p (not minted-p))
- (backend-lang
- (or (cadr
- (assq
- lang-sym
- (cond
- (minted-p org-export-latex-minted-langs)
- (listings-p org-export-latex-listings-langs))))
- lang))
- (custom-environment
- (cadr
- (assq
- lang-sym
- org-export-latex-custom-lang-environments))))
- (concat
- (when (and listings-p (not custom-environment))
- (format
- "\\lstset{%s}\n"
- (mapconcat
- #'make-option-string
- (append org-export-latex-listings-options
- `(("language" ,backend-lang))) ",")))
- (when (and caption org-export-latex-listings-w-names)
- (format
- "\n%s $\\equiv$ \n"
- (replace-regexp-in-string "_" "\\\\_" caption)))
- (cond
- (custom-environment
- (format "\\begin{%s}\n%s\\end{%s}\n"
- custom-environment rtn custom-environment))
- (listings-p
- (format "\\begin{%s}\n%s\\end{%s}\n"
- "lstlisting" rtn "lstlisting"))
- (minted-p
- (format
- "\\begin{minted}[%s]{%s}\n%s\\end{minted}\n"
- (mapconcat #'make-option-string
- org-export-latex-minted-options ",")
- backend-lang rtn)))))))
- (t (concat (car org-export-latex-verbatim-wrap)
- rtn (cdr org-export-latex-verbatim-wrap))))
- '(org-protected t org-example t))
- "#+END_LaTeX\n"))
+ (cond
+ ((and lang org-export-latex-listings)
+ (flet ((make-option-string
+ (pair)
+ (concat (first pair)
+ (if (> (length (second pair)) 0)
+ (concat "=" (second pair))))))
+ (let* ((lang-sym (intern lang))
+ (minted-p (eq org-export-latex-listings 'minted))
+ (listings-p (not minted-p))
+ (backend-lang
+ (or (cadr
+ (assq
+ lang-sym
+ (cond
+ (minted-p org-export-latex-minted-langs)
+ (listings-p org-export-latex-listings-langs))))
+ lang))
+ (custom-environment
+ (cadr
+ (assq
+ lang-sym
+ org-export-latex-custom-lang-environments))))
+ (concat
+ (when (and listings-p (not custom-environment))
+ (format
+ "\\lstset{%s}\n"
+ (mapconcat
+ #'make-option-string
+ (append org-export-latex-listings-options
+ `(("language" ,backend-lang))) ",")))
+ (when (and caption org-export-latex-listings-w-names)
+ (format
+ "\n%s $\\equiv$ \n"
+ (replace-regexp-in-string "_" "\\\\_" caption)))
+ (cond
+ (custom-environment
+ (format "\\begin{%s}\n%s\\end{%s}\n"
+ custom-environment rtn custom-environment))
+ (listings-p
+ (format "\\begin{%s}\n%s\\end{%s}\n"
+ "lstlisting" rtn "lstlisting"))
+ (minted-p
+ (format
+ "\\begin{minted}[%s]{%s}\n%s\\end{minted}\n"
+ (mapconcat #'make-option-string
+ org-export-latex-minted-options ",")
+ backend-lang rtn)))))))
+ (t (concat (car org-export-latex-verbatim-wrap)
+ rtn (cdr org-export-latex-verbatim-wrap)))))
((eq org-export-current-backend 'ascii)
;; This is not HTML or LaTeX, so just make it an example.
(setq rtn (org-export-number-lines rtn 0 0 num cont rpllbl fmt))
(concat caption "\n"
- "#+BEGIN_ASCII\n"
- (org-add-props
- (concat
- (mapconcat
- (lambda (l) (concat " " l))
- (org-split-string rtn "\n")
- "\n")
- "\n")
- '(org-protected t org-example t))
- "#+END_ASCII\n"))))
+ (concat
+ (mapconcat
+ (lambda (l) (concat " " l))
+ (org-split-string rtn "\n")
+ "\n")
+ "\n")
+ ))
+ (t
+ (error "Don't know how to markup source or example block in %s"
+ (upcase backend-name)))))
+ (setq rtn
+ (concat
+ "\n#+BEGIN_" backend-name "\n"
+ (org-add-props rtn
+ '(org-protected t org-example t org-native-text t))
+ "\n#+END_" backend-name "\n\n"))
(org-add-props rtn nil 'original-indentation indent))))
(defun org-export-number-lines (text &optional skip1 skip2 number cont
--
1.7.2.3
next prev parent reply other threads:[~2011-06-23 15:56 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-23 15:49 org-odt compatibility patches Jambunathan K
2011-06-23 15:52 ` [PATCH 1/5] org-export: Reserve a slot for OpenDocumentExporter Jambunathan K
2011-06-23 15:53 ` [PATCH 2/5] org-exp.el: Allow easy plugging in of new backends Jambunathan K
2011-06-23 15:54 ` [PATCH 3/5] Support custom formatters for marking up source or example blocks Jambunathan K
2011-06-23 15:56 ` Jambunathan K [this message]
2011-06-23 15:57 ` [PATCH 5/5] Control insertion point for footnote definitions during pre-process Jambunathan K
2011-06-24 8:05 ` org-odt compatibility patches Carsten Dominik
2011-06-24 8:42 ` Jambunathan K
2011-06-24 8:55 ` Jambunathan K
2011-06-24 10:52 ` Bastien
2011-06-24 10:47 ` Bastien
2011-06-24 10:49 ` Bastien
2011-06-25 5:19 ` Jambunathan K
2011-06-25 8:54 ` Bastien
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=81sjr07d8q.fsf@gmail.com \
--to=kjambunathan@gmail.com \
--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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.