瀏覽代碼

Implement the verse environment.

Carsten Dominik 17 年之前
父節點
當前提交
bb53613c9f
共有 4 個文件被更改,包括 52 次插入4 次删除
  1. 15 3
      doc/org.texi
  2. 10 0
      lisp/ChangeLog
  3. 19 1
      lisp/org-exp.el
  4. 8 0
      lisp/org-export-latex.el

+ 15 - 3
doc/org.texi

@@ -6731,6 +6731,16 @@ description lists.
 Paragraphs are separated by at least one empty line.  If you need to enforce
 a line break within a paragraph, use @samp{\\} at the end of a line.
 
+To keep the line breaks in a region, but otherwise use normal formatting, you
+can use this construct, which can also be used to format poetry.
+
+@example
+#+begin_verse
+Everything should be made as simple as possible,
+but not any simpler -- Albert Einstein
+#+end_verse
+@end example
+
 When quoting a passage from another document, it is customary to format this
 as a paragraph that is indented on both the left and the right margin.  You
 can include quotations in Org mode documents like this:
@@ -6742,6 +6752,7 @@ but not any simpler -- Albert Einstein
 #+end_quote
 @end example
 
+
 @node Literal examples, Include files, Paragraphs, Markup rules
 @subheading Literal examples
 @cindex literal examples, markup rules
@@ -6881,9 +6892,10 @@ exported as a horizontal line (@samp{<hr/>} in HTML).
 @cindex comment lines
 @cindex exporting, not
 
-Lines starting with @samp{#} in column zero are treated as comments
-and will never be exported.  Also entire subtrees starting with the
-word @samp{COMMENT} will never be exported.
+Lines starting with @samp{#} in column zero are treated as comments and will
+never be exported.  Also entire subtrees starting with the word
+@samp{COMMENT} will never be exported.  Finally, regions surrounded by
+@samp{#+BEGIN_COMMENT} ... @samp{END_COMMENT} will not be exported.
 
 @table @kbd
 @kindex C-c ;

+ 10 - 0
lisp/ChangeLog

@@ -1,3 +1,13 @@
+2008-05-13  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org-exp.el (org-export-as-html, org-export-preprocess-string):
+	Implement VERSE environment.
+	(org-export-preprocess-string): Implement the COMMENT
+	environment.
+
+	* org-export-latex.el (org-export-latex-preprocess): Implement
+	VERSE environment.
+
 2008-05-12  Carsten Dominik  <dominik@science.uva.nl>
 
 	* org-jsinfo.el (org-infojs-opts-table): Add entry for FIXED_TOC

+ 19 - 1
lisp/org-exp.el

@@ -1366,6 +1366,18 @@ on this string to produce the exported version."
 	(replace-match (if (equal (downcase (match-string 1)) "end")
 			   "ORG-BLOCKQUOTE-END" "ORG-BLOCKQUOTE-START")
 			 t t))
+      ;; Verse
+      (goto-char (point-min))
+      (while (re-search-forward "^#\\+\\(begin\\|end\\)_verse\\>.*" nil t)
+	(replace-match (if (equal (downcase (match-string 1)) "end")
+			   "ORG-VERSE-END" "ORG-VERSE-START")
+			 t t))
+
+      ;; Remove comment environment
+      (goto-char (point-min))
+      (while (re-search-forward
+	      "^#\\+BEGIN_COMMENT[ \t]*\n[^\000]*?^#\\+END_COMMENT\\>.*" nil t)
+	(replace-match "" t t))
 
       ;; Remove subtrees that are commented
       (goto-char (point-min))
@@ -2619,13 +2631,19 @@ lang=\"%s\" xml:lang=\"%s\">
 	    (insert "\n<hr/>\n")
 	    (throw 'nextline nil))
 
-	  ;; Blockquotes
+	  ;; Blockquotes and verse
 	  (when (equal "ORG-BLOCKQUOTE-START" line)
 	    (insert "<blockquote>\n<p>\n")
 	    (throw 'nextline nil))
 	  (when (equal "ORG-BLOCKQUOTE-END" line)
 	    (insert "</p>\n</blockquote>\n")
 	    (throw 'nextline nil))
+	  (when (equal "ORG-VERSE-START" line)
+	    (insert "<verse>\n<p>\n")
+	    (throw 'nextline nil))
+	  (when (equal "ORG-VERSE-END" line)
+	    (insert "</p>\n</verse>\n")
+	    (throw 'nextline nil))
 
 	  ;; make targets to anchors
 	  (while (string-match "<<<?\\([^<>]*\\)>>>?\\((INVISIBLE)\\)?[ \t]*\n?" line)

+ 8 - 0
lisp/org-export-latex.el

@@ -1102,6 +1102,14 @@ Regexps are those from `org-export-latex-special-string-regexps'."
   (while (re-search-forward "^#\\+END_QUOTE" nil t)
     (replace-match "\\end{quote}" t t))
 
+  ;; Convert verse
+  (goto-char (point-min))
+  (while (re-search-forward "^#\\+BEGIN_VERSE" nil t)
+    (replace-match "\\begin{verse}" t t))
+  (goto-char (point-min))
+  (while (re-search-forward "^#\\+END_VERSE" nil t)
+    (replace-match "\\end{verse}" t t))
+
   ;; Convert horizontal rules
   (goto-char (point-min))
   (while (re-search-forward "^----+.$" nil t)