Clasp: Feature Request: Convert Markdown (*.md) Files to HTML on Push

Created on 24 Oct 2019  路  5Comments  路  Source: google/clasp

Google Apps Script allows you to easily create dialogs with HTML (.html). However, some things like READMEs and CHANGELOGs are easier and more likely to be maintained as Markdown (.md) files.

I'm imagining a workflow where I could write some Typescript like:

function showChangelog() {
    var html = HtmlService.createHtmlOutputFromFile('CHANGELOG')
        .setWidth(480)
        .setHeight(640);
    SlidesApp.getUi() // Or DocumentApp or SlidesApp or FormApp.
        .showModalDialog(html, "Storyboard");
}

and a file named CHANGELOG.md would be transformed into HTML with a style that matches the look of Google Slides/Docs.

# Changelog

# Version v1

* Initial Release
<html>
  <head>
    <link
      rel="stylesheet"
      href="https://ssl.gstatic.com/docs/script/css/add-ons1.css"
    />
    <style>
      .branding-below {
        bottom: 56px;
        top: 0;
      }
    </style>
  </head>
  <body>
    <h1 id="storyboardchangelogroadmap">Changelog</h1>
    <h2 id="versionv1">Version v1</h2>
    <ul>
      <li>Initial Release.</li>
    </ul>
  </body>
</html>
feature request good first issue help wanted

Most helpful comment

The pull issue isn't really an issue if you consider that .gs cannot be pulled-back into .ts either ;)

Next step is likely for the people interested to identify a solid markdown-to-html solution which includes sanitisation.

All 5 comments

This would be pretty cool, and not saying it shouldn't be done, but I'd also say you could do this with an off-the-shelf CLI interpreter ahead of a clasp push operation. Write your own local script to compile your HTML, copy it to the right places, and push your results up.

I think the tricky part is what format to use when converting the .md to .html. Not everyone would want it in a style that matches Google Slides/Docs.

What you could do (I do something similar) is have a .html file in your project that has your text in whatever format you want, like Mark Down, and a JavaScript function to "process" it before sending to HtmlService. That way, I can create as many .html files as I want and all will have a similar look and feel. And if I need to change the L&F I just need to update the JavaScript function/processor.

Also, it would get very tricky to "pull" the data back into an .md.

The pull issue isn't really an issue if you consider that .gs cannot be pulled-back into .ts either ;)

Next step is likely for the people interested to identify a solid markdown-to-html solution which includes sanitisation.

Unfortunately it's not clear still.

For an example why should I use https://ssl.gstatic.com/docs/script/css/add-ons1.css instead of something else?

showdown is pretty tools without a hardcode.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

smandava picture smandava  路  8Comments

OleksandrRakovets picture OleksandrRakovets  路  3Comments

freddy-daniel picture freddy-daniel  路  7Comments

dustinmichels picture dustinmichels  路  4Comments

tehhowch picture tehhowch  路  3Comments