From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: Re: [Babel] Need for an extra literal block construct Date: Sun, 21 Nov 2010 14:41:27 +0100 Message-ID: <87eiaeiyk8.wl%n.goaziou@gmail.com> References: <87zkvhoh18.fsf@mundaneum.com> <87fwx5c98w.fsf@gmail.com> <87sk14p6y6.fsf@mundaneum.com> <87mxrbdyhs.fsf@gmail.com> <87tylfsd7h.fsf@mundaneum.com> <4C9D1196.8030309@gmail.com> <87r5gfppob.fsf@mundaneum.com> <8039qxmojd.fsf_-_@mundaneum.com> <4CE694F1.2050409@christianmoe.com> <8039qx3wff.fsf@missioncriticalit.com> <87mxp5q6uf.fsf@gmail.com> <80ipzrzmts.fsf@missioncriticalit.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: multipart/mixed; boundary="Multipart_Sun_Nov_21_14:41:26_2010-1" Content-Transfer-Encoding: 8bit Return-path: Received: from [140.186.70.92] (port=60188 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PKAAg-0004CS-Mi for emacs-orgmode@gnu.org; Sun, 21 Nov 2010 08:41:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PKAAf-00028k-1Y for emacs-orgmode@gnu.org; Sun, 21 Nov 2010 08:41:34 -0500 Received: from mail-ww0-f49.google.com ([74.125.82.49]:65099) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PKAAe-00028f-Oh for emacs-orgmode@gnu.org; Sun, 21 Nov 2010 08:41:32 -0500 Received: by wwc33 with SMTP id 33so6591622wwc.30 for ; Sun, 21 Nov 2010 05:41:31 -0800 (PST) In-Reply-To: <80ipzrzmts.fsf@missioncriticalit.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: =?UTF-8?B?U8OpYmFzdGllbg==?= Vauban Cc: emacs-orgmode@gnu.org --Multipart_Sun_Nov_21_14:41:26_2010-1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --Multipart_Sun_Nov_21_14:41:26_2010-1 Content-Type: text/plain; type=patch; charset=US-ASCII Content-Disposition: attachment; filename="0001-Do-not-interpret-lists-in-verse-environments-upon-ex.patch" Content-Transfer-Encoding: 7bit >From c0c3f11916bae6731eec26e4743402bf3aa83d2f Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou 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 --Multipart_Sun_Nov_21_14:41:26_2010-1 Content-Type: text/plain; type=patch; charset=US-ASCII Content-Disposition: attachment; filename="0002-Prevent-exporters-to-find-headlines-within-blocks.patch" Content-Transfer-Encoding: 7bit >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 --Multipart_Sun_Nov_21_14:41:26_2010-1 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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 --Multipart_Sun_Nov_21_14:41:26_2010-1--