emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* customized link pointing at a src block
@ 2019-11-02 19:34 Łukasz Stelmach
  2019-11-10 11:25 ` Fraga, Eric
  0 siblings, 1 reply; 2+ messages in thread
From: Łukasz Stelmach @ 2019-11-02 19:34 UTC (permalink / raw)
  To: emacs-orgmode

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

Hi,

I'd like to have collapsible source code blocks in my org document
exported to HTML. To collapse and restore I have used[1]. The library
requires a link (or a button) with appropirate properties. A link needs
to point (href) to a block and have additional custom data-toggle
property. On Debian9/Emacs 24/org-mode 8.x I was able to craft such
links by hand

    #+HTML: <a class="btn" data-toggle="collapse" href="#code1">Show</a>

    #+NAME: code1
    #+BEGIN_SRC python
    return 42
    #+END_SRC

On Debian10/Emacs26/org-mode 9.1.9 src blocks with a NAME get
automatically generated id-s (org-export-get-reference) and I can see no
way to determine href in my HTML snippet. (ATTR_HTML before org-mode
link does not work as advertised in the manual either).

Is there any way to generate a link (or a button) for every code block
with matching href/id you can recommend?

[1] https://getbootstrap.com/docs/4.2/components/collapse/

Kind regards,
-- 
Było mi bardzo miło.                                  --- Rurku. --- ...
>Łukasz<                                --- To dobrze, że mnie słuchasz.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 617 bytes --]

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

* Re: customized link pointing at a src block
  2019-11-02 19:34 customized link pointing at a src block Łukasz Stelmach
@ 2019-11-10 11:25 ` Fraga, Eric
  0 siblings, 0 replies; 2+ messages in thread
From: Fraga, Eric @ 2019-11-10 11:25 UTC (permalink / raw)
  To: Łukasz Stelmach; +Cc: emacs-orgmode@gnu.org

You want the equivalent of the LaTeX exporter's

,----[ C-h v org-latex-prefer-user-labels RET ]
| org-latex-prefer-user-labels is a variable defined in ‘ox-latex.el’.
| Its value is t
| Original value was nil
| 
|   You can customize this variable.
| 
| 
| This variable was introduced, or its default value was changed, in
| version 26.1 of Emacs.
| 
| Documentation:
| Use user-provided labels instead of internal ones when non-nil.
| 
| [...]
| 
| For headlines that do not define the CUSTOM_ID property or
| elements without a NAME, Org will continue to use its default
| labeling scheme to generate labels and resolve links into proper
| references.
`----

I don't think the HTML exporter has anything similar but it should be
possible to implement...

-- 
Eric S Fraga via Emacs 27.0.50, Org release_9.2.6-552-g8c5a78

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

end of thread, other threads:[~2019-11-10 11:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-02 19:34 customized link pointing at a src block Łukasz Stelmach
2019-11-10 11:25 ` Fraga, Eric

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