Skip to content

Commit

Permalink
Better prettyPrinting of compiled HTML <a> tags.
Browse files Browse the repository at this point in the history
  • Loading branch information
jgerigmeyer committed Dec 14, 2017
1 parent d0e982d commit 72399e7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Herman Changelog


## Unreleased

- CHANGE: Use `installJinjaCompat` for default Nunjucks environment.
- BUGFIX: Fix prettyPrint for compiled HTML/Nunjucks.


## 1.0.0-rc.7: 2017-12-12

- NEW: Support SassDoc [`googleAnalytics`][googleAnalytics] and
Expand Down
5 changes: 5 additions & 0 deletions docs/CHANGELOG.html
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,11 @@ <h3 data-sassdoc="nav-title">

<div class="text-block">
<h1 id="herman-changelog">Herman Changelog</h1>
<h2 id="unreleased">Unreleased</h2>
<ul>
<li>CHANGE: Use <code>installJinjaCompat</code> for default Nunjucks<span class="widont">&nbsp;</span>environment.</li>
<li>BUGFIX: Fix prettyPrint for compiled<span class="widont">&nbsp;</span>HTML/Nunjucks.</li>
</ul>
<h2 id="1-0-0-rc-7-2017-12-12">1.0.0-rc.7: 2017-12-12</h2>
<ul>
<li>NEW: Support SassDoc <a href="http://sassdoc.com/customising-the-view/#google-analytics"><code>googleAnalytics</code></a> and
Expand Down
8 changes: 6 additions & 2 deletions lib/annotations/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const beautify = require('html').prettyPrint;
const path = require('path');
const Promise = require('bluebird');
const sass = require('node-sass');
const stripIndent = require('strip-indent');

const getNunjucksEnv = require('../utils/getNunjucksEnv');
const renderIframe = require('../renderIframe');
Expand Down Expand Up @@ -40,7 +41,10 @@ module.exports = env => {
}
item.example.forEach(exampleItem => {
if (exampleItem.type === 'html') {
exampleItem.rendered = beautify(exampleItem.code, beautifyOpts);
exampleItem.rendered = beautify(
stripIndent(exampleItem.code),
beautifyOpts
);
} else if (exampleItem.type === 'njk') {
if (!customNjkEnv) {
customNjkEnv = getNunjucksEnv('Nunjucks @example', env, warned);
Expand All @@ -50,7 +54,7 @@ module.exports = env => {
return;
}
exampleItem.rendered = beautify(
customNjkEnv.renderString(exampleItem.code),
stripIndent(customNjkEnv.renderString(exampleItem.code)),
beautifyOpts
).trim();
} else if (exampleItem.type === 'scss') {
Expand Down
1 change: 1 addition & 0 deletions lib/utils/getNunjucksEnv.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ module.exports = (name, env, warned) => {
}
return null;
}
nunjucks.installJinjaCompat();
return nunjucks.configure(env.herman.nunjucks.templatepath);
};

0 comments on commit 72399e7

Please sign in to comment.