-
-
Notifications
You must be signed in to change notification settings - Fork 16.6k
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
Attributes in markdown #640
Conversation
@hakimel I have rebased this pull request on top of #677 that you just merged into dev. I have also restored the initial pattern for attributes in elements You will find the same idea in the |
Nice. Can you also remove the debug code (console logs) and add an example to the readme that uses the default slide attribute separator? |
All done, and pushed, based on your latest |
Thanks man! At work now but will merge this in shortly. |
By default, look for <!-- slide-attributes: xxxx -->. Whatever 'xxx' is will be added to the section attributes. You can define your own pattern with 'data-attributes'. For instance 'data-attributes="^\s*?-- (.*?)$"': that will be added to the options. The 'attributes' section is removed from the content of the slide, so the final markdown doesn't reflect them. That also means you can add those attributes *anywhere* in the slide But that allows for *any* attribute to be added for a specifc slide, like: - id="plan", for allowing internal link (issue hakimel#430) - data-background="#ff0000" - data-transition="fade" You list those attributes on a single line, like - (default): ` <!-- id="plan" data-background="#ff0000" -->` - or, with an alternative data-attributes pattern: ` -- id="plan" data-background="#ff0000"` Again, that line is remove from the final content.
The first slide of a vertical stack see some data attributes ignored. Mainly the data-transition one. Repeat all data-attributes on the wrapping section element. Ignore any other attributes (like 'id="xxx"'), in order to not mess with internal links (by repeating twice an id).
It is important that test/test-element-attributes-markdown.html do test the ability for the user to define its own pattern.
It should be `{. xxxx=yyy }`, not `{_ xxxx=yyy }`. Only test/test-element-attributes-markdown.html were using `{_`, simply in order to test the ability, for the user, to define a _different_ pattern.
I've already pulled this into my local branch but haven't pushed it yet since I'm running into issues. Attributes are working in test but the following simple single-slide test doesn't work: <section data-markdown>
<script type="text/template">
<!-- slide-attributes: data-background="#ff0000" -->
## Hello world
</script>
</section> Also what do you think about bringing this and the element attribute syntax closer together? I'd like there to be some theme to this since there's getting to be a lot of different separator expressions. |
@hakimel "element syntax selection"? Are you talking about my previous markdown patch #677? It yes, those are two different syntaxes for two different use cases. I'll prefer to see them separate. The default patterns are important (for classes in markdown-generated elements, it is an html comment, in order for those classes to not be displayed in an html preview, when using a markdown editor like https://stackedit.io/). First, I'll include your case in the slide attributes unit tests, and debug that. |
That's meant to be element attribute syntax. Okay the usefulness of HTML comment syntax makes sense, so how about we define element attributes in the same way? ## Hello world <!-- element-attributes: class="fragment" --> |
@hakimel Can you try again you test case?
It should work now just fine. And the test cases have been updated to test just that scenario. Once you have merge and published that on the branch hakimel/reveal.js@dev, I'll open a new issue/pull request to discuss how to merge markdown element attributes #677, and slide attributes (this pull request #640). |
Thanks for fixing that. I've merged this in. |
Slide attributes in Markdown
Allow an external Markdown file to set attributes for each slide
(replace #639, because the pull request is now rebased on
dev
, notmaster
):For example, that slide will set an id, transition and color:
The slide attributes themselves are removed from the final markdown content, and not visible in the resulting html slide.
Incidentally, that should also solve #430 (Markdown Support for internal links);
Another slide can now refers to "plan" with: