Pretty print html output from Jekyll

扶醉桌前 提交于 2019-12-13 17:12:01

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!