Browse Source

Fix example indentation for export.

Patch from Bernt Hansen.
Carsten Dominik 16 năm trước cách đây
mục cha
commit
e8394dcbcf
2 tập tin đã thay đổi với 7 bổ sung3 xóa
  1. 4 0
      lisp/ChangeLog
  2. 3 3
      lisp/org-exp.el

+ 4 - 0
lisp/ChangeLog

@@ -2,6 +2,10 @@
 
 	* org-exp.el (org-export-as-html): Fixed typo in creator
 	information.
+	(org-export-protect-examples): New parameter indent.  Insert extra
+	spaces only when this parameter is specified.
+	(org-export-preprocess-string): Call `org-export-protect-examples'
+	with an indentation parameter when exporting to ASCII.
 
 	* org-remember.el (org-remember-templates)
 	(org-remember-apply-template): Allow the file component to be a

+ 3 - 3
lisp/org-exp.el

@@ -1386,7 +1386,7 @@ on this string to produce the exported version."
       (setq target-alist (org-export-handle-invisible-targets target-alist))
 
       ;; Protect examples
-      (org-export-protect-examples)
+      (org-export-protect-examples (if asciip 'indent nil))
 
       ;; Protect backend specific stuff, throw away the others.
       (org-export-select-backend-specific-text
@@ -1591,13 +1591,13 @@ from the buffer."
 			 '(org-protected t))
     (goto-char (1+ (match-end 4)))))
 
-(defun org-export-protect-examples ()
+(defun org-export-protect-examples (&optional indent)
   "Protect code that should be exported as monospaced examples."
   (goto-char (point-min))
   (while (re-search-forward "^#\\+BEGIN_EXAMPLE[ \t]*\n" nil t)
     (goto-char (match-end 0))
     (while (and (not (looking-at "#\\+END_EXAMPLE")) (not (eobp)))
-      (insert ":  ")
+      (insert (if indent ":  " ":"))
       (beginning-of-line 2)))
   (goto-char (point-min))
   (while (re-search-forward "^[ \t]*:.*\\(\n[ \t]*:.*\\)*" nil t)