emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Is it possible to add a class to a paragraph in HTML export?
@ 2014-04-01 19:28 Marcin Borkowski
  2014-04-01 19:37 ` Bastien
  0 siblings, 1 reply; 7+ messages in thread
From: Marcin Borkowski @ 2014-04-01 19:28 UTC (permalink / raw)
  To: Org-mode mailing list

Hi,

I'd like to have a <p class="myfunnyclass"> in export.  I tried
#+ATTR_HTML :class myfunnyclass
but it didn't work.

Is there any way to do it?

TIA,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University

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

* Re: Is it possible to add a class to a paragraph in HTML export?
  2014-04-01 19:28 Is it possible to add a class to a paragraph in HTML export? Marcin Borkowski
@ 2014-04-01 19:37 ` Bastien
  2014-04-01 19:45   ` Marcin Borkowski
  2014-04-02  7:06   ` Nicolas Goaziou
  0 siblings, 2 replies; 7+ messages in thread
From: Bastien @ 2014-04-01 19:37 UTC (permalink / raw)
  To: Marcin Borkowski; +Cc: Org-mode mailing list

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

Hi Marcin,

Marcin Borkowski <mbork@wmi.amu.edu.pl> writes:

> I'd like to have a <p class="myfunnyclass"> in export.  I tried
> #+ATTR_HTML :class myfunnyclass
> but it didn't work.

You can't for now but this patch will make it work.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: ox-html-add-paragraph-class.patch --]
[-- Type: text/x-diff, Size: 915 bytes --]

diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index a843441..76472c7 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -2899,6 +2899,8 @@ the plist used as a communication channel."
   (let* ((parent (org-export-get-parent paragraph))
 	 (parent-type (org-element-type parent))
 	 (style '((footnote-definition " class=\"footpara\"")))
+	 (class0 (org-export-read-attribute :attr_html paragraph :class))
+	 (class (if class0 (format " class=\"%s\"" class0)))
 	 (extra (or (cadr (assoc parent-type style)) "")))
     (cond
      ((and (eq (org-element-type parent) 'item)
@@ -2925,7 +2927,7 @@ the plist used as a communication channel."
 	    (label (org-element-property :name paragraph)))
 	(org-html--wrap-image contents info caption label)))
      ;; Regular paragraph.
-     (t (format "<p%s>\n%s</p>" extra contents)))))
+     (t (format "<p%s%s>\n%s</p>" class extra contents)))))
 
 ;;;; Plain List
 

[-- Attachment #3: Type: text/plain, Size: 14 bytes --]


-- 
 Bastien

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

* Re: Is it possible to add a class to a paragraph in HTML export?
  2014-04-01 19:37 ` Bastien
@ 2014-04-01 19:45   ` Marcin Borkowski
  2014-04-02  7:06   ` Nicolas Goaziou
  1 sibling, 0 replies; 7+ messages in thread
From: Marcin Borkowski @ 2014-04-01 19:45 UTC (permalink / raw)
  To: emacs-orgmode

Dnia 2014-04-01, o godz. 21:37:06
Bastien <bzg@gnu.org> napisał(a):

> Hi Marcin,
> 
> Marcin Borkowski <mbork@wmi.amu.edu.pl> writes:
> 
> > I'd like to have a <p class="myfunnyclass"> in export.  I tried
> > #+ATTR_HTML :class myfunnyclass
> > but it didn't work.
> 
> You can't for now but this patch will make it work.
> 

Wow, thanks a lot?  Any chance this will land in the "official"
Org-mode repo soon?

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University

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

* Re: Is it possible to add a class to a paragraph in HTML export?
  2014-04-01 19:37 ` Bastien
  2014-04-01 19:45   ` Marcin Borkowski
@ 2014-04-02  7:06   ` Nicolas Goaziou
  2014-04-02  7:58     ` Christian Moe
  2014-04-17  1:13     ` Rick Frankel
  1 sibling, 2 replies; 7+ messages in thread
From: Nicolas Goaziou @ 2014-04-02  7:06 UTC (permalink / raw)
  To: Bastien; +Cc: Org-mode mailing list, Marcin Borkowski

Hello,

Bastien <bzg@gnu.org> writes:

> +	 (class0 (org-export-read-attribute :attr_html paragraph :class))
> +	 (class (if class0 (format " class=\"%s\"" class0)))
>  	 (extra (or (cadr (assoc parent-type style)) "")))
>      (cond
>       ((and (eq (org-element-type parent) 'item)
> @@ -2925,7 +2927,7 @@ the plist used as a communication channel."
>  	    (label (org-element-property :name paragraph)))
>  	(org-html--wrap-image contents info caption label)))
>       ;; Regular paragraph.
> -     (t (format "<p%s>\n%s</p>" extra contents)))))
> +     (t (format "<p%s%s>\n%s</p>" class extra contents)))))

