summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2012-07-25 12:55:00 +0200
committerNicolas Goaziou <n.goaziou@gmail.com>2012-07-25 12:55:00 +0200
commitb6b40424d2a398dae7c1686b0c427b0813f55b85 (patch)
tree132e09a373d2c6e376a416d888c81ae8cb655c62
parent3df18bef9fdff274685ae5975214ba26c443a387 (diff)
downloadorg-mode-b6b40424d2a398dae7c1686b0c427b0813f55b85.tar.gz
org-e-ascii: Center shortened horizontal rules
* contrib/lisp/org-e-ascii.el (org-e-ascii-horizontal-rule): Center shortened horizontal rules.
-rw-r--r--contrib/lisp/org-e-ascii.el28
1 files changed, 17 insertions, 11 deletions
diff --git a/contrib/lisp/org-e-ascii.el b/contrib/lisp/org-e-ascii.el
index 308c377..8f0ee11 100644
--- a/contrib/lisp/org-e-ascii.el
+++ b/contrib/lisp/org-e-ascii.el
@@ -19,16 +19,19 @@
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
-
+;;
;; This library implements an ASCII back-end for Org generic exporter.
-
-;; To test it, run
;;
-;; M-: (org-export-to-buffer 'e-ascii "*Test e-ASCII*") RET
+;; It provides two commands for export, depending on the desired
+;; output: `org-e-ascii-export-as-ascii' (temporary buffer) and
+;; `org-e-ascii-export-to-ascii' ("txt" file).
+;;
+;; Output encoding is specified through `org-e-ascii-charset'
+;; variable, among `ascii', `latin1' and `utf-8' symbols.
;;
-;; in an Org mode buffer then switch to that buffer to see the ASCII
-;; export. See contrib/lisp/org-export.el for more details on how
-;; this exporter works.
+;; By default, horizontal rules span over the full text with, but with
+;; a given width attribute (set though #+ATTR_ASCII: :width <num>)
+;; they can be shortened and centered.
;;; Code:
@@ -1086,10 +1089,13 @@ holding contextual information."
"Transcode an HORIZONTAL-RULE object from Org to ASCII.
CONTENTS is nil. INFO is a plist holding contextual
information."
- (let ((width (org-export-read-attribute :attr_ascii horizontal-rule :width)))
- (make-string (or (and (wholenump width) width)
- (org-e-ascii--current-text-width horizontal-rule info))
- (if (eq (plist-get info :ascii-charset) 'utf-8) ?― ?-))))
+ (let ((text-width (org-e-ascii--current-text-width horizontal-rule info))
+ (spec-width
+ (org-export-read-attribute :attr_ascii horizontal-rule :width)))
+ (org-e-ascii--justify-string
+ (make-string (if (wholenump spec-width) spec-width text-width)
+ (if (eq (plist-get info :ascii-charset) 'utf-8) ?― ?-))
+ text-width 'center)))
;;;; Inline Babel Call