Git Product home page Git Product logo

Comments (2)

tkareine avatar tkareine commented on August 19, 2024 1

When HTSD installs slides, it wraps elements inside the <body> tag into <div>s. The <hr> tag marks the beginning of the next slide. This behavior is designed for html files generated from Markdown files in mind.

I don't know how you've generated or written the html file in which you want to install HTSD, but maybe creating html elements dynamically is an option for you. If so, then you can proceed as follows:

  1. Add a template tag somewhere in the html document
  2. Embed the HTSD script into the document with the data-manual attribute (this prevents the automatic installation of slides)
  3. Add a script that installs HTSD slides manually and inserts new elements into the document based on the contents of the template

For example, you can append the following in the end of a Markdown document:

<script type="text/javascript" src="htsd.min.js" data-manual></script>
<script type="text/template" id="my-template">
  <div>hidden content</div>
</script>
<script type="text/javascript">
  window.htsd.installAll()
  const templateStr = document.getElementById("my-template").innerText.trim()
  const templateNode = document.createElement("template")
  templateNode.innerHTML = templateStr
  document.querySelector("body").appendChild(templateNode.content.firstChild)
</script>

Once you load that, you should see that <div>hidden content</div> is the last child element of <body>.

Also, you can replace <script type="text/template" id="my-template"> with <template id="my-template">, giving you a document fragment ready to be used. That would allow omitting the document.createElement("template") call in step 3. Unfortunately, the marked Markdown compiler wraps a <template> tag within a <p> tag.

from hackers-tiny-slide-deck.

soelen avatar soelen commented on August 19, 2024

Thank you for the quick and helpful response tkareine

from hackers-tiny-slide-deck.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.