chore(doc-gen): trim leading blank lines from markdown content
Harp 0.17 does not allow blank lines to appear between filters and their content. This change ensures that any blank lines that could appear have been trimmed inside Nunkjucks. Closes #3325
This commit is contained in:
parent
6ab2a871ce
commit
d426af741c
|
@ -54,4 +54,11 @@ module.exports = new Package('angular.io', [basePackage])
|
|||
|
||||
.config(function(getLinkInfo) {
|
||||
getLinkInfo.relativeLinks = true;
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
.config(function(templateEngine, getInjectables) {
|
||||
templateEngine.filters = templateEngine.filters.concat(getInjectables([require('./rendering/trimBlankLines')]));
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
module.exports = function(encodeCodeBlock) {
|
||||
return {
|
||||
name: 'trimBlankLines',
|
||||
process: function(str) {
|
||||
var lines = str.split(/\r?\n/);
|
||||
while(lines[0] === '') {
|
||||
lines.shift();
|
||||
}
|
||||
return lines.join('\n');
|
||||
}
|
||||
};
|
||||
};
|
|
@ -8,7 +8,7 @@ p.location-badge.
|
|||
defined in {$ githubViewLink(doc) $}
|
||||
|
||||
:markdown
|
||||
{$ doc.description | indent(2, true) $}
|
||||
{$ doc.description | indent(2, true) | trimBlankLines $}
|
||||
|
||||
{%- if doc.decorators %}
|
||||
.l-main-section
|
||||
|
@ -37,7 +37,7 @@ p.location-badge.
|
|||
{$ doc.constructorDoc.name $}{$ paramList(doc.constructorDoc.parameters) | indent(4, true) | trim $}
|
||||
{% endif %}
|
||||
:markdown
|
||||
{$ doc.constructorDoc.description | indent(6, true) | replace('## Example', '') | replace('# Example', '') $}
|
||||
{$ doc.constructorDoc.description | indent(6, true) | replace('## Example', '') | replace('# Example', '') | trimBlankLines $}
|
||||
|
||||
|
||||
{% endif -%}
|
||||
|
@ -52,8 +52,7 @@ p.location-badge.
|
|||
{$ member.name $}{$ paramList(member.parameters) | indent(4, true) | trim $}{$ returnType(doc.returnType) $}
|
||||
{% endif %}
|
||||
:markdown
|
||||
|
||||
{$ member.description | indent(6, true) | replace('## Example', '') | replace('# Example', '') $}
|
||||
{$ member.description | indent(6, true) | replace('## Example', '') | replace('# Example', '') | trimBlankLines $}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -17,6 +17,6 @@
|
|||
defined in {$ githubViewLink(doc) $}
|
||||
|
||||
:markdown
|
||||
{$ doc.description | indent(4, true) $}
|
||||
{$ doc.description | indent(4, true) | trimBlankLines $}
|
||||
|
||||
{% endblock %}
|
|
@ -9,5 +9,5 @@
|
|||
defined in {$ githubViewLink(doc) $}
|
||||
|
||||
:markdown
|
||||
{$ doc.description | indent(4, true) $}
|
||||
{$ doc.description | indent(4, true) | trimBlankLines $}
|
||||
{% endblock %}
|
Loading…
Reference in New Issue