hashobject / perun

Programmable static site generator built with Clojure and Boot (HELP NEEDED!)
https://perun.io
Eclipse Public License 1.0
351 stars 38 forks source link

How do I add html to my markdown files? #213

Closed NightMachinery closed 5 years ago

NightMachinery commented 6 years ago

I want something like this:

# HTML follows

<div id="app"></div>
    <canvas id="hello-quil"></canvas>
    <script src="js/compiled/withering_spell.js" type="text/javascript"></script>
    <script type="text/javascript">withering_spell.system.go();</script>
    <script type="text/javascript">withering_spell.quilcore.run_sketch()</script>

This should be fairly easy, so? At worst add a new tag like <html-follow> and just put its content directly into the generated final HTML.

vsch commented 6 years ago

@NightMachinary, If I remember right, pegdown generates only the HTML body content not the rest of the document tags. I no longer have the pegdown project on my system to check.

However, nothing stops you from manipulating the HTML string you get from pegdown rendering to wrap it with your desired HTML or insert the rendered HTML into your document container.

As a worst case scenario if it does generate additional tags, including <body> and </body> tags you can easily add HTML before/after the body tag with pegdownHtml.replace("<body>", "your Html Before <body> your HTML after").replace("</body>", " your HTML before /body </body>")

A bit of a kludge but it will get the job done.

Or you can simplify it by stripping off any of the standard tags it adds like <body> and </body> wrappers to get the bare body HTML content to wrap as you please with your own HTML.

bhagany commented 6 years ago

You can use Perun's render task to do this - your render function can just concatenate some html strings together.

allentiak commented 5 years ago

Seems solved. I will close it.