summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2014-05-17 10:00:41 +0200
committerNicolas Goaziou <n.goaziou@gmail.com>2014-05-17 10:00:41 +0200
commitb11b4a5c1a0a7e1205e4c2a65e2b0173fc4c7520 (patch)
tree1168d5cacb75e34db887a96c7a2a5bffede59abf
parent9a60b93d932393eda4a216d79bdcd04c44dd3a24 (diff)
downloadorg-mode-b11b4a5c1a0a7e1205e4c2a65e2b0173fc4c7520.tar.gz
ox-ascii: Fix indentation in the first paragraph of a section
* lisp/ox-ascii.el (org-ascii-indented-line-width): Update docstring. (org-ascii-paragraph): Do not apply indentation to the very first line of a section.
-rw-r--r--lisp/ox-ascii.el22
1 files changed, 14 insertions, 8 deletions
diff --git a/lisp/ox-ascii.el b/lisp/ox-ascii.el
index 4e4d3e9..02fdb32 100644
--- a/lisp/ox-ascii.el
+++ b/lisp/ox-ascii.el
@@ -192,8 +192,10 @@ original Org buffer at the same place."
(defcustom org-ascii-indented-line-width 'auto
"Additional indentation width for the first line in a paragraph.
If the value is an integer, indent the first line of each
-paragraph by this number. If it is the symbol `auto' preserve
-indentation from original document."
+paragraph by this width, unless it is located at the beginning of
+a section, in which case indentation is removed from that line.
+If it is the symbol `auto' preserve indentation from original
+document."
:group 'org-export-ascii
:version "24.4"
:package-version '(Org . "8.0")
@@ -1418,12 +1420,16 @@ INFO is a plist holding contextual information."
"Transcode a PARAGRAPH element from Org to ASCII.
CONTENTS is the contents of the paragraph, as a string. INFO is
the plist used as a communication channel."
- (let ((contents (if (not (wholenump org-ascii-indented-line-width)) contents
- (concat
- (make-string org-ascii-indented-line-width ? )
- (replace-regexp-in-string "\\`[ \t]+" "" contents)))))
- (org-ascii--fill-string
- contents (org-ascii--current-text-width paragraph info) info)))
+ (org-ascii--fill-string
+ (if (not (wholenump org-ascii-indented-line-width)) contents
+ (concat
+ ;; Do not indent first paragraph in a section.
+ (unless (and (not (org-export-get-previous-element paragraph info))
+ (eq (org-element-type (org-export-get-parent paragraph))
+ 'section))
+ (make-string org-ascii-indented-line-width ?\s))
+ (replace-regexp-in-string "\\`[ \t]+" "" contents)))
+ (org-ascii--current-text-width paragraph info) info))
;;;; Plain List