Sandcastle breaks javascript added by post-build event (Google Analytics)
I'm using the VS2019 plugin to generate HTML help files (VS2013 format) - SHFB version 2019.11.17.0 (installed today). I have a post-build event which runs a c# console app to add the following Google Analytics code into the page header, immediately after the head tag:
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-144630267-1"></script>
<script>window.dataLayer = window.dataLayer || []; function gtag() { dataLayer.push(arguments); } gtag('js', new Date());gtag('config', 'UA-144630267-1');</script>
However after this is done this script gets reformatted as:
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-144630267-1"></script>
< script >
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'UA-144630267-1');
</ script >
The spaces in the < script > tags cause it to break, instead displaying the broken script at the top of the page.
Since it's post-build it's not something SHFB or the build process is breaking since it's done at that point and doesn't modify the files after that. Regardless, you should be able to remove the post-build step and put the script in the Website Ad Content property as that's its purpose.