Support ATTR_HTML above plain lists

master
Kaushal Modi 8 years ago
parent a2d43f3beb
commit 3fd8f31db8
  1. 69
      ox-blackfriday.el
  2. 36
      test/site/content-org/all-posts.org
  3. 4
      test/site/content/posts/force-ordered-list-numbering.md
  4. 65
      test/site/content/posts/lists-with-attr-html.md

@ -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 "<style>.%s { %s }</style>\n\n"
class css-props-str)))))
(concat style-str
(format "<div %s>\n" attr-str)
" <div></div>\n\n" ;See footnote 1
contents
"\n</div>"))
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 "<style>.%s { %s }</style>\n\n"
class css-props-str)))))
(setq ret (concat style-str
(if contents
(format "<div %s>\n <div></div>\n\n%s\n</div>" ;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<!--listend-->")))))
(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<!--listend-->")))))
ret))
;;;; Plain Text
(defun org-blackfriday-plain-text (text info)

@ -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:

@ -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.

@ -0,0 +1,65 @@
+++
title = "Plain lists with ATTR_HTML"
tags = ["lists", "attr_html", "attr_css", "custom-counter"]
draft = false
+++
## Unordered lists {#unordered-lists}
<style>.red-text { color: red; }</style>
<div class="red-text">
<div></div>
- Red list item 1
- Red list item 2
</div>
<!--listend-->
<style>.green-text { color: green; }</style>
<div class="green-text">
<div></div>
- Green list item 1
- Green list item 2
</div>
## Ordered lists {#ordered-lists}
<div class="green-text">
<div></div>
1. Green ordered list item 1
2. Green ordered list item 2
</div>
_The `green-text` style is defined in the list above this one._
### Ordered list with custom counter {#ordered-list-with-custom-counter}
<style>.blue-text { color: blue; }</style>
<ol class="org-ol blue-text">
<li>Blue list item 1</li>
<li>Blue list item 2</li>
<li value="10">Blue list item 10</li>
</ol>
## Definition lists {#definition-lists}
<div class="red-text">
<div></div>
- **Defn A:** Something A in red
- **Defn B:** Something B in red
</div>
_The `red-text` style is defined in the first list above._
Loading…
Cancel
Save