forked from mirrors/org-mode
Merge branch 'master' of orgmode.org:org-mode
This commit is contained in:
commit
e03fc31ee1
|
@ -36,6 +36,7 @@
|
||||||
|
|
||||||
(declare-function org-element-get-contents "org-element" (element))
|
(declare-function org-element-get-contents "org-element" (element))
|
||||||
(declare-function org-element-get-property "org-element" (property element))
|
(declare-function org-element-get-property "org-element" (property element))
|
||||||
|
(declare-function org-element-normalize-string "org-element" (s))
|
||||||
(declare-function org-element-map "org-element"
|
(declare-function org-element-map "org-element"
|
||||||
(data types fun &optional info first-match))
|
(data types fun &optional info first-match))
|
||||||
(declare-function org-element-time-stamp-interpreter
|
(declare-function org-element-time-stamp-interpreter
|
||||||
|
@ -95,24 +96,15 @@ See `org-export-option-alist' for more information on the
|
||||||
structure or the values.")
|
structure or the values.")
|
||||||
|
|
||||||
(defconst org-e-ascii-dictionary
|
(defconst org-e-ascii-dictionary
|
||||||
'(("Table Of Contents\n"
|
'(("Footnotes\n"
|
||||||
("en"
|
("en"
|
||||||
:ascii "Table Of Contents\n"
|
:ascii "Footnotes\n"
|
||||||
:latin1 "Table Of Contents\n"
|
:latin1 "Footnotes\n"
|
||||||
:utf-8 "Table Of Contents\n")
|
:utf-8 "Footnotes\n")
|
||||||
("fr"
|
("fr"
|
||||||
:ascii "Sommaire\n"
|
:ascii "Notes de bas de page\n"
|
||||||
:latin1 "Table des matières\n"
|
:latin1 "Notes de bas de page\n"
|
||||||
:utf-8 "Table des matières\n"))
|
:utf-8 "Notes de bas de page\n"))
|
||||||
("Table %d: %s"
|
|
||||||
("en"
|
|
||||||
:ascii "Table %d: %s"
|
|
||||||
:latin1 "Table %d: %s"
|
|
||||||
:utf-8 "Table %d: %s")
|
|
||||||
("fr"
|
|
||||||
:ascii "Tableau %d : %s"
|
|
||||||
:latin1 "Tableau %d : %s"
|
|
||||||
:utf-8 "Tableau nº %d : %s"))
|
|
||||||
("Listing %d: %s"
|
("Listing %d: %s"
|
||||||
("en"
|
("en"
|
||||||
:ascii "Listing %d: %s"
|
:ascii "Listing %d: %s"
|
||||||
|
@ -149,6 +141,33 @@ structure or the values.")
|
||||||
:ascii "Programme %d : "
|
:ascii "Programme %d : "
|
||||||
:latin1 "Programme %d : "
|
:latin1 "Programme %d : "
|
||||||
:utf-8 "Programme nº %d : "))
|
:utf-8 "Programme nº %d : "))
|
||||||
|
("Table Of Contents\n"
|
||||||
|
("en"
|
||||||
|
:ascii "Table Of Contents\n"
|
||||||
|
:latin1 "Table Of Contents\n"
|
||||||
|
:utf-8 "Table Of Contents\n")
|
||||||
|
("fr"
|
||||||
|
:ascii "Sommaire\n"
|
||||||
|
:latin1 "Table des matières\n"
|
||||||
|
:utf-8 "Table des matières\n"))
|
||||||
|
("Table %d: %s"
|
||||||
|
("en"
|
||||||
|
:ascii "Table %d: %s"
|
||||||
|
:latin1 "Table %d: %s"
|
||||||
|
:utf-8 "Table %d: %s")
|
||||||
|
("fr"
|
||||||
|
:ascii "Tableau %d : %s"
|
||||||
|
:latin1 "Tableau %d : %s"
|
||||||
|
:utf-8 "Tableau nº %d : %s"))
|
||||||
|
("See section %s"
|
||||||
|
("en"
|
||||||
|
:ascii "See section %s"
|
||||||
|
:latin1 "See section %s"
|
||||||
|
:utf-8 "See section %s")
|
||||||
|
("fr"
|
||||||
|
:ascii "cf. section %s"
|
||||||
|
:latin1 "cf. section %s"
|
||||||
|
:utf-8 "cf. section %s"))
|
||||||
("Table %d: "
|
("Table %d: "
|
||||||
("en"
|
("en"
|
||||||
:ascii "Table %d: "
|
:ascii "Table %d: "
|
||||||
|
@ -166,16 +185,7 @@ structure or the values.")
|
||||||
("fr"
|
("fr"
|
||||||
:ascii "Destination inconnue"
|
:ascii "Destination inconnue"
|
||||||
:latin1 "Référence inconnue"
|
:latin1 "Référence inconnue"
|
||||||
:utf-8 "Référence inconnue"))
|
:utf-8 "Référence inconnue")))
|
||||||
("See section %s"
|
|
||||||
("en"
|
|
||||||
:ascii "See section %s"
|
|
||||||
:latin1 "See section %s"
|
|
||||||
:utf-8 "See section %s")
|
|
||||||
("fr"
|
|
||||||
:ascii "cf. section %s"
|
|
||||||
:latin1 "cf. section %s"
|
|
||||||
:utf-8 "cf. section %s")))
|
|
||||||
"Dictionary for ASCII back-end.
|
"Dictionary for ASCII back-end.
|
||||||
|
|
||||||
Alist whose car is the string to translate and cdr is an alist
|
Alist whose car is the string to translate and cdr is an alist
|
||||||
|
@ -211,6 +221,12 @@ Inner margin is applied between each headline."
|
||||||
:group 'org-export-e-ascii
|
:group 'org-export-e-ascii
|
||||||
:type 'integer)
|
:type 'integer)
|
||||||
|
|
||||||
|
(defcustom org-e-ascii-quote-margin 6
|
||||||
|
"Width of margin used for quoting text, in characters.
|
||||||
|
This margin is applied on both sides of the text."
|
||||||
|
:group 'org-export-e-ascii
|
||||||
|
:type 'integer)
|
||||||
|
|
||||||
(defcustom org-e-ascii-inlinetask-width 30
|
(defcustom org-e-ascii-inlinetask-width 30
|
||||||
"Width of inline tasks, in number of characters.
|
"Width of inline tasks, in number of characters.
|
||||||
This number ignores any margin."
|
This number ignores any margin."
|
||||||
|
@ -517,12 +533,11 @@ INFO is a plist used as a communication channel."
|
||||||
(- total-width
|
(- total-width
|
||||||
;; Each `quote-block', `quote-section' and `verse-block' above
|
;; Each `quote-block', `quote-section' and `verse-block' above
|
||||||
;; narrows text width by twice the standard margin size.
|
;; narrows text width by twice the standard margin size.
|
||||||
(+ (let ((margin (max (floor (/ total-width 12)) 2)))
|
(+ (* (loop for parent in genealogy
|
||||||
(* (loop for parent in genealogy
|
when (memq (car parent)
|
||||||
when (memq (car parent)
|
'(quote-block quote-section verse-block))
|
||||||
'(quote-block quote-section verse-block))
|
count parent)
|
||||||
count parent)
|
2 org-e-ascii-quote-margin)
|
||||||
2 margin))
|
|
||||||
;; Text width within a plain-list is restricted by
|
;; Text width within a plain-list is restricted by
|
||||||
;; indentation of current item. If that's the case,
|
;; indentation of current item. If that's the case,
|
||||||
;; compute it with the help of `:structure' property from
|
;; compute it with the help of `:structure' property from
|
||||||
|
@ -924,60 +939,68 @@ INFO is a plist used as a communication channel."
|
||||||
"Return complete document string after ASCII conversion.
|
"Return complete document string after ASCII conversion.
|
||||||
CONTENTS is the transcoded contents string. INFO is a plist
|
CONTENTS is the transcoded contents string. INFO is a plist
|
||||||
holding export options."
|
holding export options."
|
||||||
(org-e-ascii--indent-string
|
(org-element-normalize-string
|
||||||
(let ((text-width (- org-e-ascii-text-width org-e-ascii-global-margin)))
|
(org-e-ascii--indent-string
|
||||||
;; 1. Build title block.
|
(let ((text-width (- org-e-ascii-text-width org-e-ascii-global-margin)))
|
||||||
(concat
|
;; 1. Build title block.
|
||||||
(org-e-ascii-template--document-title info)
|
(concat
|
||||||
;; 2. Table of contents.
|
(org-e-ascii-template--document-title info)
|
||||||
(let ((depth (plist-get info :with-toc)))
|
;; 2. Table of contents.
|
||||||
(when depth
|
(let ((depth (plist-get info :with-toc)))
|
||||||
(concat
|
(when depth
|
||||||
(org-e-ascii--build-toc info (and (wholenump depth) depth))
|
(concat
|
||||||
"\n\n\n")))
|
(org-e-ascii--build-toc info (and (wholenump depth) depth))
|
||||||
;; 3. Document's body.
|
"\n\n\n")))
|
||||||
contents
|
;; 3. Document's body.
|
||||||
;; 4. Footnote definitions.
|
contents
|
||||||
(let ((definitions (org-export-collect-footnote-definitions
|
;; 4. Footnote definitions.
|
||||||
(plist-get info :parse-tree) info))
|
(let ((definitions (org-export-collect-footnote-definitions
|
||||||
;; Insert full links right inside the footnote definition
|
(plist-get info :parse-tree) info))
|
||||||
;; as they have no chance to be inserted later.
|
;; Insert full links right inside the footnote definition
|
||||||
(org-e-ascii-links-to-notes nil))
|
;; as they have no chance to be inserted later.
|
||||||
(when definitions
|
(org-e-ascii-links-to-notes nil))
|
||||||
(concat
|
(when definitions
|
||||||
"\n\n\n"
|
(concat
|
||||||
(mapconcat
|
"\n\n\n"
|
||||||
(lambda (ref)
|
(let ((title (org-e-ascii--translate "Footnotes\n" info)))
|
||||||
(let ((id (format "[%s] " (car ref))))
|
(concat
|
||||||
;; Distinguish between inline definitions and
|
title
|
||||||
;; full-fledged definitions.
|
(make-string
|
||||||
(org-trim
|
(1- (length title))
|
||||||
(let ((def (nth 2 ref)))
|
(if (eq (plist-get info :ascii-charset) 'utf-8) ?─ ?_))))
|
||||||
(if (eq (car def) 'org-data)
|
"\n\n"
|
||||||
;; Full-fledged definition: footnote ID is
|
(mapconcat
|
||||||
;; inserted inside the first parsed paragraph
|
(lambda (ref)
|
||||||
;; (FIRST), if any, to be sure filling will
|
(let ((id (format "[%s] " (car ref))))
|
||||||
;; take it into consideration.
|
;; Distinguish between inline definitions and
|
||||||
(let ((first (car (org-element-get-contents def))))
|
;; full-fledged definitions.
|
||||||
(if (not (eq (car first) 'paragraph))
|
(org-trim
|
||||||
(concat id "\n" (org-export-data def 'e-ascii info))
|
(let ((def (nth 2 ref)))
|
||||||
(push id (nthcdr 2 first))
|
(if (eq (car def) 'org-data)
|
||||||
(org-export-data def 'e-ascii info)))
|
;; Full-fledged definition: footnote ID is
|
||||||
;; Fill paragraph once footnote ID is inserted in
|
;; inserted inside the first parsed paragraph
|
||||||
;; order to have a correct length for first line.
|
;; (FIRST), if any, to be sure filling will
|
||||||
(org-e-ascii--fill-string
|
;; take it into consideration.
|
||||||
(concat id (org-export-secondary-string def 'e-ascii info))
|
(let ((first (car (org-element-get-contents def))))
|
||||||
text-width info))))))
|
(if (not (eq (car first) 'paragraph))
|
||||||
definitions "\n\n"))))
|
(concat id "\n" (org-export-data def 'e-ascii info))
|
||||||
;; 5. Creator. Ignore `comment' value as there are no comments in
|
(push id (nthcdr 2 first))
|
||||||
;; ASCII. Justify it to the bottom right.
|
(org-export-data def 'e-ascii info)))
|
||||||
(let ((creator-info (plist-get info :with-creator)))
|
;; Fill paragraph once footnote ID is inserted in
|
||||||
(unless (or (not creator-info) (eq creator-info 'comment))
|
;; order to have a correct length for first line.
|
||||||
(concat
|
(org-e-ascii--fill-string
|
||||||
"\n\n\n"
|
(concat id (org-export-secondary-string def 'e-ascii info))
|
||||||
(org-e-ascii--fill-string
|
text-width info))))))
|
||||||
(plist-get info :creator) text-width info 'right))))))
|
definitions "\n\n"))))
|
||||||
org-e-ascii-global-margin))
|
;; 5. Creator. Ignore `comment' value as there are no comments in
|
||||||
|
;; ASCII. Justify it to the bottom right.
|
||||||
|
(let ((creator-info (plist-get info :with-creator)))
|
||||||
|
(unless (or (not creator-info) (eq creator-info 'comment))
|
||||||
|
(concat
|
||||||
|
"\n\n\n"
|
||||||
|
(org-e-ascii--fill-string
|
||||||
|
(plist-get info :creator) text-width info 'right))))))
|
||||||
|
org-e-ascii-global-margin)))
|
||||||
|
|
||||||
(defun org-e-ascii--translate (s info)
|
(defun org-e-ascii--translate (s info)
|
||||||
"Translate string S.
|
"Translate string S.
|
||||||
|
@ -1440,11 +1463,11 @@ channel."
|
||||||
"Transcode a QUOTE-BLOCK element from Org to ASCII.
|
"Transcode a QUOTE-BLOCK element from Org to ASCII.
|
||||||
CONTENTS holds the contents of the block. INFO is a plist
|
CONTENTS holds the contents of the block. INFO is a plist
|
||||||
holding contextual information."
|
holding contextual information."
|
||||||
(let* ((width (org-e-ascii--current-text-width quote-block info))
|
(let ((width (org-e-ascii--current-text-width quote-block info)))
|
||||||
(margin-width (max (floor (/ width 12)) 2)))
|
|
||||||
(org-e-ascii--indent-string
|
(org-e-ascii--indent-string
|
||||||
(org-remove-indentation
|
(org-remove-indentation
|
||||||
(org-e-ascii--fill-string contents width info)) margin-width)))
|
(org-e-ascii--fill-string contents width info))
|
||||||
|
org-e-ascii-quote-margin)))
|
||||||
|
|
||||||
|
|
||||||
;;;; Quote Section
|
;;;; Quote Section
|
||||||
|
@ -1452,15 +1475,14 @@ holding contextual information."
|
||||||
(defun org-e-ascii-quote-section (quote-section contents info)
|
(defun org-e-ascii-quote-section (quote-section contents info)
|
||||||
"Transcode a QUOTE-SECTION element from Org to ASCII.
|
"Transcode a QUOTE-SECTION element from Org to ASCII.
|
||||||
CONTENTS is nil. INFO is a plist holding contextual information."
|
CONTENTS is nil. INFO is a plist holding contextual information."
|
||||||
(let* ((width (org-e-ascii--current-text-width quote-section info))
|
(let ((width (org-e-ascii--current-text-width quote-section info))
|
||||||
(margin-width (max (floor (/ width 12)) 2))
|
(value
|
||||||
(value
|
(org-export-secondary-string
|
||||||
(org-export-secondary-string
|
(org-remove-indentation
|
||||||
(org-remove-indentation
|
(org-element-get-property :value quote-section)) 'e-ascii info)))
|
||||||
(org-element-get-property :value quote-section)) 'e-ascii info)))
|
|
||||||
(org-e-ascii--indent-string
|
(org-e-ascii--indent-string
|
||||||
value
|
value
|
||||||
(+ margin-width
|
(+ org-e-ascii-quote-margin
|
||||||
;; Don't apply inner margin if parent headline is low level.
|
;; Don't apply inner margin if parent headline is low level.
|
||||||
(let ((headline (org-export-get-parent-headline quote-section info)))
|
(let ((headline (org-export-get-parent-headline quote-section info)))
|
||||||
(if (org-export-low-level-p headline info) 0
|
(if (org-export-low-level-p headline info) 0
|
||||||
|
@ -1818,7 +1840,7 @@ CONTENTS is nil. INFO is a plist holding contextual information."
|
||||||
(org-export-secondary-string
|
(org-export-secondary-string
|
||||||
(org-element-get-property :value verse-block) 'e-ascii info)
|
(org-element-get-property :value verse-block) 'e-ascii info)
|
||||||
verse-width 'left)
|
verse-width 'left)
|
||||||
(max (floor (/ verse-width 12)) 2))))
|
org-e-ascii-quote-margin)))
|
||||||
|
|
||||||
|
|
||||||
;;; Filter
|
;;; Filter
|
||||||
|
|
Loading…
Reference in New Issue