reveal.js: Data separator and data vertical don't work with external markdown

I tried the following and it worked:

<section data-markdown data-separator="^\n----\n$" data-vertical="^\n---\n$">
  <script type="text/template">
    ###Title

    ---

    ####Title 2
    * 1
    * 2
  </script>
</section>

capture d cran 2014-05-29 15 41 35

But if I use an external markdown file:

<section data-markdown="slides/test.md" data-separator="^\n----\n$" data-vertical="^\n---\n$"></section>

Everything is stacked in one page, the vertical slides are not created … capture d cran 2014-05-29 15 40 43

Any idea ? Is it a bug or a config problem ?

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 16 (4 by maintainers)

Commits related to this issue

Most upvoted comments

This is a problem with the newline sign. Windows use \r\n and not \n. A quik fix for me was to add the following code in line 129 in the plugin file markdown.js

markdown = markdown.replace(/(\r\n|\r)/g, '\n');

The code then looks like this:

function slidify( markdown, options ) {

  options = getSlidifyOptions( options );

  markdown = markdown.replace(/(\r\n|\r)/g, '\n');

  var separatorRegex = new RegExp( options.separator + ( options.verticalSeparator ? '|' + options.verticalSeparator : '' ), 'mg' ),
  horizontalSeparatorRegex = new RegExp( options.separator );

...

Hope that helps to find a clean solution 😉

it’s not data-vertical but data-separator-vertical

Did this bug creep back into the latest version. I cannot get a vertical slide to work - in either the external or md file.

For external <section data-markdown="example.md" data-separator="^\n----\n" data-vertical="^\n---\n"> NOTE: I’ve also tried “^\r\n—\r\n” and ^\r\n—\r\n$" and “^\n—\n$”

And in this file…

###Title

----

####Title 2
* 1
* 2
* 3

This produces a seperate slide,

but this

###Title

---

####Title 2
* 1
* 2
* 3

Doesn’t produce a new vertical slide, but instead the following “stacked” (single slide)

capture

Oh, @ocombe’s test actually works just great for me after renaming data-vertical to data-separator-vertical (per changes from https://github.com/hakimel/reveal.js/commit/015468c3a2d1d4092f33920ac555a0e288e6213f, released in 3.0 on Jan 9, 2015).

I believe @rhhamburg correctly diagnosed the issue: if I switch my slides.md file between Unix and Windows line endings, it works (Unix) and fails (Windows).

Updating the regex to include an optional \r fixes it for me regardless of line endings: data-separator="^\r?\n----\r?\n$" data-separator-vertical="^\r?\n---\r?\n$"

Similarly, the following regex works with both line endings: data-separator="^----$" data-separator-vertical="^---$"