add support for '//===' for <h3>s in bs-lessdoc
This commit is contained in:
parent
39861714a8
commit
db829f8620
|
@ -726,9 +726,7 @@
|
||||||
</div>
|
</div>
|
||||||
<h2 id="navs">Navs</h2>
|
<h2 id="navs">Navs</h2>
|
||||||
<p></p>
|
<p></p>
|
||||||
<div class="row">
|
<h3 id="shared-nav-styles">Shared nav styles</h3>
|
||||||
</div>
|
|
||||||
<h2 id="shared-nav-styles">Shared nav styles</h2>
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="bs-customizer-input">
|
<div class="bs-customizer-input">
|
||||||
<label for="input-@nav-link-padding">@nav-link-padding</label>
|
<label for="input-@nav-link-padding">@nav-link-padding</label>
|
||||||
|
|
|
@ -4,8 +4,11 @@ each section in sections
|
||||||
h2(id=section.id)= section.heading
|
h2(id=section.id)= section.heading
|
||||||
if section.docstring
|
if section.docstring
|
||||||
p!= section.docstring.html
|
p!= section.docstring.html
|
||||||
|
each subsection in section.subsections
|
||||||
|
if subsection.heading
|
||||||
|
h3(id=subsection.id)= subsection.heading
|
||||||
div.row
|
div.row
|
||||||
each variable in section.variables
|
each variable in subsection.variables
|
||||||
div.bs-customizer-input
|
div.bs-customizer-input
|
||||||
label(for="input-" + variable.name)= variable.name
|
label(for="input-" + variable.name)= variable.name
|
||||||
input.form-control(
|
input.form-control(
|
||||||
|
|
|
@ -24,6 +24,7 @@ Mini-language:
|
||||||
|
|
||||||
var CUSTOMIZABLE_HEADING = /^[/]{2}={2}(.*)$/;
|
var CUSTOMIZABLE_HEADING = /^[/]{2}={2}(.*)$/;
|
||||||
var UNCUSTOMIZABLE_HEADING = /^[/]{2}-{2}(.*)$/;
|
var UNCUSTOMIZABLE_HEADING = /^[/]{2}-{2}(.*)$/;
|
||||||
|
var SUBSECTION_HEADING = /^[/]{2}={3}(.*)$/;
|
||||||
var SECTION_DOCSTRING = /^[/]{2}#{2}(.*)$/;
|
var SECTION_DOCSTRING = /^[/]{2}#{2}(.*)$/;
|
||||||
var VAR_ASSIGNMENT = /^(@[a-zA-Z0-9_-]+):[ ]*([^ ;][^;]+);[ ]*$/;
|
var VAR_ASSIGNMENT = /^(@[a-zA-Z0-9_-]+):[ ]*([^ ;][^;]+);[ ]*$/;
|
||||||
var VAR_DOCSTRING = /^[/]{2}[*]{2}(.*)$/;
|
var VAR_DOCSTRING = /^[/]{2}[*]{2}(.*)$/;
|
||||||
|
@ -33,12 +34,23 @@ function Section(heading, customizable) {
|
||||||
this.id = this.heading.replace(/\s+/g, '-').toLowerCase();
|
this.id = this.heading.replace(/\s+/g, '-').toLowerCase();
|
||||||
this.customizable = customizable;
|
this.customizable = customizable;
|
||||||
this.docstring = null;
|
this.docstring = null;
|
||||||
this.variables = [];
|
this.subsections = [];
|
||||||
this.addVar = function (variable) {
|
|
||||||
this.variables.push(variable);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Section.prototype.addSubSection = function (subsection) {
|
||||||
|
this.subsections.push(subsection);
|
||||||
|
}
|
||||||
|
|
||||||
|
function SubSection(heading) {
|
||||||
|
this.heading = heading.trim();
|
||||||
|
this.id = this.heading.replace(/\s+/g, '-').toLowerCase();
|
||||||
|
this.variables = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
SubSection.prototype.addVar = function (variable) {
|
||||||
|
this.variables.push(variable);
|
||||||
|
};
|
||||||
|
|
||||||
function VarDocstring(markdownString) {
|
function VarDocstring(markdownString) {
|
||||||
this.html = markdown2html(markdownString);
|
this.html = markdown2html(markdownString);
|
||||||
}
|
}
|
||||||
|
@ -78,6 +90,10 @@ Tokenizer.prototype._shift = function () {
|
||||||
}
|
}
|
||||||
var line = this._lines.shift();
|
var line = this._lines.shift();
|
||||||
var match = null;
|
var match = null;
|
||||||
|
match = SUBSECTION_HEADING.exec(line);
|
||||||
|
if (match !== null) {
|
||||||
|
return new SubSection(match[1]);
|
||||||
|
}
|
||||||
match = CUSTOMIZABLE_HEADING.exec(line);
|
match = CUSTOMIZABLE_HEADING.exec(line);
|
||||||
if (match !== null) {
|
if (match !== null) {
|
||||||
return new Section(match[1], true);
|
return new Section(match[1], true);
|
||||||
|
@ -146,17 +162,50 @@ Parser.prototype.parseSection = function () {
|
||||||
else {
|
else {
|
||||||
this._tokenizer.unshift(docstring);
|
this._tokenizer.unshift(docstring);
|
||||||
}
|
}
|
||||||
this.parseVars(section);
|
this.parseSubSections(section);
|
||||||
|
|
||||||
return section;
|
return section;
|
||||||
};
|
};
|
||||||
|
|
||||||
Parser.prototype.parseVars = function (section) {
|
Parser.prototype.parseSubSections = function (section) {
|
||||||
|
while (true) {
|
||||||
|
var subsection = this.parseSubSection();
|
||||||
|
if (subsection === null) {
|
||||||
|
if (section.subsections.length === 0) {
|
||||||
|
// Presume an implicit initial subsection
|
||||||
|
subsection = new SubSection('');
|
||||||
|
this.parseVars(subsection);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
section.addSubSection(subsection);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (section.subsections.length === 1 && !(section.subsections[0].heading) && section.subsections[0].variables.length === 0) {
|
||||||
|
// Ignore lone empty implicit subsection
|
||||||
|
section.subsections = [];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Parser.prototype.parseSubSection = function () {
|
||||||
|
var subsection = this._tokenizer.shift();
|
||||||
|
if (subsection instanceof SubSection) {
|
||||||
|
this.parseVars(subsection);
|
||||||
|
return subsection;
|
||||||
|
}
|
||||||
|
this._tokenizer.unshift(subsection);
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
Parser.prototype.parseVars = function (subsection) {
|
||||||
while (true) {
|
while (true) {
|
||||||
var variable = this.parseVar();
|
var variable = this.parseVar();
|
||||||
if (variable === null) {
|
if (variable === null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
section.addVar(variable);
|
subsection.addVar(variable);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -366,7 +366,7 @@
|
||||||
//
|
//
|
||||||
//##
|
//##
|
||||||
|
|
||||||
//== Shared nav styles
|
//=== Shared nav styles
|
||||||
@nav-link-padding: 10px 15px;
|
@nav-link-padding: 10px 15px;
|
||||||
@nav-link-hover-bg: @gray-lighter;
|
@nav-link-hover-bg: @gray-lighter;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue