From: Kaushal Modi <kaushal.modi@gmail.com>
To: emacs-org list <emacs-orgmode@gnu.org>
Subject: Re: RFC: Proposal for an Org Special Block for ox-html
Date: Thu, 24 May 2018 14:28:06 -0400 [thread overview]
Message-ID: <CAFyQvY3Z=oR-TW1dWcFjaKqc3Ld1Jw05UL=QcRy_buPdweQSOg@mail.gmail.com> (raw)
In-Reply-To: <CAFyQvY2j1=qh37wad3V-u0XUziih2-tuNjFUrUjiru23q0riJg@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2653 bytes --]
Hello Aaron,
On Thu, May 24, 2018 at 2:08 PM Kaushal Modi <kaushal.modi@gmail.com> wrote:
> Expanding on your idea.. what if we had another Special block with name
> summary?
>
> #+begin_details
> #+begin_summary
> Open for details
>
> More summary.
> #+end_summary
> Many details here.
> #+end_details
>
From quick testing, this works (doesn't support the div tags for HTML4).
The good part is that the "summary" Special Block is automatically handled
by ox-html.
((string= block-type "details")
;; Recognize Org Special blocks like:
;; #+begin_details
;; #+begin_summary
;; This is summary.
;; #+end_summary
;; Here are the details.
;; #+end_details
(let* ((is-open (member "open" (org-element-property :attr_html
special-block)))
(str1 (org-blackfriday-special-block special-block contents
nil))
;; Insert a new-line before the closing </details> tag
;; for correct Markdown parsing for cases when the
;; Special Block content ends a code block. Without this
;; inserted newline, the Markdown converted content will
;; look like below, and Blackfriday won't parse it
;; correctly.
;; ```emacs-lisp
;; (message "a code block")
;; ```</details>
;; A closing </p> tag is also added.. the opening <p>
;; tag is later added in the `str2' var if summary is
;; present, else in `str3' var.
(str1 (replace-regexp-in-string "</details>\\'" "\n</p>\\&"
str1))
;; Detect the summary closing tag "</summary>".
;; Also add the opening <p> tag with "details" class
;; so that just as CSS rules can be set for summary
;; ("details summary"), they can be set for the details
;; portion following the <summary> too, using "details
;; .details".
(str2 (replace-regexp-in-string
"\\(<summary>\\(.\\|\n\\)*</summary>\\)"
"\\1<p class=\"details\">"
str1)))
;; (message "[DBG details/summary]: is-open:%S `%s' `%s'" is-open
str1 str2)
(if is-open
(replace-regexp-in-string "\\`\\(<details\\)>" "\\1 open>" str2)
str2)))
Also, thinking about HTML4 support, as details and summary tags were added
in HTML5, the "support" would be simply to and the (string= block-type
"details") condition with org-html-html5-fancy or equivalent. So then for
HTML4, details and summary Special Blocks will simply be div tags.
--
Kaushal Modi
[-- Attachment #2: Type: text/html, Size: 4037 bytes --]
next prev parent reply other threads:[~2018-05-24 18:28 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-24 13:40 RFC: Proposal for an Org Special Block for ox-html Kaushal Modi
2018-05-24 17:41 ` Aaron Ecay
2018-05-24 18:08 ` Kaushal Modi
2018-05-24 18:28 ` Kaushal Modi [this message]
2018-05-24 18:36 ` Aaron Ecay
2018-05-24 18:47 ` Kaushal Modi
2018-05-24 19:08 ` Aaron Ecay
2018-05-24 19:25 ` Kaushal Modi
2018-05-25 14:19 ` Aaron Ecay
2018-05-25 15:09 ` Kaushal Modi
2018-05-25 16:38 ` Kaushal Modi
2018-05-27 16:21 ` Aaron Ecay
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAFyQvY3Z=oR-TW1dWcFjaKqc3Ld1Jw05UL=QcRy_buPdweQSOg@mail.gmail.com' \
--to=kaushal.modi@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.