function prepareArticleTemplate()

in inflation-explorer/harness/update-harness.js [42:83]


function prepareArticleTemplate(html) {
  const dom = new jsdom.JSDOM(html)
  const document = dom.window.document

  removeUnwantedArticleElements(document)
  replaceArticleFurniture(document)
  insertIFrameElement(document)

  let serialized = dom.serialize()

   // this replacement needs to happen after serialization to prevent escaping
  serialized = serialized.replace("{{ title }}", "<%= title %>")
  serialized = serialized.replace("{{ headline }}", "<%= headline %>")
  serialized = serialized.replace("{{ standfirst }}", "<%= standfirst %>")

  serialized = serialized.replace("{{ iframe }}", `<iframe class="interactive-atom-fence" style="width:100%" srcdoc="
    <!DOCTYPE html>
    <html>
        <head>
            <meta charset=&quot;utf-8&quot;>
            <meta name=&quot;viewport&quot; content=&quot;width=device-width,minimum-scale=1,initial-scale=1&quot;>
            <script>
                var fonts=[].slice.apply(window.parent.document.styleSheets).filter(function(sheet){return sheet.ownerNode.className.indexOf(&quot;webfont&quot;)>-1}).map(function(sheet){return sheet.ownerNode.textContent}).join(&quot; &quot;);var css=document.createElement(&quot;style&quot;);css.textContent=fonts;document.head.appendChild(css);
            </script>
            <style>
                <%- css %>
            </style>
        </head>
        <body>
            <%- html %>
            <script>
                <%- js %>
            </script>
            <script>
                function resize(){window.frameElement.height=document.body.offsetHeight}window.addEventListener(&quot;resize&quot;,resize);resize();
            </script>
        </body>
    </html>
  "></iframe>`)

  return serialized
}