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

Add list fragment shorthand #26

Merged
merged 6 commits into from
Feb 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,16 @@ Fragments allow slide elements to come one by one. This is often used in lists t
- come one by one <fragment/>
```

Or, if you find it cleaner, like this:

```markdown
# Slide

+ This
+ will
+ come one by one
```

### Slide backgrounds

To modify the background of the current slide, **jekyll-reveal.js** simplifies the syntax to `<background>color</background>`:
Expand Down
29 changes: 28 additions & 1 deletion _layouts/reveal.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,34 @@
{% for post in site.posts reversed %}
<section data-markdown data-separator="^\n---\n$" data-separator-vertical="^\n--\n$" data-notes="^Note:">
<script type="text/template">
{{ post.content | replace:'<fragment/>','<!-- .element: class="fragment" -->' | replace:'<background>','<!-- .slide: data-background="' | replace:'</background>','" -->' | replace: '<backgroundimage>','<!-- .slide: data-background="' | replace: '</backgroundimage>','" --> ' | replace: '<backgroundimageopacity>','<!-- .slide: data-background-opacity="' | replace: '</backgroundimageopacity>','" -->' }}
{%
assign lines = post.content | newline_to_br | strip_newlines | split: "<br />"
%}{%
for line in lines
%}{%
assign processed_line = line
| replace:'<fragment/>','<!-- .element: class="fragment" -->'
| replace:'<background>','<!-- .slide: data-background="'
| replace:'</background>','" -->'
| replace:'<backgroundimage>','<!-- .slide: data-background="'
| replace:'</backgroundimage>','" --> '
| replace:'<backgroundimageopacity>','<!-- .slide: data-background-opacity="'
| replace:'</backgroundimageopacity>','" -->'
%}{%
assign first_char = line
| slice: 0,1
%}{%
if first_char == '+'
%}{%
assign processed_line = processed_line
| replace_first: '+',''
| prepend: '+ <!-- .element: class="fragment" -->'
%}{%
endif
%}{{ processed_line }}{% comment %}Following line break is important{% endcomment %}
{%
endfor
%}
</script>
</section>
{% endfor %}
Expand Down
9 changes: 6 additions & 3 deletions _posts/0000-01-03-fragments.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

It's also possible to do fragments.

- You can use &lt;fragment/&gt; to step your list items
- like <fragment/>
- this <fragment/>
- Start the line with ‘+’ instead of ‘-’ for your fragment item like this:
`+ This is a fragment`
+ This is a fragment
+ Your fragment may contain the ‘+’ character

<fragment/>You can use &lt;fragment/&gt; to step other content.