mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-08-25 08:32:53 +00:00
org-list: enhance list transformations and fix glitches
* lisp/org-list.el (org-list-to-generic): set a default term for ill-formed description lists. Do not insert newline characters unless told to. (org-list-to-texinfo,org-list-to-html): apply changes to `org-list-parse-liste'.
This commit is contained in:
parent
294dcb25ab
commit
b6fc03b70c
|
@ -2850,13 +2850,19 @@ items."
|
||||||
;; extra information that needs to be processed.
|
;; extra information that needs to be processed.
|
||||||
(lambda (item type depth)
|
(lambda (item type depth)
|
||||||
(let* ((counter (pop item))
|
(let* ((counter (pop item))
|
||||||
(fmt (concat (cond
|
(fmt (concat
|
||||||
((eq type 'descriptive)
|
(cond
|
||||||
(concat (org-trim (eval istart)) "%s"
|
((eq type 'descriptive)
|
||||||
(eval ddend)))
|
;; Stick DTSTART to ISTART by
|
||||||
((and counter (eq type 'ordered))
|
;; left-trimming the latter.
|
||||||
(concat (eval icount) "%s"))
|
(concat (let ((s (eval istart)))
|
||||||
(t (concat (eval istart) "%s")))
|
(or (and (string-match "[ \t\n\r]+\\'" s)
|
||||||
|
(replace-match "" t t s))
|
||||||
|
istart))
|
||||||
|
"%s" (eval ddend)))
|
||||||
|
((and counter (eq type 'ordered))
|
||||||
|
(concat (eval icount) "%s"))
|
||||||
|
(t (concat (eval istart) "%s")))
|
||||||
(eval iend)))
|
(eval iend)))
|
||||||
(first (car item)))
|
(first (car item)))
|
||||||
;; Replace checkbox if any is found.
|
;; Replace checkbox if any is found.
|
||||||
|
@ -2868,12 +2874,17 @@ items."
|
||||||
((string-match "\\[-\\]" first)
|
((string-match "\\[-\\]" first)
|
||||||
(setq first (replace-match "$\\boxminus$" t t first))))
|
(setq first (replace-match "$\\boxminus$" t t first))))
|
||||||
;; Insert descriptive term if TYPE is `descriptive'.
|
;; Insert descriptive term if TYPE is `descriptive'.
|
||||||
(when (and (eq type 'descriptive)
|
(when (eq type 'descriptive)
|
||||||
(string-match "^\\(.*\\)[ \t]+::" first))
|
(let* ((complete (string-match "^\\(.*\\)[ \t]+::" first))
|
||||||
(setq first (concat
|
(term (if complete
|
||||||
(eval dtstart) (org-trim (match-string 1 first))
|
(save-match-data
|
||||||
(eval dtend) (eval ddstart)
|
(org-trim (match-string 1 first)))
|
||||||
(org-trim (substring first (match-end 0))) "")))
|
"???"))
|
||||||
|
(desc (if complete
|
||||||
|
(org-trim (substring first (match-end 0)))
|
||||||
|
first)))
|
||||||
|
(setq first (concat (eval dtstart) term (eval dtend)
|
||||||
|
(eval ddstart) desc))))
|
||||||
(setcar item first)
|
(setcar item first)
|
||||||
(format fmt
|
(format fmt
|
||||||
(mapconcat (lambda (e)
|
(mapconcat (lambda (e)
|
||||||
|
@ -2889,10 +2900,10 @@ items."
|
||||||
(fmt (concat (cond
|
(fmt (concat (cond
|
||||||
(splicep "%s")
|
(splicep "%s")
|
||||||
((eq type 'ordered)
|
((eq type 'ordered)
|
||||||
(concat (eval ostart) "\n%s" (eval oend)))
|
(concat (eval ostart) "%s" (eval oend)))
|
||||||
((eq type 'descriptive)
|
((eq type 'descriptive)
|
||||||
(concat (eval dstart) "\n%s" (eval dend)))
|
(concat (eval dstart) "%s" (eval dend)))
|
||||||
(t (concat (eval ustart) "\n%s" (eval uend))))
|
(t (concat (eval ustart) "%s" (eval uend))))
|
||||||
(eval lsep))))
|
(eval lsep))))
|
||||||
(format fmt (mapconcat (lambda (e)
|
(format fmt (mapconcat (lambda (e)
|
||||||
(funcall export-item e type depth))
|
(funcall export-item e type depth))
|
||||||
|
@ -2906,9 +2917,9 @@ with overruling parameters for `org-list-to-generic'."
|
||||||
(org-list-to-generic
|
(org-list-to-generic
|
||||||
list
|
list
|
||||||
(org-combine-plists
|
(org-combine-plists
|
||||||
'(:splice nil :ostart "\\begin{enumerate}" :oend "\\end{enumerate}"
|
'(:splice nil :ostart "\\begin{enumerate}\n" :oend "\\end{enumerate}"
|
||||||
:ustart "\\begin{itemize}" :uend "\\end{itemize}"
|
:ustart "\\begin{itemize}\n" :uend "\\end{itemize}"
|
||||||
:dstart "\\begin{description}" :dend "\\end{description}"
|
:dstart "\\begin{description}\n" :dend "\\end{description}"
|
||||||
:dtstart "[" :dtend "] "
|
:dtstart "[" :dtend "] "
|
||||||
:istart "\\item " :iend "\n"
|
:istart "\\item " :iend "\n"
|
||||||
:icount (let ((enum (nth depth '("i" "ii" "iii" "iv"))))
|
:icount (let ((enum (nth depth '("i" "ii" "iii" "iv"))))
|
||||||
|
@ -2927,12 +2938,12 @@ with overruling parameters for `org-list-to-generic'."
|
||||||
(org-list-to-generic
|
(org-list-to-generic
|
||||||
list
|
list
|
||||||
(org-combine-plists
|
(org-combine-plists
|
||||||
'(:splice nil :ostart "<ol>" :oend "\n</ol>"
|
'(:splice nil :ostart "<ol>\n" :oend "\n</ol>"
|
||||||
:ustart "<ul>" :uend "\n</ul>"
|
:ustart "<ul>\n" :uend "\n</ul>"
|
||||||
:dstart "<dl>" :dend "</dl>"
|
:dstart "<dl>\n" :dend "\n</dl>"
|
||||||
:dtstart "<dt>" :dtend "</dt>\n"
|
:dtstart "<dt>" :dtend "</dt>\n"
|
||||||
:ddstart "<dd>" :ddend "</dd>"
|
:ddstart "<dd>" :ddend "</dd>"
|
||||||
:istart "<li>" :iend "\n</li>"
|
:istart "<li>" :iend "</li>"
|
||||||
:icount (format "<li value=\"%s\">" counter)
|
:icount (format "<li value=\"%s\">" counter)
|
||||||
:isep "\n" :lsep "\n" :csep "\n"
|
:isep "\n" :lsep "\n" :csep "\n"
|
||||||
:cbon "<code>[X]</code>" :cboff "<code>[ ]</code>")
|
:cbon "<code>[X]</code>" :cboff "<code>[ ]</code>")
|
||||||
|
@ -2945,9 +2956,9 @@ with overruling parameters for `org-list-to-generic'."
|
||||||
(org-list-to-generic
|
(org-list-to-generic
|
||||||
list
|
list
|
||||||
(org-combine-plists
|
(org-combine-plists
|
||||||
'(:splice nil :ostart "@itemize @minus" :oend "@end itemize"
|
'(:splice nil :ostart "@itemize @minus\n" :oend "@end itemize"
|
||||||
:ustart "@enumerate" :uend "@end enumerate"
|
:ustart "@enumerate\n" :uend "@end enumerate"
|
||||||
:dstart "@table @asis" :dend "@end table"
|
:dstart "@table @asis\n" :dend "@end table"
|
||||||
:dtstart " " :dtend "\n"
|
:dtstart " " :dtend "\n"
|
||||||
:istart "@item\n" :iend "\n"
|
:istart "@item\n" :iend "\n"
|
||||||
:icount "@item\n"
|
:icount "@item\n"
|
||||||
|
|
Loading…
Reference in a new issue