emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] ox-html: Allow "Figure %d:", etc. to be styled
@ 2013-07-03 22:19 Kodi Arfer
  2013-07-09 19:53 ` Nicolas Goaziou
  0 siblings, 1 reply; 5+ messages in thread
From: Kodi Arfer @ 2013-07-03 22:19 UTC (permalink / raw)
  To: emacs-orgmode

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



[-- Attachment #2: 0001-ox-html-Allow-Figure-d-etc.-to-be-styled.patch --]
[-- Type: text/x-patch, Size: 3621 bytes --]

From a873d204b2c4f3facf2d8658f69764acbd063246 Mon Sep 17 00:00:00 2001
From: Kodi Arfer <git@arfer.net>
Date: Wed, 3 Jul 2013 17:51:56 -0400
Subject: [PATCH] ox-html: Allow "Figure %d:", etc. to be styled

* lisp/ox-html.el (org-html-paragraph): Wrap "Figure %d:" in
  <span class="figure-number">.
  (org-html-list-of-tables, org-html-table): Wrap "Table %d:" in
   <span class="table-number">.
  (org-html-list-of-listings): Wrap "Listing %d:" in
  <span class="listing-number">.
* doc/org.text (CSS support): Mention .figure-number,
  .listing-number, and .table-number.

I didn't change org-html-style-default, so these labels won't
appear special by default.

TINYCHANGE
---
 doc/org.texi    |  3 +++
 lisp/ox-html.el | 14 +++++++++-----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/doc/org.texi b/doc/org.texi
index 4eb9a45..ce4f715 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -11337,6 +11337,9 @@ p.creator           @r{creator info, about org mode version}
 div.outline-N       @r{div for outline level N (headline plus text))}
 div.outline-text-N  @r{extra div for text at outline level N}
 .section-number-N   @r{section number in headlines, different for each level}
+.figure-number      @r{label like "Figure 1:"}
+.table-number       @r{label like "Table 1:"}
+.listing-number     @r{label like "Listing 1:"}
 div.figure          @r{how to format an inlined image}
 pre.src             @r{formatted source code}
 pre.example         @r{normal example}
diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 9ce73c4..b0417e8 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -2009,7 +2009,8 @@ of listings as a string, or nil if it is empty."
 		      org-html-toplevel-hlevel)
 	      "<div id=\"text-list-of-listings\">\n<ul>\n"
 	      (let ((count 0)
-		    (initial-fmt (org-html--translate "Listing %d:" info)))
+		    (initial-fmt (format "<span class=\"listing-number\">%s</span>"
+					 (org-html--translate "Listing %d:" info))))
 		(mapconcat
 		 (lambda (entry)
 		   (let ((label (org-element-property :name entry))
@@ -2043,7 +2044,8 @@ of tables as a string, or nil if it is empty."
 		      org-html-toplevel-hlevel)
 	      "<div id=\"text-list-of-tables\">\n<ul>\n"
 	      (let ((count 0)
-		    (initial-fmt (org-html--translate "Table %d:" info)))
+		    (initial-fmt (format "<span class=\"table-number\">%s</span>"
+					 (org-html--translate "Table %d:" info))))
 		(mapconcat
 		 (lambda (entry)
 		   (let ((label (org-element-property :name entry))
@@ -2790,12 +2792,13 @@ the plist used as a communication channel."
 		    'org-html--has-caption-p))
 	       (if (not (org-string-nw-p raw)) raw
 		 (concat
+                  "<span class=\"figure-number\">"
 		  (format (org-html--translate "Figure %d:" info)
 			  (org-export-get-ordinal
 			   (org-element-map paragraph 'link
 			     'identity info t)
 			   info nil 'org-html-standalone-image-p))
-		  " " raw))))
+		  "</span> " raw))))
 	    (label (org-element-property :name paragraph)))
 	(org-html--wrap-image contents info caption label)))
      ;; Regular paragraph.
@@ -3204,8 +3207,9 @@ contextual information."
 			     "<caption align=\"above\">%s</caption>"
 			   "<caption align=\"bottom\">%s</caption>")
 			 (concat
-			  (format (org-html--translate "Table %d:" info) number)
-			  " " (org-export-data caption info))))
+			  "<span class=\"table-number\">"
+                          (format (org-html--translate "Table %d:" info) number)
+			  "</span> " (org-export-data caption info))))
 	       (funcall table-column-specs table info)
 	       contents)))))
 
-- 
1.8.1.2


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

* Re: [PATCH] ox-html: Allow "Figure %d:", etc. to be styled
  2013-07-03 22:19 [PATCH] ox-html: Allow "Figure %d:", etc. to be styled Kodi Arfer
@ 2013-07-09 19:53 ` Nicolas Goaziou
  2013-07-09 20:19   ` Kodi Arfer
  0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Goaziou @ 2013-07-09 19:53 UTC (permalink / raw)
  To: Kodi Arfer; +Cc: emacs-orgmode

Hello,

Kodi Arfer <kodi@arfer.net> writes:

> From a873d204b2c4f3facf2d8658f69764acbd063246 Mon Sep 17 00:00:00 2001
> From: Kodi Arfer <git@arfer.net>
> Date: Wed, 3 Jul 2013 17:51:56 -0400
> Subject: [PATCH] ox-html: Allow "Figure %d:", etc. to be styled
>
> * lisp/ox-html.el (org-html-paragraph): Wrap "Figure %d:" in
>   <span class="figure-number">.
>   (org-html-list-of-tables, org-html-table): Wrap "Table %d:" in
>    <span class="table-number">.
>   (org-html-list-of-listings): Wrap "Listing %d:" in
>   <span class="listing-number">.
> * doc/org.text (CSS support): Mention .figure-number,
>   .listing-number, and .table-number.

Thank you for the patch.

Wouldn't it be more future-proof to wrap them within the same CSS entry?
Otherwise, if we ever introduce other caption types, we'll need to
remember to add another entry for it.

Obviously, my question assume it is very unlikely that someone would
want different styles for captions. But I may be wrong.

BTW, do you have any news about your FSF papers?


Regards,

-- 
Nicolas Goaziou

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

* Re: [PATCH] ox-html: Allow "Figure %d:", etc. to be styled
  2013-07-09 19:53 ` Nicolas Goaziou
@ 2013-07-09 20:19   ` Kodi Arfer
  2013-07-09 20:31     ` Nicolas Goaziou
  2013-07-09 21:24     ` Bastien
  0 siblings, 2 replies; 5+ messages in thread
From: Kodi Arfer @ 2013-07-09 20:19 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

On 2013 Jul 09 Tue 3:53:26 PM -0400, Nicolas Goaziou 
<n.goaziou@gmail.com> wrote:
> Kodi Arfer <kodi@arfer.net> writes:
>
>>  From a873d204b2c4f3facf2d8658f69764acbd063246 Mon Sep 17 00:00:00 2001
>> From: Kodi Arfer <git@arfer.net>
>> Date: Wed, 3 Jul 2013 17:51:56 -0400
>> Subject: [PATCH] ox-html: Allow "Figure %d:", etc. to be styled
>>
>> * lisp/ox-html.el (org-html-paragraph): Wrap "Figure %d:" in
>>    <span class="figure-number">.
>>    (org-html-list-of-tables, org-html-table): Wrap "Table %d:" in
>>     <span class="table-number">.
>>    (org-html-list-of-listings): Wrap "Listing %d:" in
>>    <span class="listing-number">.
>> * doc/org.text (CSS support): Mention .figure-number,
>>    .listing-number, and .table-number.
>
> Thank you for the patch.

De nada.

> Wouldn't it be more future-proof to wrap them within the same CSS entry?
> Otherwise, if we ever introduce other caption types, we'll need to
> remember to add another entry for it.
>
> Obviously, my question assume it is very unlikely that someone would
> want different styles for captions. But I may be wrong.

One case I know of is APA style. Here are some examples from the APA 
publication manual. "Figure 1" is supposed to be italicized and inline 
with the caption ( http://i.imgur.com/u6jsfJx.png ), whereas "Table 1" 
is supposed to be upright and on its own line ( 
http://i.imgur.com/3gvxEdd.png ). Admittedly, APA style is crazy, and 
you have to be additionally crazy to want APA style in HTML.

We could still use the same class and then expect people to use 
selectors to be as specific as they want (e.g., if the generic class is 
~.caption-number~, one could use the selector ~caption .caption-number~ 
for tables and ~figcaption .caption-number~ for figures, at least in 
HTML5). I think using different classes is actually simpler, though, 
because then we don't have to keep track of how selectable the different 
caption types are.

> BTW, do you have any news about your FSF papers?

I got an assignment form back from the FSF, and I returned scans of the 
signed form on July 1, but I haven't heard back since.

I guess there's not much of a hurry. I won't be firing off these little 
patches as much now that I've released http://arfer.net/daylight .

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

* Re: [PATCH] ox-html: Allow "Figure %d:", etc. to be styled
  2013-07-09 20:19   ` Kodi Arfer
@ 2013-07-09 20:31     ` Nicolas Goaziou
  2013-07-09 21:24     ` Bastien
  1 sibling, 0 replies; 5+ messages in thread
From: Nicolas Goaziou @ 2013-07-09 20:31 UTC (permalink / raw)
  To: Kodi Arfer; +Cc: emacs-orgmode

Kodi Arfer <kodi@arfer.net> writes:

> One case I know of is APA style. Here are some examples from the APA
> publication manual. "Figure 1" is supposed to be italicized and inline
> with the caption ( http://i.imgur.com/u6jsfJx.png ), whereas "Table 1"
> is supposed to be upright and on its own line
> ( http://i.imgur.com/3gvxEdd.png ). Admittedly, APA style is crazy,
> and you have to be additionally crazy to want APA style in HTML.
>
> We could still use the same class and then expect people to use
> selectors to be as specific as they want (e.g., if the generic class
> is ~.caption-number~, one could use the selector ~caption
> .caption-number~ for tables and ~figcaption .caption-number~ for
> figures, at least in HTML5). I think using different classes is
> actually simpler, though, because then we don't have to keep track of
> how selectable the different caption types are.

Understood. Patch applied.

Thank you again.


Regards,

-- 
Nicolas Goaziou

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

* Re: [PATCH] ox-html: Allow "Figure %d:", etc. to be styled
  2013-07-09 20:19   ` Kodi Arfer
  2013-07-09 20:31     ` Nicolas Goaziou
@ 2013-07-09 21:24     ` Bastien
  1 sibling, 0 replies; 5+ messages in thread
From: Bastien @ 2013-07-09 21:24 UTC (permalink / raw)
  To: Kodi Arfer; +Cc: emacs-orgmode, Nicolas Goaziou

Kodi Arfer <kodi@arfer.net> writes:

>> BTW, do you have any news about your FSF papers?
>
> I got an assignment form back from the FSF, and I returned scans of
> the signed form on July 1, but I haven't heard back since.

I just received the confirmation from the FSF that Kodi assignment
is okay.  Welcome!  No need to add TINYCHANGE anymore.

Thanks,

-- 
 Bastien

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

end of thread, other threads:[~2013-07-09 21:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-03 22:19 [PATCH] ox-html: Allow "Figure %d:", etc. to be styled Kodi Arfer
2013-07-09 19:53 ` Nicolas Goaziou
2013-07-09 20:19   ` Kodi Arfer
2013-07-09 20:31     ` Nicolas Goaziou
2013-07-09 21:24     ` 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).