>From a26ade00a90afa73fb709080fa17ece2997b3a57 Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou
Date: Sun, 21 Nov 2010 13:42:32 +0100
Subject: [PATCH 2/2] Prevent exporters to find headlines within blocks
* lisp/org-exp.el (org-export-mark-blockquote-verse-center): Protect
headlines within blocks. As leading white spaces are removed from
text inside blocks, a line starting with some spaces and some starts
would be considered as an headline otherwise.
* lisp/org-html.el (org-export-as-html): added some predicates to
identify what type of block current line is in. Do not recognize
headlines in such blocks
* lisp/org-docbook.el (org-export-as-docbook): added some predicates
to identify what type of block current line is in. Do not recognize
headlines in such blocks
---
lisp/org-docbook.el | 19 ++++++++++++++-----
lisp/org-exp.el | 7 ++++++-
lisp/org-html.el | 17 +++++++++++++----
3 files changed, 33 insertions(+), 10 deletions(-)
diff --git a/lisp/org-docbook.el b/lisp/org-docbook.el
index 7d90ec3..b0ddbce 100644
--- a/lisp/org-docbook.el
+++ b/lisp/org-docbook.el
@@ -496,9 +496,11 @@ publishing directory."
(html-table-tag (plist-get opt-plist :html-table-tag))
(quote-re0 (concat "^[ \t]*" org-quote-string "\\>"))
(quote-re (concat "^\\(\\*+\\)\\([ \t]+" org-quote-string "\\>\\)"))
- (inquote nil)
- (infixed nil)
- (inverse nil)
+ (inquote nil)
+ (inblockquote nil)
+ (infixed nil)
+ (inverse nil)
+ (incenter nil)
(in-local-list nil)
(local-list-type nil)
(local-list-indent nil)
@@ -706,7 +708,8 @@ publishing directory."
(throw 'nextline nil))
;; Start of block quotes and verses
- (when (or (equal "ORG-BLOCKQUOTE-START" line)
+ (when (or (and (equal "ORG-BLOCKQUOTE-START" line)
+ (setq inblockquote t))
(and (equal "ORG-VERSE-START" line)
(setq inverse t)))
(org-export-docbook-close-para-maybe)
@@ -742,6 +745,7 @@ publishing directory."
;; End of block quotes
(when (equal "ORG-BLOCKQUOTE-END" line)
+ (setq inblockquote nil)
(org-export-docbook-close-para-maybe)
(insert "\n")
(org-export-docbook-open-para)
@@ -758,6 +762,7 @@ publishing directory."
;; seem to work with FOP, so for now we use to
;; center the text, which can contain multiple paragraphs.
(when (equal "ORG-CENTER-START" line)
+ (setq incenter t)
(org-export-docbook-close-para-maybe)
(insert "\n"
"\n"
@@ -766,6 +771,7 @@ publishing directory."
(throw 'nextline nil))
(when (equal "ORG-CENTER-END" line)
+ (setq incenter nil)
(org-export-docbook-close-para-maybe)
(insert "\n"
"\n\n")
@@ -970,7 +976,10 @@ publishing directory."
(push (cons num 1) footref-seen))))))
(cond
- ((string-match "^\\(\\*+\\)[ \t]+\\(.*\\)" line)
+ ((and (not incenter)
+ (not inblockquote)
+ (not inverse)
+ (string-match "^\\(\\*+\\)[ \t]+\\(.*\\)" line))
;; This is a headline
(setq level (org-tr-level (- (match-end 1) (match-beginning 1)
level-offset))
diff --git a/lisp/org-exp.el b/lisp/org-exp.el
index 08c0ac6..3b8c273 100644
--- a/lisp/org-exp.el
+++ b/lisp/org-exp.el
@@ -1655,7 +1655,12 @@ These special cookies will later be interpreted by the backend."
content "\n"
"ORG-" (upcase t1) "-END\n"))
(delete-region beg end)
- (insert (org-add-props content nil 'original-indentation ind))))))
+ (insert (org-add-props content nil 'original-indentation ind))
+ ;; Protect headings inside block
+ (goto-char beg)
+ (while (re-search-forward "^\\(\\*\\)+[ \t]+" end 'move)
+ (add-text-properties
+ (match-beginning 1) (match-end 1) '(org-protected t)))))))
(defun org-export-mark-list-ending (backend)
"Mark list endings with special cookies.
diff --git a/lisp/org-html.el b/lisp/org-html.el
index 1a3e673..9e5a268 100644
--- a/lisp/org-html.el
+++ b/lisp/org-html.el
@@ -916,9 +916,11 @@ PUB-DIR is set, use this as the publishing directory."
(html-table-tag (plist-get opt-plist :html-table-tag))
(quote-re0 (concat "^[ \t]*" org-quote-string "\\>"))
(quote-re (concat "^\\(\\*+\\)\\([ \t]+" org-quote-string "\\>\\)"))
- (inquote nil)
- (infixed nil)
- (inverse nil)
+ (inquote nil)
+ (inblockquote nil)
+ (infixed nil)
+ (inverse nil)
+ (incenter nil)
(in-local-list nil)
(local-list-type nil)
(local-list-indent nil)
@@ -1236,11 +1238,13 @@ lang=\"%s\" xml:lang=\"%s\">
;; Blockquotes, verse, and center
(when (equal "ORG-BLOCKQUOTE-START" line)
+ (setq inblockquote t)
(org-close-par-maybe)
(insert "\n")
(org-open-par)
(throw 'nextline nil))
(when (equal "ORG-BLOCKQUOTE-END" line)
+ (setq inblockquote nil)
(org-close-par-maybe)
(insert "\n
\n")
(org-open-par)
@@ -1258,11 +1262,13 @@ lang=\"%s\" xml:lang=\"%s\">
(setq inverse nil)
(throw 'nextline nil))
(when (equal "ORG-CENTER-START" line)
+ (setq incenter t)
(org-close-par-maybe)
(insert "\n")
(org-open-par)
(throw 'nextline nil))
(when (equal "ORG-CENTER-END" line)
+ (setq incenter nil)
(org-close-par-maybe)
(insert "\n
")
(org-open-par)
@@ -1510,7 +1516,10 @@ lang=\"%s\" xml:lang=\"%s\">
t t line))))))
(cond
- ((string-match "^\\(\\*+\\)[ \t]+\\(.*\\)" line)
+ ((and (not inverse)
+ (not incenter)
+ (not inblockquote)
+ (string-match "^\\(\\*+\\)[ \t]+\\(.*\\)" line))
;; This is a headline
(setq level (org-tr-level (- (match-end 1) (match-beginning 1)
level-offset))
--
1.7.3.2