diff options
author | Bastien <bzg@gnu.org> | 2019-12-03 23:27:04 +0100 |
---|---|---|
committer | Bastien <bzg@gnu.org> | 2019-12-03 23:27:04 +0100 |
commit | 165f7383822086d465519ebe6e4283723923f097 (patch) | |
tree | 820be9480e3d571d766483f564c963037192f6ec /lisp/org/ox-ascii.el | |
parent | 821de968434d2096bdea67dd24301bf6b517aef1 (diff) | |
download | emacs-165f7383822086d465519ebe6e4283723923f097.tar.gz |
Update Org to 9.3
Diffstat (limited to 'lisp/org/ox-ascii.el')
-rw-r--r-- | lisp/org/ox-ascii.el | 61 |
1 files changed, 40 insertions, 21 deletions
diff --git a/lisp/org/ox-ascii.el b/lisp/org/ox-ascii.el index 7c9920f64c5..6e6c17c4964 100644 --- a/lisp/org/ox-ascii.el +++ b/lisp/org/ox-ascii.el @@ -632,7 +632,7 @@ Return value is a symbol among `left', `center', `right' and (or justification 'left))) (defun org-ascii--build-title - (element info text-width &optional underline notags toc) + (element info text-width &optional underline notags toc) "Format ELEMENT title and return it. ELEMENT is either an `headline' or `inlinetask' element. INFO is @@ -651,13 +651,12 @@ possible. It doesn't apply to `inlinetask' elements." (let* ((headlinep (eq (org-element-type element) 'headline)) (numbers ;; Numbering is specific to headlines. - (and headlinep (org-export-numbered-headline-p element info) - ;; All tests passed: build numbering string. - (concat - (mapconcat - 'number-to-string - (org-export-get-headline-number element info) ".") - " "))) + (and headlinep + (org-export-numbered-headline-p element info) + (let ((numbering (org-export-get-headline-number element info))) + (if toc (format "%d. " (org-last numbering)) + (concat (mapconcat #'number-to-string numbering ".") + " "))))) (text (org-trim (org-export-data @@ -672,8 +671,7 @@ possible. It doesn't apply to `inlinetask' elements." (plist-get info :with-tags) (let ((tag-list (org-export-get-tags element info))) (and tag-list - (format ":%s:" - (mapconcat 'identity tag-list ":")))))) + (org-make-tag-string tag-list))))) (priority (and (plist-get info :with-priority) (let ((char (org-element-property :priority element))) @@ -733,7 +731,7 @@ caption keyword." (org-export-data caption info)) (org-ascii--current-text-width element info) info))))) -(defun org-ascii--build-toc (info &optional n keyword local) +(defun org-ascii--build-toc (info &optional n keyword scope) "Return a table of contents. INFO is a plist used as a communication channel. @@ -744,10 +742,10 @@ depth of the table. Optional argument KEYWORD specifies the TOC keyword, if any, from which the table of contents generation has been initiated. -When optional argument LOCAL is non-nil, build a table of -contents according to the current headline." +When optional argument SCOPE is non-nil, build a table of +contents according to the specified scope." (concat - (unless local + (unless scope (let ((title (org-ascii--translate "Table of Contents" info))) (concat title "\n" (make-string @@ -769,7 +767,7 @@ contents according to the current headline." (or (not (plist-get info :with-tags)) (eq (plist-get info :with-tags) 'not-in-toc)) 'toc)))) - (org-export-collect-headlines info n (and local keyword)) "\n")))) + (org-export-collect-headlines info n scope) "\n")))) (defun org-ascii--list-listings (keyword info) "Return a list of listings. @@ -960,7 +958,7 @@ channel." (t (concat (org-ascii--fill-string - (format "[%s] %s" anchor (org-element-property :raw-link link)) + (format "[%s] <%s>" anchor (org-element-property :raw-link link)) width info) "\n\n"))))) links "")) @@ -1518,8 +1516,13 @@ information." ((string-match-p "\\<headlines\\>" value) (let ((depth (and (string-match "\\<[0-9]+\\>" value) (string-to-number (match-string 0 value)))) - (localp (string-match-p "\\<local\\>" value))) - (org-ascii--build-toc info depth keyword localp))) + (scope + (cond + ((string-match ":target +\\(\".+?\"\\|\\S-+\\)" value) ;link + (org-export-resolve-link + (org-strip-quotes (match-string 1 value)) info)) + ((string-match-p "\\<local\\>" value) keyword)))) ;local + (org-ascii--build-toc info depth keyword scope))) ((string-match-p "\\<tables\\>" value) (org-ascii--list-tables keyword info)) ((string-match-p "\\<listings\\>" value) @@ -1602,11 +1605,13 @@ INFO is a plist holding contextual information." ;; Don't know what to do. Signal it. (_ "???")))) (t - (let ((raw-link (org-element-property :raw-link link))) - (if (not (org-string-nw-p desc)) (format "[%s]" raw-link) + (let ((raw-link (concat (org-element-property :type link) + ":" + (org-element-property :path link)))) + (if (not (org-string-nw-p desc)) (format "<%s>" raw-link) (concat (format "[%s]" desc) (and (not (plist-get info :ascii-links-to-notes)) - (format " (%s)" raw-link))))))))) + (format " (<%s>)" raw-link))))))))) ;;;; Node Properties @@ -2067,6 +2072,20 @@ a communication channel." ;;; End-user functions ;;;###autoload +(defun org-ascii-convert-region-to-ascii () + "Assume region has Org syntax, and convert it to plain ASCII." + (interactive) + (let ((org-ascii-charset 'ascii)) + (org-export-replace-region-by 'ascii))) + +;;;###autoload +(defun org-ascii-convert-region-to-utf8 () + "Assume region has Org syntax, and convert it to UTF-8." + (interactive) + (let ((org-ascii-charset 'utf-8)) + (org-export-replace-region-by 'ascii))) + +;;;###autoload (defun org-ascii-export-as-ascii (&optional async subtreep visible-only body-only ext-plist) "Export current buffer to a text buffer. |