Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Org reader support for ATTR_HTML #1906

Closed
bosmacs opened this issue Jan 27, 2015 · 11 comments · Fixed by #2927
Closed

Org reader support for ATTR_HTML #1906

bosmacs opened this issue Jan 27, 2015 · 11 comments · Fixed by #2927

Comments

@bosmacs
Copy link
Contributor

bosmacs commented Jan 27, 2015

Similar to #1877, it would be nice for the org reader to support #+ATTR_HTML. This was mentioned on pandoc-discuss a while back, and seems useful for adding arbitrary HTML attributes to non-header elements; take images, for example:

#+CAPTION: A black cat stalking a spider
#+ATTR_HTML: :alt cat/spider image :title Action! :align right
[[./img/a.jpg]]
@tarleb
Copy link
Collaborator

tarleb commented Jan 28, 2015

Agreed, this would be a very nice addition. I'm swamped with work, so any help is highly appreciated.

Which reminds me: that the smart quotations issue, which you raised, is still open, too. Sorry about that.

@jtmoulia
Copy link

jtmoulia commented Sep 1, 2015

👍 I'm not a haskellite, but I'll take a look when I get a chance.

@fommil
Copy link

fommil commented Nov 7, 2015

👍 a workaround would be good. I'd just like to be able to add attributes to my revealjs <section>s (e.g. background images / videos / etc)

@fommil
Copy link

fommil commented Nov 13, 2015

workaround, it's evil (you need to know the id of the thing you want to change):

#+BEGIN_HTML
<script type="text/javascript">
document.getElementById("shapeless").setAttribute("data-background", "./images/brucelee.jpg");
</script>
#+END_HTML

tarleb added a commit to tarleb/pandoc that referenced this issue May 19, 2016
A `#+ATTR_HTML` line can be used to add custom attributes to certain
blocks.  The reader support this now for figures and tables.

This closes jgm#1906.
tarleb added a commit to tarleb/pandoc that referenced this issue May 19, 2016
Arbitrary key-value pairs can be added to some block types using a
`#+ATTR_HTML` line before the block.  Emacs Org-mode only includes these
when exporting to HTML, but since we cannot make this distinction here,
the attributes are always added.

The functionality is now supported for figures.

This closes jgm#1906.
@jgm jgm closed this as completed in #2927 May 19, 2016
@fommil
Copy link

fommil commented May 19, 2016

wow, nice! This will really help out next I'm writing a talk.

@fommil
Copy link

fommil commented May 19, 2016

will this work for the reveal.js <section>s too?

@tarleb
Copy link
Collaborator

tarleb commented May 19, 2016

How are section marked in org-mode? Could you give me a brief example?

The current code only works with figures, but it should be easy to add this to any element as long as the respective pandoc element has an Attr. This means it could be added to Div, CodeBlock, or Header. Org-mode ignores it for headers (would require a :PREFERENCES: block), so Div and CodeBlock would work.

@fommil
Copy link

fommil commented May 19, 2016

They are level 1 or 2 headings in org-mode, when rendered to revealjs. I can point you at some talks if that helps but actually the simply example on the pandoc website might be enough.

@tarleb
Copy link
Collaborator

tarleb commented May 19, 2016

K, thx. Sounds like some basic support for :PREFERENCES: blocks is required to get this working. I will take another look at #1962 and #1984 over the next days.

It would be fairly easy to get this working with ATTR_HTML but that would not be comparatible to Emacs, so I'd rather not do that.

@hrehfeld
Copy link

Is this really resolved?

#+ATTR_HTML: :title atitle
#+BEGIN_myclass
test
#+END_myclass

should resolve to

<div title="atitle" class="myclass">
<p>
test
</p>

</div>

however, the generated json does not contain the title:

{"t":"Div","c":[["",["myclass"],[]],[{"t":"Para","c":[{"t":"Str","c":"test"}]}]]}

@tarleb
Copy link
Collaborator

tarleb commented Oct 25, 2016

This issue was mainly about figures. Please open a new issue for adding this to blocks in general.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants