emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* How do I set a class for a paragraph in HTML export?
@ 2014-12-02  1:10 Marcin Borkowski
  2014-12-02  4:36 ` Richard Lawrence
  0 siblings, 1 reply; 2+ messages in thread
From: Marcin Borkowski @ 2014-12-02  1:10 UTC (permalink / raw)
  To: Org-Mode mailing list

Hi all,

I'd like to get something like this:

<p class="myclass">Hello world</p>

What should I write in the Org file?  Looking at org-html-paragraph, I'm
afraid that it's currently impossible.

If this is indeed the case, what do I do to change it?  A natural idea
is that I could define an org-my-html-paragraph and plug it into a
custom exporter.  However, I do not want to repeat the whole code of
org-html-paragraph, which I don't even fully understand (it would take
me some time to digest it...).  Two ideas that come to me are: either
use an #+ATTR_MY_HTML line (or similar), or enclose my paragraph in
#+BEGIN_MYCLASS ... #+END_MYCLASS and detect this (I already have this:

(defun org-edu-html-check-for-block-type (element block-type)
  "Check whether ELEMENT is inside a BLOCK-TYPE (which is a
string) special block."
  (let ((parent (org-export-get-parent element)))
    (cond ((and (eq (car parent) 'special-block)
		(string= (org-element-property :type parent) block-type))
	   t)
	  (parent
	   (org-edu-html-check-for-block-type parent block-type)))))

so that I can do that easily).  However, it seems that if I take this
route, I will loose all bells and whistles of org-html-paragraph
anyway.

Any suggestions?

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: How do I set a class for a paragraph in HTML export?
  2014-12-02  1:10 How do I set a class for a paragraph in HTML export? Marcin Borkowski
@ 2014-12-02  4:36 ` Richard Lawrence
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Lawrence @ 2014-12-02  4:36 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Marcin Borkowski

Hi Marcin,

Marcin Borkowski <mbork@wmi.amu.edu.pl> writes:
>
> I'd like to get something like this:
>
> <p class="myclass">Hello world</p>
>
> What should I write in the Org file?  Looking at org-html-paragraph, I'm
> afraid that it's currently impossible.

This works for me:

----------------------------------
#+ATTR_HTML: :class myclass
This is a paragraph.
----------------------------------

That produces
----------------------------------
<p class="myclass">
This is a paragraph.</p>
----------------------------------
in the exported HTML.

Best,
Richard

OpenPGP Key ID: CF6FA646
Fingerprint: 9969 43E1 CF6F A646

(See http://www.ocf.berkeley.edu/~rwl/encryption.html for more information.)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-12-02  4:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-02  1:10 How do I set a class for a paragraph in HTML export? Marcin Borkowski
2014-12-02  4:36 ` Richard Lawrence

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