فهرست منبع

Centering: Implement markup for centered text.

Carsten Dominik 16 سال پیش
والد
کامیت
ad11d7f675
6فایلهای تغییر یافته به همراه46 افزوده شده و 4 حذف شده
  1. 4 0
      doc/ChangeLog
  2. 7 0
      doc/org.texi
  3. 7 0
      lisp/ChangeLog
  4. 17 4
      lisp/org-exp.el
  5. 8 0
      lisp/org-export-latex.el
  6. 3 0
      lisp/org.el

+ 4 - 0
doc/ChangeLog

@@ -1,3 +1,7 @@
+2009-03-16  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org.texi (Paragraphs): Document centering.
+
 2009-03-14  Carsten Dominik  <carsten.dominik@gmail.com>
 
 	* org.texi (Creating timestamps, Agenda commands): Document new

+ 7 - 0
doc/org.texi

@@ -7855,6 +7855,13 @@ but not any simpler -- Albert Einstein
 #+END_QUOTE
 @end example
 
+If you would like to center some text, do it like this:
+@example
+#+BEGIN_CENTER
+Everything should be made as simple as possible, \\
+but not any simpler
+#+END_CENTER
+@end example
 
 @node Literal examples, Include files, Paragraphs, Markup rules
 @subheading Literal examples

+ 7 - 0
lisp/ChangeLog

@@ -1,5 +1,12 @@
 2009-03-16  Carsten Dominik  <carsten.dominik@gmail.com>
 
+	* org-export-latex.el (org-export-latex-preprocess): Implement the
+	centering markup.
+
+	* org-exp.el (org-export-mark-blockquote-verse-center): Renamed
+	from `org-export-mark-blockquote-and-verse'.
+	(org-export-as-html): Implement the centering markup.
+
 	* org-export-latex.el (org-export-latex-tables): Fix vertical
 	lines in tables.
 

+ 17 - 4
lisp/org-exp.el

@@ -1656,8 +1656,8 @@ on this string to produce the exported version."
       ;; Protect verbatim elements
       (org-export-protect-verbatim)
 
-      ;; Blockquotes and verse
-      (org-export-mark-blockquote-and-verse)
+      ;; Blockquotes, verse, and center
+      (org-export-mark-blockquote-verse-center)
 
       ;; Remove timestamps, if the user has requested so
       (unless (plist-get parameters :timestamps)
@@ -2027,7 +2027,7 @@ from the buffer."
 	  ;; No, this is for a different backend, kill it
 	  (delete-region (match-beginning 0) (match-end 0)))))))
 
-(defun org-export-mark-blockquote-and-verse ()
+(defun org-export-mark-blockquote-verse-center ()
   "Mark block quote and verse environments with special cookies.
 These special cookies will later be interpreted by the backend."
   ;; Blockquotes
@@ -2042,6 +2042,12 @@ These special cookies will later be interpreted by the backend."
   (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))
+  ;; Center
+  (goto-char (point-min))
+  (while (re-search-forward "^#\\+\\(begin\\|end\\)_center\\>.*" nil t)
+    (replace-match (if (equal (downcase (match-string 1)) "end")
+		       "ORG-CENTER-END" "ORG-CENTER-START")
 		   t t)))
 
 (defun org-export-attach-captions-and-attributes (backend target-alist)
@@ -3713,7 +3719,7 @@ lang=\"%s\" xml:lang=\"%s\">
 	      (insert "\n<hr/>\n"))
 	    (throw 'nextline nil))
 
-	  ;; Blockquotes and verse
+	  ;; Blockquotes, verse, and center
 	  (when (equal "ORG-BLOCKQUOTE-START" line)
 	    (org-close-par-maybe)
 	    (insert "<blockquote>\n<p>\n")
@@ -3730,6 +3736,13 @@ lang=\"%s\" xml:lang=\"%s\">
 	    (insert "</p>\n")
 	    (setq inverse nil)
 	    (throw 'nextline nil))
+	  (when (equal "ORG-CENTER-START" line)
+	    (org-close-par-maybe)
+	    (insert "\n<p style=\"text-align: center\">\n")
+	    (throw 'nextline nil))
+	  (when (equal "ORG-CENTER-END" line)
+	    (insert "</p>\n")
+	    (throw 'nextline nil))
 	  (when inverse
 	    (let ((i (org-get-string-indentation line)))
 	      (if (> i 0)

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

@@ -1366,6 +1366,14 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
   (while (search-forward "ORG-VERSE-END" nil t)
     (replace-match "\\end{verse}" t t))
 
+  ;; Convert center
+  (goto-char (point-min))
+  (while (search-forward "ORG-CENTER-START" nil t)
+    (replace-match "\\begin{center}" t t))
+  (goto-char (point-min))
+  (while (search-forward "ORG-CENTER-END" nil t)
+    (replace-match "\\end{center}" t t))
+
   ;; Convert horizontal rules
   (goto-char (point-min))
   (while (re-search-forward "^----+.$" nil t)

+ 3 - 0
lisp/org.el

@@ -8373,6 +8373,7 @@ This function can be used in a hook."
     "BEGIN_EXAMPLE" "END_EXAMPLE"
     "BEGIN_QUOTE" "END_QUOTE"
     "BEGIN_VERSE" "END_VERSE"
+    "BEGIN_CENTER" "END_CENTER"
     "BEGIN_SRC" "END_SRC"
     "CATEGORY" "COLUMNS"
     "CAPTION" "LABEL" "ATTR_HTML" "ATTR_LaTeX"))
@@ -8387,6 +8388,8 @@ This function can be used in a hook."
          "<quote>\n?\n</quote>")
     ("v" "#+begin_verse\n?\n#+end_verse"
          "<verse>\n?\n/verse>")
+    ("c" "#+begin_center\n?\n#+end_center"
+         "<center>\n?\n/center>")
     ("l" "#+begin_latex\n?\n#+end_latex"
          "<literal style=\"latex\">\n?\n</literal>")
     ("L" "#+latex: "