Skip to content

Repair Google Tag Manager #4403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions scripts/md2html/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,16 @@ for specification in $specifications; do

minorVersion=${version:0:3}
tempfile="$deploydir/temp/$version.html"
tempfile2="$deploydir/temp/$version-2.html"

echo === Building $version to $destination

node scripts/md2html/md2html.js --maintainers $maintainers $specification "$allVersions" > $tempfile
npx respec --no-sandbox --use-local --src $tempfile --out $destination
rm $tempfile
npx respec --no-sandbox --use-local --src $tempfile --out $tempfile2
# remove unwanted Google Tag Manager and Google Analytics scripts
sed -e 's/<script type="text\/javascript" async="" src="https:\/\/www.google-analytics.com\/analytics.js"><\/script>//' \
-e 's/<script type="text\/javascript" async="" src="https:\/\/www.googletagmanager.com\/gtag\/js?id=G-[^"]*"><\/script>//' \
$tempfile2 > $destination

echo === Built $destination

Expand All @@ -79,6 +83,5 @@ if [ "$latestCopied" != "none" ]; then
echo Latest tag is $latest, copied $latestCopied to latest.html
fi

rm $deploydir/js/respec-w3c.*
rmdir $deploydir/js
rmdir $deploydir/temp
rm -r $deploydir/js
rm -r $deploydir/temp
11 changes: 6 additions & 5 deletions scripts/md2html/md2html.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,18 @@ function preface(title,options) {
// }
};

let preface = `<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>${md.utils.escapeHtml(title)}</title>`;
let preface = '<!DOCTYPE html><html lang="en"><head>\n'
preface += fs.readFileSync(path.resolve(__dirname,'./analytics/google.html'),'utf8');

// SEO
preface += '<meta name="description" content="The OpenAPI Specification (OAS) defines a standard, programming language-agnostic interface description for HTTP APIs.">';
preface += `<meta charset="UTF-8">\n<title>${md.utils.escapeHtml(title)}</title>`;
preface += '<meta name="description" content="The OpenAPI Specification (OAS) defines a standard, programming language-agnostic interface description for HTTP APIs.">\n';

// ReSpec
preface += '<meta name="color-scheme" content="light dark">';
preface += '<script src="../js/respec-w3c.js" class="remove"></script>';
preface += `<script class="remove">var respecConfig = ${JSON.stringify(respec)};</script>`;
preface += fs.readFileSync(path.resolve(__dirname,'./analytics/google.html'),'utf8');
preface += '</head><body>';
preface += `<script class="remove">var respecConfig = ${JSON.stringify(respec)};</script>\n`;
preface += '</head>\n<body>';
preface += '<style>';
preface += fs.readFileSync(path.resolve(__dirname,'main.css'),'utf8').split(/\r?\n/).join(' ');
preface += fs.readFileSync(path.resolve(__dirname,'gist.css'),'utf8').split(/\r?\n/).join(' ');
Expand Down
Loading