1
0
mirror of https://github.com/gryf/jekyll-rst.git synced 2025-12-19 04:20:21 +01:00

Added configurable headings level

Currently, there was no way for changing level of the heading, from
which html would be generated. In this patch, there is added an ability
to define it in jekyll _config.yml file for site.

It's simple as adding following entries into _config.yml:

rst:
  initial_header_level: 2

If not defined, level 2 will be used as default.
This commit is contained in:
2019-05-04 11:23:58 -06:00
parent 65a7c70ee5
commit 11e2d51499

View File

@@ -18,7 +18,17 @@ module Jekyll
def convert(content) def convert(content)
dirname = "#{File.expand_path(File.dirname(__FILE__))}" dirname = "#{File.expand_path(File.dirname(__FILE__))}"
RbST.executables = {:html => dirname + "/rst2html5.py"} RbST.executables = {:html => dirname + "/rst2html5.py"}
rst2htmlcontent = RbST.new(content).to_html(:initial_header_level => 2) level = 2
conf = Jekyll.configuration({})
if conf.has_key?('rst')
level = conf['rst']['initial_header_level']
if not level.is_a?(Integer)
level = 2
end
end
rst2htmlcontent = RbST.new(content).to_html(:initial_header_level => level)
document = Nokogiri::HTML(rst2htmlcontent) document = Nokogiri::HTML(rst2htmlcontent)
content = document.css('body').inner_html content = document.css('body').inner_html
end end