diff --git a/ox-blackfriday.el b/ox-blackfriday.el index 2e784ec..63f5a9b 100644 --- a/ox-blackfriday.el +++ b/ox-blackfriday.el @@ -320,7 +320,10 @@ ELEM Org element using #+ATTR_HTML. If #+ATTR_CSS is also used, and if a class is specified in #+ATTR_HTML, then an inline style is also inserted that applies -the specified CSS to that class." +the specified CSS to that class. + +If CONTENTS is nil, and #+ATTR_CSS is used, return only the HTML +style tag." (let* ((elem-type (org-element-type elem)) (attr (let ((attr1 (org-export-read-attribute :attr_html elem))) (when (equal elem-type 'paragraph) @@ -331,23 +334,24 @@ the specified CSS to that class." (plist-put attr1 :target nil) (plist-put attr1 :rel nil)) attr1)) - (attr-str (org-html--make-attribute-string attr))) - (if (org-string-nw-p attr-str) - (let ((class (plist-get attr :class)) - (style-str "")) - (when class - (let* ((css-props (org-export-read-attribute :attr_css elem)) - (css-props-str (org-blackfriday--make-css-property-string css-props))) - (when (org-string-nw-p css-props-str) - (setq style-str (format "\n\n" - class css-props-str))))) - - (concat style-str - (format "
\n" attr-str) - "
\n\n" ;See footnote 1 - contents - "\n
")) - contents))) + (attr-str (org-html--make-attribute-string attr)) + (ret contents)) + (when (org-string-nw-p attr-str) + (let ((class (plist-get attr :class)) + (style-str "")) + (when class + (let* ((css-props (org-export-read-attribute :attr_css elem)) + (css-props-str (org-blackfriday--make-css-property-string css-props))) + (when (org-string-nw-p css-props-str) + (setq style-str (format "\n\n" + class css-props-str))))) + + (setq ret (concat style-str + (if contents + (format "
\n
\n\n%s\n
" ;See footnote 1 + attr-str contents) + ""))))) + ret)) @@ -513,18 +517,23 @@ INFO is a plist holding contextual information." "Transcode PLAIN-LIST element into Blackfriday Markdown format. CONTENTS is the plain-list contents. INFO is a plist used as a communication channel." - (if (org-blackfriday--ordered-list-with-custom-counter-p plain-list) - ;; If this is an ordered list and if any item in this list is - ;; using a custom counter, export this list in HTML. - (org-html-plain-list plain-list contents info) - (let* ((next (org-export-get-next-element plain-list info)) - (next-type (org-element-type next)) - (next-is-list (eq 'plain-list next-type))) - (concat contents - ;; Two consecutive lists in Markdown can be separated by - ;; a comment. - (when next-is-list - "\n"))))) + (let (ret) + (if (org-blackfriday--ordered-list-with-custom-counter-p plain-list) + ;; If this is an ordered list and if any item in this list is + ;; using a custom counter, export this list in HTML. + (setq ret (concat + (org-blackfriday--div-wrap-maybe plain-list nil) + (org-html-plain-list plain-list contents info))) + (let* ((next (org-export-get-next-element plain-list info)) + (next-type (org-element-type next)) + (next-is-list (eq 'plain-list next-type))) + (setq ret (org-blackfriday--div-wrap-maybe plain-list contents)) + (setq ret (concat ret + ;; Two consecutive lists in Markdown can be + ;; separated by a comment. + (when next-is-list + "\n"))))) + ret)) ;;;; Plain Text (defun org-blackfriday-plain-text (text info) diff --git a/test/site/content-org/all-posts.org b/test/site/content-org/all-posts.org index a0ecd7d..0cb65d4 100644 --- a/test/site/content-org/all-posts.org +++ b/test/site/content-org/all-posts.org @@ -2414,11 +2414,13 @@ element than the /bar*/ items. - zoo2 1. numbered1 2. numbered2 -** Force ordered list numbering +** Force ordered list numbering :custom_counter: :PROPERTIES: :EXPORT_DATE: 2017-08-01 :EXPORT_FILE_NAME: force-ordered-list-numbering :END: +Ordered lists with custom counter. + 1. This will be 1. 1. This will be 2. @@ -2467,6 +2469,38 @@ Checklist showing progress in ratio. - [X] Task 3 - [ ] Task 4 - [X] Task 5 +** Plain lists with ATTR_HTML :attr___html:attr___css:custom_counter: +:PROPERTIES: +:EXPORT_FILE_NAME: lists-with-attr-html +:END: +*** Unordered lists +#+ATTR_HTML: :class red-text +#+ATTR_CSS: :color red +- Red list item 1 +- Red list item 2 + +#+ATTR_HTML: :class green-text +#+ATTR_CSS: :color green +- Green list item 1 +- Green list item 2 +*** Ordered lists +#+ATTR_HTML: :class green-text +1. Green ordered list item 1 +2. Green ordered list item 2 + +/The =green-text= style is defined in the list above this one./ +**** Ordered list with custom counter +#+ATTR_HTML: :class blue-text +#+ATTR_CSS: :color blue +1. Blue list item 1 +2. Blue list item 2 +3. [@10]Blue list item 10 +*** Definition lists +#+ATTR_HTML: :class red-text +- Defn A :: Something A in red +- Defn B :: Something B in red + +/The =red-text= style is defined in the first list above./ * Quotes :quotes: ** Consecutive quotes :PROPERTIES: diff --git a/test/site/content/posts/force-ordered-list-numbering.md b/test/site/content/posts/force-ordered-list-numbering.md index 1e4a8f0..90a5b85 100644 --- a/test/site/content/posts/force-ordered-list-numbering.md +++ b/test/site/content/posts/force-ordered-list-numbering.md @@ -1,10 +1,12 @@ +++ title = "Force ordered list numbering" date = 2017-08-01 -tags = ["lists"] +tags = ["lists", "custom-counter"] draft = false +++ +Ordered lists with custom counter. + 1. This will be 1. 2. This will be 2. diff --git a/test/site/content/posts/lists-with-attr-html.md b/test/site/content/posts/lists-with-attr-html.md new file mode 100644 index 0000000..2f4caa0 --- /dev/null +++ b/test/site/content/posts/lists-with-attr-html.md @@ -0,0 +1,65 @@ ++++ +title = "Plain lists with ATTR_HTML" +tags = ["lists", "attr_html", "attr_css", "custom-counter"] +draft = false ++++ + +## Unordered lists {#unordered-lists} + + + +
+
+ +- Red list item 1 +- Red list item 2 + +
+ + + + +
+
+ +- Green list item 1 +- Green list item 2 + +
+ + +## Ordered lists {#ordered-lists} + +
+
+ +1. Green ordered list item 1 +2. Green ordered list item 2 + +
+ +_The `green-text` style is defined in the list above this one._ + + +### Ordered list with custom counter {#ordered-list-with-custom-counter} + + + +
    +
  1. Blue list item 1
  2. +
  3. Blue list item 2
  4. +
  5. Blue list item 10
  6. +
+ + +## Definition lists {#definition-lists} + +
+
+ +- **Defn A:** Something A in red +- **Defn B:** Something B in red + +
+ +_The `red-text` style is defined in the first list above._