reveal.js icon indicating copy to clipboard operation
reveal.js copied to clipboard

reveal.js markdown with react don't work

Open hms181231 opened this issue 6 years ago • 13 comments

qq20180430-193246 2x

hms181231 avatar Apr 30 '18 11:04 hms181231

Hello good afternoon

I'm having trouble integrating the library with React, can you help me please

Following is an example where we see that the slide is not showing

https://codesandbox.io/s/4rxkmr7k3x

mozgbrasil avatar Oct 31 '18 02:10 mozgbrasil

@mozgbrasil : Did you get any solution on your problem

achhranitesh avatar Jun 19 '20 07:06 achhranitesh

Thank you for trying

Gone321 avatar Jun 21 '20 08:06 Gone321

Hi did you get a solution to this issue? I am having the same issue and would like to know.

aditya-m-shah avatar Mar 05 '21 14:03 aditya-m-shah

Same issue

SumukhJadhav avatar Mar 08 '22 15:03 SumukhJadhav

Exact same issue.

noah79 avatar Mar 20 '22 02:03 noah79

Exact same issue.

starInEcust avatar Apr 28 '22 08:04 starInEcust

I'm having trouble integrating the library with React, can you help me please

Following is an example where we see that the slide is not showing

https://codesandbox.io/s/4rxkmr7k3x

The issue in this example is that the DOM element containing reveal.js doesn't have any height. This makes reveal.js try to scale content to fit within an impossibly small size leading to nothing being visible.

Here's a forked example that works. All I added was an inline height style: https://codesandbox.io/s/https-github-com-hakimel-reveal-js-issues-2267-forked-3mgi24?file=/src/index.js:374-437

Is this the issue everyone has run into? If it's a common problem we should find a way to address it in the framework.

hakimel avatar Apr 28 '22 08:04 hakimel

I am not sure if it is the same issue but the issue title is exactly about that.

Here you can find a minimal reproducible issue when trying to render slides using markdown in react.

https://stackblitz.com/edit/vitejs-vite-ckayd2?file=src%2FApp.jsx

It also happens locally. A <code> fragment is rendered with HTML from the index.html instead of the string to be parsed as markdown.

Thanks in advance

salvaft avatar Jun 12 '23 07:06 salvaft

I am not sure if it is the same issue but the issue title is exactly about that.

Here you can find a minimal reproducible issue when trying to render slides using markdown in react.

https://stackblitz.com/edit/vitejs-vite-ckayd2?file=src%2FApp.jsx

It also happens locally. A <code> fragment is rendered with HTML from the index.html instead of the string to be parsed as markdown.

Thanks in advance

@SFToro Hi! Did you get any solution on this problem? It seem just happen in react.

Michael-py001 avatar Sep 08 '23 10:09 Michael-py001

I am not sure if it is the same issue but the issue title is exactly about that. Here you can find a minimal reproducible issue when trying to render slides using markdown in react. https://stackblitz.com/edit/vitejs-vite-ckayd2?file=src%2FApp.jsx It also happens locally. A <code> fragment is rendered with HTML from the index.html instead of the string to be parsed as markdown. Thanks in advance

@SFToro Hi! Did you get any solution on this problem? It seem just happen in react.

@Michael-py001 I ended up using the external directive and using .md files.

Using vite i can "import" the md files.

// [...]
import performance from "../../md/performance.md";
import Md from "../../../src/components/markdown.jsx";
// [...]
 <section
      data-auto-animate-id={id}
      data-auto-animate={animate || null}
      data-auto-animate-restart={restart || null}
    >
<Md name={performance} external />
</section>

function markdown({ external, children, name }) {
  if (external) {
    return <section data-markdown={name} />;
  } else {
    return (
      <section data-markdown>
        <div data-template>{children}</div>
      </section>
    );
  }
}

export default markdown;

salvaft avatar Sep 12 '23 12:09 salvaft

Adding empty quotes as value on data-markdown attribute works here with React.

  <section data-markdown="">
    <script type="text/template">
      {`
        # Hello
        ---
        ## World
        `}
    </script>
  </section>

dmenezesgabriel avatar Dec 03 '23 23:12 dmenezesgabriel