Skip to content

Commit e2cf596

Browse files
committed
Use span instead of a, remove unused code
1 parent 2eba27e commit e2cf596

File tree

1 file changed

+9
-21
lines changed

1 file changed

+9
-21
lines changed

scripts/md2html/md2html.js

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ complete control over formatting and syntax highlighting */
1111
const fs = require('fs');
1212
const path = require('path');
1313
const url = require('url');
14-
const util = require('util');
1514

1615
const hljs = require('highlight.js');
1716
const cheerio = require('cheerio');
@@ -196,7 +195,6 @@ let indents = [0];
196195
// process the markdown
197196
for (let l in lines) {
198197
let line = lines[l];
199-
let linkTarget;
200198

201199
if (line.startsWith('## Table of Contents')) inTOC = true;
202200
if (line.startsWith('<!-- /TOC')) inTOC = false;
@@ -238,20 +236,9 @@ for (let l in lines) {
238236
newIndent++;
239237
}
240238

241-
if (line.indexOf('<a name=')>=0) {
242-
let comp = line.split('</a>');
243-
let title = comp[1];
244-
if (inDefs) title = '<dfn>'+title+'</dfn>';
245-
let link = comp[0].split('<a ')[1].replace('name=','id=');
246-
const anchor = link.split("'").join('"').split('"')[1];
247-
line = '#'.repeat(newIndent)+' <span>'+title+'</span>';
248-
linkTarget = '<a id="'+anchor+'"></a>';
249-
}
250-
else {
251-
let title = line.split('# ')[1];
252-
if (inDefs) title = '<dfn>'+title+'</dfn>';
253-
line = ('#'.repeat(newIndent)+' '+title);
254-
}
239+
let title = line.split('# ')[1];
240+
if (inDefs) title = '<dfn>'+title+'</dfn>';
241+
line = ('#'.repeat(newIndent)+' '+title);
255242

256243
if (delta>0) indents.push(originalIndent);
257244
if (delta<0) {
@@ -267,10 +254,11 @@ for (let l in lines) {
267254
if (line.indexOf('<a name="')>=0) {
268255
if (line.indexOf('<a name="parameterAllowEmptyValue"/>')>=0)
269256
// fix syntax error in 2.0.md
270-
line = line.replace('<a name="parameterAllowEmptyValue"/>','<a id="parameterAllowEmptyValue"></a>');
271-
else
272-
line = line.replace('<a name=','<a id=');
273-
line = line.replace('"></a>','" class="logo"></a>');
257+
line = line.replace('<a name="parameterAllowEmptyValue"/>','<span id="parameterAllowEmptyValue"></span>');
258+
else {
259+
line = line.replace('<a name=','<span id=');
260+
line = line.replace('</a>','</span>');
261+
}
274262
}
275263

276264
line = line.split('\\|').join('&#124;'); // was &brvbar
@@ -347,7 +335,7 @@ for (let l in lines) {
347335
line = prefix+md.render(line);
348336
}
349337

350-
lines[l] = (linkTarget ? linkTarget : '') + line;
338+
lines[l] = line;
351339
}
352340

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

0 commit comments

Comments
 (0)