Support descriptive lists nested in other lists

This is a workaround for Blackfriday limitation, as there doesn't seem
to be a way to nest Blackfriday syntax descriptive/definition lists.
master
Kaushal Modi 8 years ago
parent cfaea8b0a2
commit 972f8b7208
  1. 35
      ox-blackfriday.el
  2. 24
      test/site/content-org/all-posts.org
  3. 32
      test/site/content/posts/nested-lists.md

@ -461,7 +461,21 @@ contextual information."
(if (org-blackfriday--ordered-list-with-custom-counter-p parent-list)
(org-html-format-list-item contents 'ordered nil info
(org-element-property :counter item))
(let* ((type (org-element-property :type (org-export-get-parent item)))
(let* ((parent-list (org-export-get-parent item))
(parent-list-type (org-element-property :type parent-list))
(desc-list? (eq parent-list-type 'descriptive))
(grandparent (when desc-list?
(org-export-get-parent parent-list)))
(grandparent-type (when desc-list?
(org-element-type grandparent)))
(list-is-nested (eq 'item grandparent-type))
;; Export the descriptive list items like that in
;; ox-md.el if this descriptive list is nested in some
;; other list, because the Blackfriday style descriptive
;; list syntax seems to work only at top level (i.e. not
;; when that list is nested).
(ox-md-style-desc-list (and desc-list? list-is-nested))
(bf-style-desc-list (and desc-list? (not list-is-nested)))
(struct (org-element-property :structure item))
(item-num (car (last (org-list-get-item-number
(org-element-property :begin item)
@ -469,18 +483,23 @@ contextual information."
(org-list-prevs-alist struct)
(org-list-parents-alist struct)))))
(bullet (cond
((eq type 'unordered)
((or (eq parent-list-type 'unordered)
ox-md-style-desc-list)
"-")
((eq type 'ordered)
((eq parent-list-type 'ordered)
(format "%d." item-num))
(t ;Descriptive
(t ;Non-nested descriptive list item
(when (> item-num 1)
"\n")))) ;Newline between each descriptive list item
(padding (unless (eq type 'descriptive)
(padding (unless bf-style-desc-list
(make-string (- 4 (length bullet)) ? )))
(tag (when (eq type 'descriptive)
(let ((tag1 (org-element-property :tag item)))
(and tag1 (format "%s\n: " (org-export-data tag1 info)))))))
(tag (when desc-list?
(let* ((tag1 (org-element-property :tag item))
(tag1-str (org-export-data tag1 info)))
(when tag1
(if ox-md-style-desc-list
(format "**%s:** " tag1-str)
(format "%s\n: " tag1-str)))))))
(concat bullet
padding
(pcase (org-element-property :checkbox item)

@ -2399,7 +2399,7 @@ element than the /bar*/ items.
- bar1 :: description
- bar2 :: description
** Nested lists
** Nested lists :@upstream:
:PROPERTIES:
:EXPORT_FILE_NAME: nested-lists
:EXPORT_DATE: 2017-07-31
@ -2414,6 +2414,28 @@ element than the /bar*/ items.
- zoo2
1. numbered1
2. numbered2
*** Unordered list inside descriptive list
- bar1 :: description for bar1
- foo1
- foo2
- bar2 :: description for bar2
- foo3
- foo4
*** Descriptive list inside unordered list
*Seems like Blackfriday style descriptive list syntax does not work
when that list is nested in other lists.*
So in that case, switch back to the descriptive list syntax used in
=ox-md=.
-----
- foo1
- bar1 :: description for bar1
- bar2 :: description for bar2
- foo2
- bar3 :: description for bar3
- bar4 :: description for bar4
** Force ordered list numbering :custom_counter:
:PROPERTIES:
:EXPORT_DATE: 2017-08-01

@ -2,6 +2,7 @@
title = "Nested lists"
date = 2017-07-31
tags = ["lists"]
categories = ["upstream"]
draft = false
+++
@ -15,3 +16,34 @@ draft = false
- zoo2
1. numbered1
2. numbered2
## Unordered list inside descriptive list {#unordered-list-inside-descriptive-list}
bar1
: description for bar1
- foo1
- foo2
bar2
: description for bar2
- foo3
- foo4
## Descriptive list inside unordered list {#descriptive-list-inside-unordered-list}
**Seems like Blackfriday style descriptive list syntax does not work
when that list is nested in other lists.**
So in that case, switch back to the descriptive list syntax used in
`ox-md`.
---
- foo1
- **bar1:** description for bar1
- **bar2:** description for bar2
- foo2
- **bar3:** description for bar3
- **bar4:** description for bar4

Loading…
Cancel
Save