Skip to content
Merged
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
12 changes: 9 additions & 3 deletions scripts/md2html/md2html.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ function preface(title,options) {
if (options.respec) {
preface += '<script src="../js/respec-oai.js" class="remove"></script>';
preface += `<script class="remove">var respecConfig = ${JSON.stringify(respec)};</script>`;
preface += fs.readFileSync('./analytics/google.html','utf8');
try {
preface += fs.readFileSync('./analytics/google.html','utf8');
}
catch (ex) {}
preface += '</head><body>';
preface += '<style>';
preface += '#respec-ui { visibility: hidden; }';
Expand Down Expand Up @@ -167,6 +170,7 @@ let indents = [0];
// process the markdown
for (let l in lines) {
let line = lines[l];
let linkTarget;

if (line.startsWith('## Table of Contents')) inTOC = true;
if (line.startsWith('<!-- /TOC')) inTOC = false;
Expand Down Expand Up @@ -213,7 +217,9 @@ for (let l in lines) {
let title = comp[1];
if (inDefs) title = '<dfn>'+title+'</dfn>';
let link = comp[0].split('<a ')[1].replace('name=','id=');
line = ('#'.repeat(newIndent)+' <span '+link+title+'</span>');
const anchor = link.split("'").join('"').split('"')[1];
line = '#'.repeat(newIndent)+' <span>'+title+'</span>';
linkTarget = '<a id="'+anchor+'"></a>';
}
else {
let title = line.split('# ')[1];
Expand Down Expand Up @@ -303,7 +309,7 @@ for (let l in lines) {
line = prefix+md.render(line);
}

lines[l] = line;
lines[l] = (linkTarget ? linkTarget : '') + line;
}

s = preface(`OpenAPI Specification v${argv.subtitle} | Introduction, Definitions, & More`,argv)+'\n\n'+lines.join('\n');
Expand Down