问题
Is there any way to pretty print html output from Jekyll?
For example, below is a snippet of html that Jekyll generates. Notice how the <p>
tags have no indentation and have unnecessary line breaks after them.
...
<div id="content">
<p class="flush">Post 1</p>
<p class="flush">Post 2</p>
<p class="flush">Post 3</p>
</div>
...
I'm imagining an option or plugin that would pretty print like this instead:
...
<div id="content">
<p class="flush">Post 1</p>
<p class="flush">Post 2</p>
<p class="flush">Post 3</p>
</div>
...
回答1:
I would suggest you to choose one of tidy-makers and write your own :tidy
task in the end of jekyll-specific task chain. Or, even easier:
desc "Tidy jekyll output"
task :tidy do
`find _site -name "*.html" -exec tidy {} \;`
end
Please note, that neither your newly created task nor any plugin that probably may be found over the internet will not be applied on github pages, since they have restricted policies to run jekyll.
来源:https://stackoverflow.com/questions/14791373/pretty-print-html-output-from-jekyll