emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Getting checkboxes in HTML output?


From: Peter Davis
Subject: Re: [O] Getting checkboxes in HTML output?
Date: Thu, 28 Nov 2013 08:55:50 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.1.0


On 11/28/13, 8:33 AM, Rick Frankel wrote:
On Wed, Nov 27, 2013 at 01:20:59PM -0500, Peter Davis wrote:
On Wed, Nov 27, 2013 at 11:03:38AM -0500, Nick Dokos wrote:
Peter Davis <address@hidden> writes:

I noticed that HTML output contains "[ ]" and "[X]", just like
the
mark-up. Wouldn't it make sense to use actual unchecked or
checked
checkboxes in HTML?

Is there a simple way to do this that I've overlooked?

A cursory glance through ox-html.el uncovered this:

--8<---------------cut here---------------start------------->8---
(defun org-html-checkbox (checkbox)
   "Format CHECKBOX into HTML."
   (case checkbox (on "<code>[X]</code>")
     (off "<code>[&#xa0;]</code>")
     (trans "<code>[-]</code>")
     (t "")))
--8<---------------cut here---------------end--------------->8---

Maybe you can redefine this function to do what you want?
Yes, this works:

--8<---------------cut here---------------start------------->8---
(defun org-html-checkbox (checkbox)
   "Format CHECKBOX into HTML."
   (case checkbox (on "<input type=\"checkbox\" checked />")
   (off "<input type=\"checkbox\" />")
   (trans "<code>[-]</code>")
   (t "")))
--8<---------------cut here---------------end--------------->8---
For xhtml compatibility, it would need to be 'checked="checked"'. I've
done a quick look at the html dtd, and i does look like input elements
are allowed outside of forms, but i would need to double
check... Also, the fallback to "[-]" for the partially checked state
is a bit inconsistent, perhaps changing background color or other
attributre of the checkbox would be better.

I would be willing to make this change (as an option?) to the html
exporter if others agree.
Thanks, Rick. Adding a value for the checked attribute is no problem. I didn't have a good solution for the partially checked state. One possibility would be adding the 'disabled="disabled"' attribute, which would make it appear gray. However, I've considered adding that attribute in all cases, since the HTML output is really for display and not input.

I'd love to see this as an option in the main code, so I don't have to keep retrofitting it into succeeding versions.

-pd

--
----
Peter Davis
The Tech Curmudgeon
www.techcurmudgeon.com




reply via email to

[Prev in Thread] Current Thread [Next in Thread]