Skip to content
Snippets Groups Projects
Unverified Commit e03735ad authored by fauno's avatar fauno
Browse files

pass flags according to site lang

parent 73f7e504
Branches
Tags
No related merge requests found
...@@ -50,7 +50,10 @@ pandoc: ...@@ -50,7 +50,10 @@ pandoc:
latex: latex:
pdf: '--latex-engine=xelatex' pdf: '--latex-engine=xelatex'
epub: '--epub-chapter-level=2' epub: '--epub-chapter-level=2'
lang:
ar:
all: '-V mainfont="Amiri"'
pdf: '--include-in-header=_layouts/rtl.tex'
``` ```
* `markdown: pandoc` will instruct jekyll to use the pandoc html * `markdown: pandoc` will instruct jekyll to use the pandoc html
...@@ -93,6 +96,11 @@ regular jekyll site build. ...@@ -93,6 +96,11 @@ regular jekyll site build.
* `full_file` generates a single file containing all articles, sectioned * `full_file` generates a single file containing all articles, sectioned
by their main category (the first one defined if many). by their main category (the first one defined if many).
* `lang` is a hash where you can define per-language flags. If you have
a `lang` attribute in your site config, this plugin will add the
`-V lang=XX` flag and any language-specific flag you want. You can
define language flags for `all` formats or for specific formats.
**IMPORTANT**: As of version 0.1.0 the syntax of the config changed. **IMPORTANT**: As of version 0.1.0 the syntax of the config changed.
Please upgrade your `_config.yml` accordingly. Please upgrade your `_config.yml` accordingly.
......
...@@ -45,11 +45,16 @@ module JekyllPandocMultipleFormats ...@@ -45,11 +45,16 @@ module JekyllPandocMultipleFormats
base.class_eval do base.class_eval do
# Just return html5 # Just return html5
def convert(content) def convert(content)
flags = "#{@config['pandoc']['flags']} #{@config['pandoc']['site_flags']}" lang = @config.dig('lang')
flags = []
flags << @config.dig('pandoc', 'flags')
flags << @config.dig('pandoc', 'site_flags')
flags << @config.dig('pandoc', 'lang', lang, 'all')
output = '' output = ''
Dir::chdir(@config['source']) do Dir::chdir(@config['source']) do
Open3::popen3("pandoc -t html5 #{flags}") do |stdin, stdout, stderr, thread| cmd = "pandoc -t html5 #{flags.compact.join(' ')}"
Open3::popen3(cmd) do |stdin, stdout, stderr, thread|
stdin.puts content stdin.puts content
stdin.close stdin.close
......
# Copyright (c) 2012-2015 Nicolás Reynolds <fauno@endefensadelsl.org> # Copyright (c) 2012-2018 Nicolás Reynolds <fauno@endefensadelsl.org>
# 2012-2013 Mauricio Pasquier Juan <mpj@endefensadelsl.org> # 2012-2013 Mauricio Pasquier Juan <mpj@endefensadelsl.org>
# 2013 Brian Candler <b.candler@pobox.com> # 2013 Brian Candler <b.candler@pobox.com>
# #
...@@ -253,13 +253,27 @@ module Jekyll ...@@ -253,13 +253,27 @@ module Jekyll
@flags << @config['full_flags'] @flags << @config['full_flags']
end end
@flags.join ' ' if site_lang?
@flags << "-V lang=#{site_lang}"
@flags << @config.dig('lang', site_lang, 'all')
@flags << @config.dig('lang', site_lang, @format)
end
@flags.compact.join ' '
end end
def command def command
'pandoc ' << flags 'pandoc ' << flags
end end
def site_lang
@site.config.dig('lang')
end
def site_lang?
!site_lang.nil?
end
def full? def full?
@extra[:full] @extra[:full]
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment