emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Renaming of +NAME for code blocks to in HTML export, no longer user defined
@ 2016-01-04 18:04 Adam Aviv
  2016-01-04 18:29 ` Nick Dokos
  0 siblings, 1 reply; 5+ messages in thread
From: Adam Aviv @ 2016-01-04 18:04 UTC (permalink / raw)
  To: Emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 1427 bytes --]

Hi all,

I've been using org-mode for some time to manage a course website, and I
developed a hack for source blocking where if I use the +NAME tag for
source doe like so:

#+NAME: helloworld.cpp
#+BEGIN_SRC c++ -r
#include <iostream> (ref:include)

using namespace std; (ref:namespace)

// Hello World in C++
int main(int argc, char * argv[]){
  cout << "Hello World" << endl; (ref:speak)
}
#+END_SRC

Then I could retrieve the name tag in the HTML source via the id when
exported, like so:

<pre class="src src-c++" id="helloworld.cpp">

I can then use the id tag and CSS to have it float next to the code like
this:

[image: Inline image 1]


However, since I updated org-mode recently to version 8.3.2, the +NAME
tagging is no longer user defined. Instead, it get's a generic, org defined
name, such as orgsrcblock1. This means my little hack no longer works and I
get something that looks like this in the HTML exporting:

<pre class="src src-c++" id="orgsrcblock1">

I have two questions for the group:

1) Is there a way to overwrite the generic source block naming? Or turn off
this feature somewhere? I can't seem to figure that out for myself.

2) Is there another hack that someone can suggest? For example, is there a
way to have a user defined <div> tag around the src code that will get
exported?

Thanks!

adam



-- 
Adam J. Aviv, PhD
*Asst. Professor*
*Computer Science*
*U.S. Naval Academy*
*(410) 293- 6655*

[-- Attachment #1.2: Type: text/html, Size: 2482 bytes --]

[-- Attachment #2: Screenshot 2016-01-04 12.53.57.png --]
[-- Type: image/png, Size: 40401 bytes --]

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

* Re: Renaming of +NAME for code blocks to in HTML export, no longer user defined
  2016-01-04 18:04 Renaming of +NAME for code blocks to in HTML export, no longer user defined Adam Aviv
@ 2016-01-04 18:29 ` Nick Dokos
  2016-01-05 16:44   ` Adam Aviv
  0 siblings, 1 reply; 5+ messages in thread
From: Nick Dokos @ 2016-01-04 18:29 UTC (permalink / raw)
  To: emacs-orgmode

Adam Aviv <aviv@usna.edu> writes:

> Hi all,
>
> I've been using org-mode for some time to manage a course website, and I developed a hack for source
> blocking where if I use the +NAME tag for source doe like so:
>
> #+NAME: helloworld.cpp
> #+BEGIN_SRC c++ -r
> #include <iostream> (ref:include)
>
> using namespace std; (ref:namespace)
>
> // Hello World in C++
> int main(int argc, char * argv[]){
>   cout << "Hello World" << endl; (ref:speak)
> }
> #+END_SRC
>
> Then I could retrieve the name tag in the HTML source via the id when exported, like so:
>
> <pre class="src src-c++" id="helloworld.cpp">
>
> I can then use the id tag and CSS to have it float next to the code like this:
>
> Inline image 1                           
>
> However, since I updated org-mode recently to version 8.3.2, the +NAME tagging is no longer user
> defined. Instead, it get's a generic, org defined name, such as orgsrcblock1. This means my little hack
> no longer works and I get something that looks like this in the HTML exporting:
>
> <pre class="src src-c++" id="orgsrcblock1">
>
> I have two questions for the group:
>
> 1) Is there a way to overwrite the generic source block naming? Or turn off this feature somewhere? I
> can't seem to figure that out for myself. 
>
> 2) Is there another hack that someone can suggest? For example, is there a way to have a user defined
> <div> tag around the src code that will get exported?
>

It may be a bug: the code (in org-html-src-block) looks like this

	  (label (let ((lbl (and (org-element-property :name src-block)
				 (org-export-get-reference src-block info))))
		   (if lbl (format " id=\"%s\"" lbl) ""))))

and I'm wondering whether the "and" should be an "or".

--
Nick

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

* Re: Renaming of +NAME for code blocks to in HTML export, no longer user defined
  2016-01-04 18:29 ` Nick Dokos
@ 2016-01-05 16:44   ` Adam Aviv
  2016-01-21  9:20     ` Nicolas Goaziou
  0 siblings, 1 reply; 5+ messages in thread
From: Adam Aviv @ 2016-01-05 16:44 UTC (permalink / raw)
  To: Nick Dokos; +Cc: emacs-orgmode

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

On Mon, Jan 4, 2016 at 1:29 PM, Nick Dokos <ndokos@gmail.com> wrote:

> It may be a bug: the code (in org-html-src-block) looks like this
>
>           (label (let ((lbl (and (org-element-property :name src-block)
>                                  (org-export-get-reference src-block
> info))))
>                    (if lbl (format " id=\"%s\"" lbl) ""))))
>
> and I'm wondering whether the "and" should be an "or".
>

Interesting. I don't know if it is a bug, though, as this seems intentional
and matches my experience. The idea being that if you want to label
something, you use the :name tag, but this will make it so the second item
is evaluated, producing a unique identifier. The unique identifier is then
assigned instead of the :name tag. If it was an, OR, however, then every
element block would get a label, and that might be suboptimal given that
not every block is referenced later.

I would still like to be able to add my own name tags, but understand why
this might have been changed to avoid to blocks having the same label.


-- 
Adam J. Aviv, PhD
*Asst. Professor*
*Computer Science*
*U.S. Naval Academy*
*(410) 293- 6655*

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

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

* Re: Renaming of +NAME for code blocks to in HTML export, no longer user defined
  2016-01-05 16:44   ` Adam Aviv
@ 2016-01-21  9:20     ` Nicolas Goaziou
  2016-01-21 14:21       ` Adam Aviv
  0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Goaziou @ 2016-01-21  9:20 UTC (permalink / raw)
  To: Adam Aviv; +Cc: Nick Dokos, emacs-orgmode

Hello,

Adam Aviv <aviv@usna.edu> writes:

> Interesting. I don't know if it is a bug, though, as this seems intentional
> and matches my experience. The idea being that if you want to label
> something, you use the :name tag, but this will make it so the second item
> is evaluated, producing a unique identifier. The unique identifier is then
> assigned instead of the :name tag. If it was an, OR, however, then every
> element block would get a label, and that might be suboptimal given that
> not every block is referenced later.

That's correct.

> I would still like to be able to add my own name tags, but understand why
> this might have been changed to avoid to blocks having the same label.

That and the fact that one might introduce forbidden characters in the
name (e.g., ask the user to know about forbidden characters in the
target format). The generic names are pretty safe.

Anyway, what about using special blocks to generate custom <div>?

  #+attr_html: :property whatever
  #+begin_something
  ...
  #+end_something


Regards,

-- 
Nicolas Goaziou

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

* Re: Renaming of +NAME for code blocks to in HTML export, no longer user defined
  2016-01-21  9:20     ` Nicolas Goaziou
@ 2016-01-21 14:21       ` Adam Aviv
  0 siblings, 0 replies; 5+ messages in thread
From: Adam Aviv @ 2016-01-21 14:21 UTC (permalink / raw)
  To: Adam Aviv, Nick Dokos, emacs-orgmode

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

On Thu, Jan 21, 2016 at 4:20 AM, Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:

> That and the fact that one might introduce forbidden characters in the
> name (e.g., ask the user to know about forbidden characters in the
> target format). The generic names are pretty safe.
>
> Anyway, what about using special blocks to generate custom <div>?
>
>   #+attr_html: :property whatever
>   #+begin_something
>   ...
>   #+end_something
>
>
Thanks for the feedback. All of that makes sense. Is there really a
+begin_somthing tag? Or are you referring to any general tag? Sorry for my
obtuseness.

I'll look into the :property issue: I think that'd properly work for my
needs.


-- 
Adam J. Aviv, PhD
*Asst. Professor*
*Computer Science*
*U.S. Naval Academy*
*(410) 293- 6655*

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

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

end of thread, other threads:[~2016-01-21 14:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-04 18:04 Renaming of +NAME for code blocks to in HTML export, no longer user defined Adam Aviv
2016-01-04 18:29 ` Nick Dokos
2016-01-05 16:44   ` Adam Aviv
2016-01-21  9:20     ` Nicolas Goaziou
2016-01-21 14:21       ` Adam Aviv

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