test-markdown-element-attributes.html 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>reveal.js - Test Markdown Element Attributes</title>
  6. <link rel="stylesheet" href="../dist/reveal.css">
  7. <link rel="stylesheet" href="qunit-2.5.0.css">
  8. <script src="qunit-2.5.0.js"></script>
  9. </head>
  10. <body style="overflow: auto;">
  11. <div id="qunit"></div>
  12. <div id="qunit-fixture"></div>
  13. <div class="reveal" style="display: none;">
  14. <div class="slides">
  15. <!-- <section data-markdown="example.md" data-separator="^\n\n\n" data-separator-vertical="^\n\n"></section> -->
  16. <!-- Slides are separated by newline + three dashes + newline, vertical slides identical but two dashes -->
  17. <section data-markdown data-separator="^\n---\n$" data-separator-vertical="^\n--\n$" data-element-attributes="{_\s*?([^}]+?)}">>
  18. <script type="text/template">
  19. ## Slide 1.1
  20. <!-- {_class="fragment fade-out" data-fragment-index="1"} -->
  21. --
  22. ## Slide 1.2
  23. <!-- {_class="fragment shrink"} -->
  24. Paragraph 1
  25. <!-- {_class="fragment grow"} -->
  26. Paragraph 2
  27. <!-- {_class="fragment grow"} -->
  28. - list item 1 <!-- {_class="fragment grow"} -->
  29. - list item 2 <!-- {_class="fragment grow"} -->
  30. - list item 3 <!-- {_class="fragment grow"} -->
  31. ---
  32. ## Slide 2
  33. Paragraph 1.2
  34. multi-line <!-- {_class="fragment highlight-red"} -->
  35. Paragraph 2.2 <!-- {_class="fragment highlight-red"} -->
  36. Paragraph 2.3 <!-- {_class="fragment highlight-red"} -->
  37. Paragraph 2.4 <!-- {_class="fragment highlight-red"} -->
  38. - list item 1 <!-- {_class="fragment highlight-green"} -->
  39. - list item 2<!-- {_class="fragment highlight-green"} -->
  40. - list item 3<!-- {_class="fragment highlight-green"} -->
  41. - list item 4
  42. <!-- {_class="fragment highlight-green"} -->
  43. - list item 5<!-- {_class="fragment highlight-green"} -->
  44. Test
  45. ![Example Picture](examples/assets/image2.png) <!-- {_class="reveal stretch"} -->
  46. </script>
  47. </section>
  48. <section data-markdown data-separator="^\n\n\n"
  49. data-separator-vertical="^\n\n"
  50. data-separator-notes="^Note:"
  51. data-charset="utf-8">
  52. <script type="text/template">
  53. # Test attributes in Markdown with default separator
  54. ## Slide 1 Def <!-- .element: class="fragment highlight-red" data-fragment-index="1" -->
  55. ## Slide 2 Def
  56. <!-- .element: class="fragment highlight-red" -->
  57. </script>
  58. </section>
  59. <section data-markdown>
  60. <script type="text/template">
  61. ## Hello world
  62. A paragraph
  63. <!-- .element: class="fragment highlight-blue" -->
  64. </script>
  65. </section>
  66. <section data-markdown>
  67. <script type="text/template">
  68. ## Hello world
  69. Multiple
  70. Line
  71. <!-- .element: class="fragment highlight-blue" -->
  72. </script>
  73. </section>
  74. <section data-markdown>
  75. <script type="text/template">
  76. ## Hello world
  77. Test<!-- .element: class="fragment highlight-blue" -->
  78. More Test
  79. </script>
  80. </section>
  81. </div>
  82. </div>
  83. <script type="module">
  84. import '../js/index.js'
  85. import Markdown from '../plugin/markdown/markdown.js'
  86. Reveal.initialize({
  87. dependencies: [ Markdown ]
  88. }).then( function() {
  89. QUnit.module( 'Markdown' );
  90. QUnit.test( 'Vertical separator', function( assert ) {
  91. assert.strictEqual( document.querySelectorAll( '.reveal .slides>section>section' ).length, 4, 'found four slides' );
  92. });
  93. QUnit.test( 'Attributes on element header in vertical slides', function( assert ) {
  94. assert.strictEqual( document.querySelectorAll( '.reveal .slides section>section h2.fragment.fade-out' ).length, 1, 'found one vertical slide with class fragment.fade-out on header' );
  95. assert.strictEqual( document.querySelectorAll( '.reveal .slides section>section h2.fragment.shrink' ).length, 1, 'found one vertical slide with class fragment.shrink on header' );
  96. });
  97. QUnit.test( 'Attributes on element paragraphs in vertical slides', function( assert ) {
  98. assert.strictEqual( document.querySelectorAll( '.reveal .slides section>section p.fragment.grow' ).length, 2, 'found a vertical slide with two paragraphs with class fragment.grow' );
  99. });
  100. QUnit.test( 'Attributes on element list items in vertical slides', function( assert ) {
  101. assert.strictEqual( document.querySelectorAll( '.reveal .slides section>section li.fragment.grow' ).length, 3, 'found a vertical slide with three list items with class fragment.grow' );
  102. });
  103. QUnit.test( 'Attributes on element paragraphs in horizontal slides', function( assert ) {
  104. assert.strictEqual( document.querySelectorAll( '.reveal .slides section p.fragment.highlight-red' ).length, 4, 'found a horizontal slide with four paragraphs with class fragment.grow' );
  105. });
  106. QUnit.test( 'Attributes on element list items in horizontal slides', function( assert ) {
  107. assert.strictEqual( document.querySelectorAll( '.reveal .slides section li.fragment.highlight-green' ).length, 5, 'found a horizontal slide with five list items with class fragment.roll-in' );
  108. });
  109. QUnit.test( 'Attributes on element image in horizontal slides', function( assert ) {
  110. assert.strictEqual( document.querySelectorAll( '.reveal .slides section img.reveal.stretch' ).length, 1, 'found a horizontal slide with stretched image, class img.reveal.stretch' );
  111. });
  112. QUnit.test( 'Attributes on elements in vertical slides with default element attribute separator', function( assert ) {
  113. assert.strictEqual( document.querySelectorAll( '.reveal .slides section h2.fragment.highlight-red' ).length, 2, 'found two h2 titles with fragment highlight-red in vertical slides with default element attribute separator' );
  114. });
  115. QUnit.test( 'Attributes on elements in single slides with default element attribute separator', function( assert ) {
  116. assert.strictEqual( document.querySelectorAll( '.reveal .slides section p.fragment.highlight-blue' ).length, 3, 'found three elements with fragment highlight-blue in single slide with default element attribute separator' );
  117. });
  118. } );
  119. </script>
  120. </body>
  121. </html>