emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <n.goaziou@gmail.com>
To: "Sébastien Vauban" <wxhgmqzgwmuf@spammotel.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Re: [Babel] Need for an extra literal block construct
Date: Sun, 21 Nov 2010 14:41:27 +0100	[thread overview]
Message-ID: <87eiaeiyk8.wl%n.goaziou@gmail.com> (raw)
In-Reply-To: <80ipzrzmts.fsf@missioncriticalit.com>

[-- Attachment #1: Type: text/plain, Size: 1454 bytes --]

Hello,

>>>>> Sébastien Vauban writes:

> I'd expect to see all the above passage from the email to be
> uninterpreted. It is not acting that way.

According to the manual, VERSE block only preserves line breaks and
leading white spaces. Otherwise it is _normal_ formatting. Though,
this raises an interesting question about lists.

At the moment, by design, Org doesn't recognize lists inside blocks.
While this is obviously the way to go in SRC EXAMPLE and COMMENT
blocks, it isn't as clear with VERSE, CENTER and QUOTE.

In the case of VERSE, preserving leading white spaces cannot cooperate
with list exporting. So I still think lists shouldn't be interpreted
here and, as such, not recognized there either. On the other side, in
CENTER and QUOTE blocks, Org may be able to understand them (they are
correctly exported in those cases).

I could make this distinction when I'll update list model. For now, I
suggest using the first patch, which simply ignores lists in HTML and
LaTeX when in a VERSE block.

There are some other problems with those blocks. You can, for example,
replacing your bullets with stars, and export again. This will become
headings in a verse environment. I could bet this wasn't intended.
This is because text as the same column as VERSE block header is
pasted in the temporary buffer at column 0. Items thus become
headings. The second patch prevents headlines inside blocks from being
interpreted.

Regards,

-- Nicolas


[-- Attachment #2: 0001-Do-not-interpret-lists-in-verse-environments-upon-ex.patch --]
[-- Type: text/plain, Size: 2733 bytes --]

From c0c3f11916bae6731eec26e4743402bf3aa83d2f Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <n.goaziou@gmail.com>
Date: Sun, 21 Nov 2010 12:01:59 +0100
Subject: [PATCH 1/2] Do not interpret lists in verse environments upon exporting

* lisp/org-html.el (org-export-as-html): skip list interpretation when
  inside a verse block

This change isn't needed in DocBook exporter, which treats VERSE as
QUOTE environment.
---
 lisp/org-html.el  |    6 ++++--
 lisp/org-latex.el |    9 +++++++++
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/lisp/org-html.el b/lisp/org-html.el
index d1fe06d..1a3e673 100644
--- a/lisp/org-html.el
+++ b/lisp/org-html.el
@@ -1549,13 +1549,15 @@ lang=\"%s\" xml:lang=\"%s\">
 	      (insert (org-format-table-html table-buffer table-orig-buffer))))
 	   (t
 	    ;; Normal lines
-	    (when (string-match
+	    (when (and
+		   (not inverse)
+		   (string-match
 		   (cond
 		    ((eq llt t) "^\\([ \t]*\\)\\(\\([-+*] \\)\\|\\([0-9]+[.)]\\) \\)?\\( *[^ \t\n\r]\\|[ \t]*$\\)")
 		    ((= llt ?.) "^\\([ \t]*\\)\\(\\([-+*] \\)\\|\\([0-9]+\\.\\) \\)?\\( *[^ \t\n\r]\\|[ \t]*$\\)")
 		    ((= llt ?\)) "^\\([ \t]*\\)\\(\\([-+*] \\)\\|\\([0-9]+)\\) \\)?\\( *[^ \t\n\r]\\|[ \t]*$\\)")
 		    (t (error "Invalid value of `org-plain-list-ordered-item-terminator'")))
-		   line)
+		   line))
 	      (setq ind (or (get-text-property 0 'original-indentation line)
 			    (org-get-string-indentation line))
 		    item-type (if (match-beginning 4) "o" "u")
diff --git a/lisp/org-latex.el b/lisp/org-latex.el
index 91bf380..75d9ce2 100644
--- a/lisp/org-latex.el
+++ b/lisp/org-latex.el
@@ -2214,14 +2214,23 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
     (org-replace-match-keep-properties "\\begin{verse}" t t)
     (beginning-of-line 2)
     (while (and (not (looking-at "[ \t]*ORG-VERSE-END.*")) (not (eobp)))
+      ;; Replace leading white spaces.
       (when (looking-at "\\([ \t]+\\)\\([^ \t\n]\\)")
 	(goto-char (match-end 1))
 	(org-replace-match-keep-properties
 	 (org-export-latex-protect-string
 	  (concat "\\hspace*{1cm}" (match-string 2))) t t)
 	(beginning-of-line 1))
+      ;; When at a list item, protect its bullet to avoid later
+      ;; interpretation. This is only needed for items at the same
+      ;; column as block header.
+      (when (looking-at org-item-beginning-re)
+	(add-text-properties
+	 (match-beginning 1) (match-end 1) '(org-protected t)))
+      ;; Replace empty lines.
       (if (looking-at "[ \t]*$")
 	  (insert (org-export-latex-protect-string "\\vspace*{1em}"))
+	;; Add \\ to the end of line if necessary.
 	(unless (looking-at ".*?[^ \t\n].*?\\\\\\\\[ \t]*$")
 	  (end-of-line 1)
 	  (insert "\\\\")))
-- 
1.7.3.2


[-- Attachment #3: 0002-Prevent-exporters-to-find-headlines-within-blocks.patch --]
[-- Type: text/plain, Size: 5935 bytes --]

From a26ade00a90afa73fb709080fa17ece2997b3a57 Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <n.goaziou@gmail.com>
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 "</blockquote>\n")
 	    (org-export-docbook-open-para)
@@ -758,6 +762,7 @@ publishing directory."
 	  ;; seem to work with FOP, so for now we use <informaltable> 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 "<informaltable frame=\"none\" colsep=\"0\" rowsep=\"0\">\n"
 		    "<tgroup align=\"center\" cols=\"1\">\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 "</entry></row></tbody>\n"
 		    "</tgroup>\n</informaltable>\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 "<blockquote>\n")
 	    (org-open-par)
 	    (throw 'nextline nil))
 	  (when (equal "ORG-BLOCKQUOTE-END" line)
+	    (setq inblockquote nil)
 	    (org-close-par-maybe)
 	    (insert "\n</blockquote>\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<div style=\"text-align: center\">")
 	    (org-open-par)
 	    (throw 'nextline nil))
 	  (when (equal "ORG-CENTER-END" line)
+	    (setq incenter nil)
 	    (org-close-par-maybe)
 	    (insert "\n</div>")
 	    (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


[-- Attachment #4: 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

  parent reply	other threads:[~2010-11-21 13:41 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-16 15:16 [babel] Environment around exported results Sébastien Vauban
2010-09-20  4:46 ` Eric Schulte
2010-09-20 19:10   ` Sébastien Vauban
2010-09-21  7:44     ` Sébastien Vauban
2010-09-21 13:14     ` Eric Schulte
2010-09-24  9:28       ` Sébastien Vauban
2010-09-24 21:01         ` Rainer M Krug
2010-09-27  8:16           ` Sébastien Vauban
2010-11-19 13:27             ` [Babel] Need for an extra literal block construct Sébastien Vauban
2010-11-19 15:17               ` Christian Moe
2010-11-19 20:12                 ` Sébastien Vauban
2010-11-19 20:26                   ` Sébastien Vauban
2010-11-19 20:38                     ` Thomas S. Dye
2010-11-19 22:02                       ` Sébastien Vauban
2010-11-19 22:20                         ` Thomas S. Dye
2010-11-19 23:00                           ` Sébastien Vauban
2010-11-19 22:24                     ` Eric Schulte
2010-11-19 23:07                       ` Eric Schulte
2010-11-20  7:20                         ` Sébastien Vauban
2010-11-22 21:46                         ` Sébastien Vauban
2010-11-23  0:42                           ` Eric Schulte
2010-11-23 23:15                             ` Sébastien Vauban
2010-11-19 23:13                       ` Sébastien Vauban
2010-11-19 22:36                   ` Dan Davison
2010-11-20 21:50                     ` Sébastien Vauban
2010-11-21 10:01                       ` Dan Davison
2010-11-22 20:22                         ` Sébastien Vauban
2010-11-21 13:41                       ` Nicolas Goaziou [this message]
2010-11-22 20:30                         ` Sébastien Vauban
2010-11-23 19:27                           ` Nicolas Goaziou
2010-11-23 23:22                             ` Sébastien Vauban
2010-11-24 10:14                               ` Nicolas Goaziou
2010-11-19 23:10                   ` Christian Moe
2010-11-19 23:23                     ` Sébastien Vauban

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=87eiaeiyk8.wl%n.goaziou@gmail.com \
    --to=n.goaziou@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=wxhgmqzgwmuf@spammotel.com \
    /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).