emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Case sensitivity of special block names in HTML export / class names
@ 2019-07-29 12:52 Nik Clayton
  0 siblings, 0 replies; only message in thread
From: Nik Clayton @ 2019-07-29 12:52 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1415 bytes --]

Hoi,

Org special block names (within Org) appear to be case-insensitive. That
is, I can write either:

#+BEGIN_NOTES
...
#+END_NOTES

or

#+begin_notes
...
#+end_notes

and Org is happy. I think the switch from Org 8 to 9 changed the default
templates to insert lower-case blocks instead of upper case blocks, so it's
natural now to have files that contain a mix of both cases.

This is a problem for HTML export, as they get converted to:

<div class="NOTES">...</div>

or

<div class="notes">...</div>

depending on the original case of the special block in the .org file. HTML
class element values are case sensitive in non-quirks mode browsers, so
this makes existing CSS for content exported by Org fail, as

div.NOTES { ... }

does not match a <div class="notes">.

A quick local fix is:

(defun my/downcase-special-block (ohsb special-block contents info)
  (let ((special-block-copy (org-element-copy special-block)))
    (org-element-put-property
     special-block-copy
     :type
     (downcase (org-element-property :type special-block)))
    (funcall ohsb special-block-copy contents info)))

(advice-add #'org-html-special-block :around
            #'my/downcase-special-block)

But I wanted to raise this in case there was any interest in a more general
solution (perhaps a configuration option to either (a) retain case (current
behaviour), (b) convert to lower case, (c) convert to upper case?

N

[-- Attachment #2: Type: text/html, Size: 2959 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-07-29 12:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-29 12:52 Case sensitivity of special block names in HTML export / class names Nik Clayton

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).