If deemed useful, I think this patch should use
`org-html--make-attribute-string' instead of hard-coding "class"
attribute:

  (attributes (org-html--make-attribute-string
               (org-export-read-attribute :attr_html paragraph)))

...

  (t (format "<p%s%s>\n%s</p>" attributes extra contents))

This way, attributes will not be limited to "class" only. See, for
example, `org-html-special-block'.


Regards,

-- 
Nicolas Goaziou

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

* Re: Is it possible to add a class to a paragraph in HTML export?
  2014-04-02  7:06   ` Nicolas Goaziou
@ 2014-04-02  7:58     ` Christian Moe
  2014-04-17  1:13     ` Rick Frankel
  1 sibling, 0 replies; 7+ messages in thread
From: Christian Moe @ 2014-04-02  7:58 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Bastien, Org-mode mailing list, Marcin Borkowski


Nicolas Goaziou writes:

> If deemed useful, I think this patch should use
> `org-html--make-attribute-string' instead of hard-coding "class"
> attribute

+1. I would find this change useful.

Yours,
Christian

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

* Re: Is it possible to add a class to a paragraph in HTML export?
  2014-04-02  7:06   ` Nicolas Goaziou
  2014-04-02  7:58     ` Christian Moe
@ 2014-04-17  1:13     ` Rick Frankel
  2014-04-17  6:20       ` Bastien
  1 sibling, 1 reply; 7+ messages in thread
From: Rick Frankel @ 2014-04-17  1:13 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Bastien, Org-mode mailing list, Marcin Borkowski

On Wed, Apr 02, 2014 at 09:06:48AM +0200, Nicolas Goaziou wrote:
>
> If deemed useful, I think this patch should use
> `org-html--make-attribute-string' instead of hard-coding "class"
> attribute:
>
>   (attributes (org-html--make-attribute-string
>                (org-export-read-attribute :attr_html paragraph)))
>
> ...
>
>   (t (format "<p%s%s>\n%s</p>" attributes extra contents))
>
> This way, attributes will not be limited to "class" only. See, for
> example, `org-html-special-block'.

A version of this patch using Nicolas' approach has been pushed to master.

rick

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

* Re: Is it possible to add a class to a paragraph in HTML export?
  2014-04-17  1:13     ` Rick Frankel
@ 2014-04-17  6:20       ` Bastien
  0 siblings, 0 replies; 7+ messages in thread
From: Bastien @ 2014-04-17  6:20 UTC (permalink / raw)
  To: Rick Frankel; +Cc: Org-mode mailing list, Nicolas Goaziou, Marcin Borkowski

Rick Frankel <rick@rickster.com> writes:

> A version of this patch using Nicolas' approach has been pushed to
> master.

Thanks!

-- 
 Bastien

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

end of thread, other threads:[~2014-04-17  6:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-01 19:28 Is it possible to add a class to a paragraph in HTML export? Marcin Borkowski
2014-04-01 19:37 ` Bastien
2014-04-01 19:45   ` Marcin Borkowski
2014-04-02  7:06   ` Nicolas Goaziou
2014-04-02  7:58     ` Christian Moe
2014-04-17  1:13     ` Rick Frankel
2014-04-17  6:20       ` Bastien

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