paru 0.2.4.2 → 0.2.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/lib/paru.rb +8 -20
  3. data/lib/paru/error.rb +4 -6
  4. data/lib/paru/filter.rb +144 -110
  5. data/lib/paru/filter/ast_manipulation.rb +75 -39
  6. data/lib/paru/filter/attr.rb +72 -36
  7. data/lib/paru/filter/block.rb +14 -8
  8. data/lib/paru/filter/block_quote.rb +12 -9
  9. data/lib/paru/filter/bullet_list.rb +6 -6
  10. data/lib/paru/filter/citation.rb +51 -25
  11. data/lib/paru/filter/cite.rb +29 -20
  12. data/lib/paru/filter/code.rb +41 -24
  13. data/lib/paru/filter/code_block.rb +36 -21
  14. data/lib/paru/filter/definition_list.rb +19 -15
  15. data/lib/paru/filter/definition_list_item.rb +30 -17
  16. data/lib/paru/filter/div.rb +29 -21
  17. data/lib/paru/filter/document.rb +73 -46
  18. data/lib/paru/filter/emph.rb +6 -6
  19. data/lib/paru/filter/empty_block.rb +17 -13
  20. data/lib/paru/filter/empty_inline.rb +24 -17
  21. data/lib/paru/filter/header.rb +38 -23
  22. data/lib/paru/filter/image.rb +13 -11
  23. data/lib/paru/filter/inline.rb +21 -10
  24. data/lib/paru/filter/line_block.rb +6 -6
  25. data/lib/paru/filter/line_break.rb +6 -6
  26. data/lib/paru/filter/link.rb +33 -21
  27. data/lib/paru/filter/list.rb +26 -17
  28. data/lib/paru/filter/list_attributes.rb +53 -32
  29. data/lib/paru/filter/markdown.rb +102 -59
  30. data/lib/paru/filter/math.rb +65 -38
  31. data/lib/paru/filter/meta.rb +26 -16
  32. data/lib/paru/filter/meta_blocks.rb +12 -9
  33. data/lib/paru/filter/meta_bool.rb +6 -6
  34. data/lib/paru/filter/meta_inlines.rb +12 -9
  35. data/lib/paru/filter/meta_list.rb +6 -6
  36. data/lib/paru/filter/meta_map.rb +49 -33
  37. data/lib/paru/filter/meta_string.rb +6 -6
  38. data/lib/paru/filter/meta_value.rb +22 -14
  39. data/lib/paru/filter/node.rb +204 -129
  40. data/lib/paru/filter/note.rb +31 -20
  41. data/lib/paru/filter/null.rb +6 -6
  42. data/lib/paru/filter/ordered_list.rb +34 -18
  43. data/lib/paru/filter/para.rb +20 -13
  44. data/lib/paru/filter/plain.rb +21 -12
  45. data/lib/paru/filter/quoted.rb +27 -18
  46. data/lib/paru/filter/raw_block.rb +32 -19
  47. data/lib/paru/filter/raw_inline.rb +40 -22
  48. data/lib/paru/filter/small_caps.rb +7 -6
  49. data/lib/paru/filter/soft_break.rb +6 -6
  50. data/lib/paru/filter/space.rb +6 -6
  51. data/lib/paru/filter/span.rb +28 -18
  52. data/lib/paru/filter/str.rb +29 -18
  53. data/lib/paru/filter/strikeout.rb +6 -6
  54. data/lib/paru/filter/strong.rb +6 -6
  55. data/lib/paru/filter/subscript.rb +6 -6
  56. data/lib/paru/filter/superscript.rb +6 -6
  57. data/lib/paru/filter/table.rb +51 -29
  58. data/lib/paru/filter/table_row.rb +21 -14
  59. data/lib/paru/filter/target.rb +29 -15
  60. data/lib/paru/filter/version.rb +23 -14
  61. data/lib/paru/pandoc.rb +165 -111
  62. data/lib/paru/pandoc_options.yaml +3 -3
  63. data/lib/paru/selector.rb +176 -153
  64. metadata +2 -3
  65. data/lib/paru/filter/alignment.rb +0 -30
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright 2015, 2016 Huub de Beer <Huub@heerdebeer.org>
2
+ # Copyright 2015, 2016, 2017 Huub de Beer <Huub@heerdebeer.org>
3
3
  #
4
4
  # This file is part of Paru
5
5
  #
@@ -17,26 +17,37 @@
17
17
  # along with Paru. If not, see <http://www.gnu.org/licenses/>.
18
18
  #++
19
19
  module Paru
20
- module PandocFilter
21
- require_relative "./inline"
20
+ module PandocFilter
21
+ require_relative "./inline"
22
22
 
23
- # Str String
24
- class Str < Inline
25
- def initialize value
26
- @string = value
27
- end
23
+ # A Str node represents a string
24
+ class Str < Inline
28
25
 
29
- def ast_contents
30
- @string
31
- end
26
+ # Create a new Str node based on the value
27
+ #
28
+ # @param value [String]
29
+ def initialize(value)
30
+ @string = value
31
+ end
32
32
 
33
- def has_string?
34
- true
35
- end
33
+ # The AST contents
34
+ def ast_contents()
35
+ @string
36
+ end
36
37
 
37
- def has_inline?
38
- false
39
- end
38
+ # Has the Str node a string value? Of course!
39
+ #
40
+ # @return [Boolean] true
41
+ def has_string?()
42
+ true
43
+ end
44
+
45
+ # Has the Str node inline contents?
46
+ #
47
+ # @return [Boolean] false
48
+ def has_inline?()
49
+ false
50
+ end
51
+ end
40
52
  end
41
- end
42
53
  end
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright 2015, 2016 Huub de Beer <Huub@heerdebeer.org>
2
+ # Copyright 2015, 2016, 2017 Huub de Beer <Huub@heerdebeer.org>
3
3
  #
4
4
  # This file is part of Paru
5
5
  #
@@ -17,12 +17,12 @@
17
17
  # along with Paru. If not, see <http://www.gnu.org/licenses/>.
18
18
  #++
19
19
  module Paru
20
- module PandocFilter
21
- require_relative "./inline"
20
+ module PandocFilter
21
+ require_relative "./inline"
22
22
 
23
- # Strikeout [Inline]
24
- class Strikeout < Inline
23
+ # A Strikeout inline node
24
+ class Strikeout < Inline
25
+ end
25
26
  end
26
- end
27
27
  end
28
28
 
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright 2015, 2016 Huub de Beer <Huub@heerdebeer.org>
2
+ # Copyright 2015, 2016, 2017 Huub de Beer <Huub@heerdebeer.org>
3
3
  #
4
4
  # This file is part of Paru
5
5
  #
@@ -17,12 +17,12 @@
17
17
  # along with Paru. If not, see <http://www.gnu.org/licenses/>.
18
18
  #++
19
19
  module Paru
20
- module PandocFilter
21
- require_relative "./inline"
20
+ module PandocFilter
21
+ require_relative "./inline"
22
22
 
23
- # Strong [Inline]
24
- class Strong < Inline
23
+ # A Strong inline node
24
+ class Strong < Inline
25
+ end
25
26
  end
26
- end
27
27
  end
28
28
 
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright 2015, 2016 Huub de Beer <Huub@heerdebeer.org>
2
+ # Copyright 2015, 2016, 2017 Huub de Beer <Huub@heerdebeer.org>
3
3
  #
4
4
  # This file is part of Paru
5
5
  #
@@ -17,12 +17,12 @@
17
17
  # along with Paru. If not, see <http://www.gnu.org/licenses/>.
18
18
  #++
19
19
  module Paru
20
- module PandocFilter
21
- require_relative "./inline"
20
+ module PandocFilter
21
+ require_relative "./inline"
22
22
 
23
- # Subscript [Inline]
24
- class Subscript < Inline
23
+ # A Subscript inline node
24
+ class Subscript < Inline
25
+ end
25
26
  end
26
- end
27
27
  end
28
28
 
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright 2015, 2016 Huub de Beer <Huub@heerdebeer.org>
2
+ # Copyright 2015, 2016, 2017 Huub de Beer <Huub@heerdebeer.org>
3
3
  #
4
4
  # This file is part of Paru
5
5
  #
@@ -17,12 +17,12 @@
17
17
  # along with Paru. If not, see <http://www.gnu.org/licenses/>.
18
18
  #++
19
19
  module Paru
20
- module PandocFilter
21
- require_relative "./inline"
20
+ module PandocFilter
21
+ require_relative "./inline"
22
22
 
23
- # Superscript [Inline]
24
- class Superscript < Inline
23
+ # A Superscript inline node
24
+ class Superscript < Inline
25
+ end
25
26
  end
26
- end
27
27
  end
28
28
 
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright 2015, 2016 Huub de Beer <Huub@heerdebeer.org>
2
+ # Copyright 2015, 2016, 2017 Huub de Beer <Huub@heerdebeer.org>
3
3
  #
4
4
  # This file is part of Paru
5
5
  #
@@ -17,37 +17,59 @@
17
17
  # along with Paru. If not, see <http://www.gnu.org/licenses/>.
18
18
  #++
19
19
  module Paru
20
- module PandocFilter
21
- require_relative "./block"
22
- require_relative "./inline"
23
- require_relative "./alignment"
20
+ module PandocFilter
21
+ require_relative "./block"
22
+ require_relative "./inline"
23
+
24
+ # The allignment of a table column
25
+ ALIGNMENTS = ["AlignLeft", "AlignRight", "AlignCenter", "AlignDefault"]
24
26
 
25
- ALIGNMENTS = ["AlignLeft", "AlignRight", "AlignCenter", "AlignDefault"]
27
+ # A Table node represents a table with an inline caption, column
28
+ # definition, widths, headers, and rows.
29
+ #
30
+ # @!attribute caption
31
+ # @return [Inline]
32
+ #
33
+ # @!attribute alignment
34
+ # @return [ALIGNMENTS]
35
+ #
36
+ # @!attribute column_widths
37
+ # @return [Float]
38
+ #
39
+ # @!attribute headers
40
+ # @return [TableRow]
41
+ #
42
+ # @!attribute rows
43
+ # @return [Array<TableRow>]
44
+ class Table < Block
45
+ attr_accessor :caption, :alignment, :column_widths, :headers, :rows
26
46
 
27
- # Table [Inline] [Alignment] [Double] [TableCell] [[TableCell]]
28
- class Table < Block
29
- attr_accessor :caption, :alignment, :column_widths, :headers, :rows
47
+ # Create a new Table based on the contents
48
+ #
49
+ # @param contents [Array]
50
+ def initialize(contents)
51
+ @caption = Inline.new contents[0]
52
+ @alignment = contents[1]
53
+ @column_widths = contents[2]
54
+ @headers = TableRow.new contents[3]
55
+ @rows = []
56
+ contents[4].each do |row_data|
57
+ @rows.push TableRow.new row_data
58
+ end
59
+ end
30
60
 
31
- def initialize contents
32
- @caption = Inline.new contents[0]
33
- @alignment = contents[1]
34
- @column_widths = contents[2]
35
- @headers = TableRow.new contents[3]
36
- @rows = []
37
- contents[4].each do |row_data|
38
- @rows.push TableRow.new row_data
61
+ # The AST contents of this Table node
62
+ #
63
+ # @return [Array]
64
+ def ast_contents()
65
+ [
66
+ @caption.ast_contents,
67
+ @alignment,
68
+ @column_widths,
69
+ @headers.ast_contents,
70
+ @rows.map {|row| row.ast_contents}
71
+ ]
72
+ end
39
73
  end
40
- end
41
-
42
- def ast_contents
43
- [
44
- @caption.ast_contents,
45
- @alignment,
46
- @column_widths,
47
- @headers.ast_contents,
48
- @rows.map {|row| row.ast_contents}
49
- ]
50
- end
51
74
  end
52
- end
53
75
  end
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright 2015, 2016 Huub de Beer <Huub@heerdebeer.org>
2
+ # Copyright 2015, 2016, 2017 Huub de Beer <Huub@heerdebeer.org>
3
3
  #
4
4
  # This file is part of Paru
5
5
  #
@@ -17,20 +17,27 @@
17
17
  # along with Paru. If not, see <http://www.gnu.org/licenses/>.
18
18
  #++
19
19
  module Paru
20
- module PandocFilter
21
- require_relative "./block"
20
+ module PandocFilter
21
+ require_relative "./block"
22
22
 
23
- class TableRow < Block
24
- def initialize row_data
25
- super []
26
- row_data.each do |cell|
27
- @children.push Block.new cell
28
- end
29
- end
23
+ # A TableRow node represents a row in a table's head or body
24
+ class TableRow < Block
25
+ # Create a new TableRow based on the row_data
26
+ #
27
+ # @param row_data [Array]
28
+ def initialize(row_data)
29
+ super []
30
+ row_data.each do |cell|
31
+ @children.push Block.new cell
32
+ end
33
+ end
30
34
 
31
- def ast_contents
32
- @children.map {|child| child.ast_contents}
33
- end
35
+ # The AST contents of this TableRow
36
+ #
37
+ # @return [Array]
38
+ def ast_contents
39
+ @children.map {|child| child.ast_contents}
40
+ end
41
+ end
34
42
  end
35
- end
36
43
  end
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright 2015, 2016 Huub de Beer <Huub@heerdebeer.org>
2
+ # Copyright 2015, 2016, 2017 Huub de Beer <Huub@heerdebeer.org>
3
3
  #
4
4
  # This file is part of Paru
5
5
  #
@@ -17,21 +17,35 @@
17
17
  # along with Paru. If not, see <http://www.gnu.org/licenses/>.
18
18
  #++
19
19
  module Paru
20
- module PandocFilter
20
+ module PandocFilter
21
+
22
+ # A Target represents the target of a link or image
23
+ #
24
+ # @!attribute url
25
+ # @return [String] the target
26
+ #
27
+ # @!attribute title
28
+ # @return [String] the title of the target
29
+ class Target
30
+ attr_accessor :url, :title
21
31
 
22
- class Target
23
- attr_accessor :url, :title
24
- def initialize contents
25
- @url = contents[0]
26
- @title = contents[1]
27
- end
32
+ # Create a new Target based on the contents
33
+ #
34
+ # @param contents [Array]
35
+ def initialize(contents)
36
+ @url = contents[0]
37
+ @title = contents[1]
38
+ end
28
39
 
29
- def to_ast
30
- [
31
- @url,
32
- @title
33
- ]
34
- end
40
+ # Create an AST representation of this Target
41
+ #
42
+ # @return [Array]
43
+ def to_ast()
44
+ [
45
+ @url,
46
+ @title
47
+ ]
48
+ end
49
+ end
35
50
  end
36
- end
37
51
  end
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright 2015, 2016 Huub de Beer <Huub@heerdebeer.org>
2
+ # Copyright 2015, 2016, 2017 Huub de Beer <Huub@heerdebeer.org>
3
3
  #
4
4
  # This file is part of Paru
5
5
  #
@@ -17,21 +17,30 @@
17
17
  # along with Paru. If not, see <http://www.gnu.org/licenses/>.
18
18
  #++
19
19
  module Paru
20
- module PandocFilter
21
- require_relative "./node"
20
+ module PandocFilter
21
+ require_relative "./node"
22
22
 
23
- class Version < Node
24
- def initialize contents
25
- @major, @minor, @revision = contents
26
- end
23
+ # Version is a general Node containing the pandoc-api-version. It has
24
+ # the format major.minor.revision.sub
25
+ class Version < Node
27
26
 
28
- def ast_type
29
- "pandoc-api-version"
30
- end
27
+ # Create a Version node based on contents
28
+ #
29
+ # @param contents [Array<Integer>] a list with api, major, minor,
30
+ # revision number
31
+ def initialize(contents)
32
+ @api, @major, @minor, @revision = contents
33
+ end
31
34
 
32
- def to_ast
33
- [@major, @minor, @revision]
34
- end
35
+ # The AST type is "pandoc-api-version"
36
+ def ast_type
37
+ "pandoc-api-version"
38
+ end
39
+
40
+ # Create an AST representation of this Version
41
+ def to_ast()
42
+ [@api, @major, @minor, @revision]
43
+ end
44
+ end
35
45
  end
36
- end
37
46
  end
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright 2015, 2016 Huub de Beer <Huub@heerdebeer.org>
2
+ # Copyright 2015, 2016, 2017 Huub de Beer <Huub@heerdebeer.org>
3
3
  #
4
4
  # This file is part of Paru
5
5
  #
@@ -18,134 +18,188 @@
18
18
  #++
19
19
  module Paru
20
20
 
21
- require "yaml"
22
-
23
- # Pandoc is a wrapper around the pandoc system. See
24
- # <http://pandoc.org/README.html> for details about pandoc. This file is
25
- # basically a straightforward translation from command line program to ruby
26
- # class
27
-
28
- class Pandoc
29
-
30
- # Gather information about pandoc. It runs `pandoc --version` and extracts
31
- # pandoc's version number and default data directory.
32
- def self.info
33
- output = ''
34
- IO.popen('pandoc --version', 'r+') do |p|
35
- p.close_write
36
- output << p.read
37
- end
38
- version = output.match(/pandoc (\d+\.\d+.*)$/)[1]
39
- data_dir = output.match(/Default user data directory: (.+)$/)[1]
40
-
41
- {
42
- :version => version,
43
- :data_dir => data_dir
44
- }
45
- end
21
+ require "shellwords"
22
+ require "yaml"
46
23
 
47
- def initialize &block
48
- @options = {}
49
- configure(&block) if block_given?
50
- end
24
+ # Pandoc is a wrapper around the pandoc document converter. See
25
+ # <http://pandoc.org/README.html> for details about pandoc. This file is
26
+ # basically a straightforward translation from the pandoc command line
27
+ # program to a ruby class, giving a Rubyesque API to work with pandoc.
28
+ #
29
+ # @example Convert the markdown string 'hello *world*' to HTML
30
+ # converter = Paru::Pandoc.new
31
+ # converter.configure do
32
+ # from "markdown"
33
+ # to "html"
34
+ # end
35
+ # converter.convert 'hello *world*'
36
+ #
37
+ # @example Convert markdown to HTML, written in a more commonly used shorthand
38
+ # Paru::Pandoc.new do
39
+ # from markdown
40
+ # to html
41
+ # end << 'hello *world*'
42
+ #
43
+ #
44
+ class Pandoc
45
+
46
+ # Gather information about pandoc. It runs `pandoc --version` and extracts
47
+ # pandoc's version number and default data directory.
48
+ #
49
+ # @return [Hash] Return a Hash with the :verion and :data_dir of the
50
+ # pandoc installation
51
+ def self.info()
52
+ output = ''
53
+ IO.popen('pandoc --version', 'r+') do |p|
54
+ p.close_write
55
+ output << p.read
56
+ end
57
+ version = output.match(/pandoc (\d+\.\d+.*)$/)[1]
58
+ data_dir = output.match(/Default user data directory: (.+)$/)[1]
59
+
60
+ {
61
+ :version => version,
62
+ :data_dir => data_dir
63
+ }
64
+ end
51
65
 
52
- def configure &block
53
- instance_eval(&block)
54
- self
55
- end
66
+ # Create a new Pandoc converter, optionally configured by block
67
+ #
68
+ # @param block [Proc] an optional configuration block. See #configure
69
+ # for how to configure a Pandoc converter
70
+ def initialize(&block)
71
+ @options = {}
72
+ configure(&block) if block_given?
73
+ end
56
74
 
57
- # Converts input string to output string using the pandoc invocation
58
- # configures in this Pandoc instance.
59
- def convert input
60
- output = ""
61
- IO.popen(to_command, "r+") do |p|
62
- p << input
63
- p.close_write
64
- output << p.read
65
- end
66
- output
67
- end
68
- alias << convert
75
+ # Configure this Pandoc converter with block. In the block you can
76
+ # call all pandoc options as methods on this converter. In multi-word
77
+ # options the dash (-) is replaced by an underscore (_)
78
+ #
79
+ # Pandoc has a number of command line options. Most are simple options,
80
+ # like flags, that can be set only once. Other options can occur more than
81
+ # once, such as the css option: to add more than one css file to a
82
+ # generated standalone html file, use the css options once for each
83
+ # stylesheet to include. Other options do have the pattern key[:value],
84
+ # which can also occur multiple times, such as metadata.
85
+ #
86
+ # All options are specified in a pandoc_options.yaml. If it is an option
87
+ # that can occur only once, the value of the option in that yaml file is
88
+ # its default value. If the option can occur multiple times, its value is
89
+ # an array with one value, the default value.
90
+ #
91
+ # @param block [Proc] the options to pandoc
92
+ # @return [Pandoc] this Pandoc converter
93
+ #
94
+ # @example Configure converting HTML to LaTeX with a LaTeX engine
95
+ # converter.configure do
96
+ # from 'html'
97
+ # to 'latex'
98
+ # latex_engine 'lualatex'
99
+ # end
100
+ #
101
+ def configure(&block)
102
+ instance_eval(&block)
103
+ self
104
+ end
69
105
 
70
- def to_command option_sep = " \\\n\t"
71
- "pandoc\t#{to_option_string option_sep}"
72
- end
106
+ # Converts input string to output string using the pandoc invocation
107
+ # configured in this Pandoc instance.
108
+ #
109
+ # @param input [String] the input string to convert
110
+ # @return [String] the converted output string
111
+ #
112
+ # The following two examples are the same:
113
+ #
114
+ # @example Using convert
115
+ # output = converter.convert 'this is a *strong* word'
116
+ #
117
+ # @example Using <<
118
+ # output = converter << 'this is a *strong* word'
119
+ def convert(input)
120
+ output = ''
121
+ IO.popen(to_command, 'r+') do |p|
122
+ p << input
123
+ p.close_write
124
+ output << p.read
125
+ end
126
+ output
127
+ end
128
+ alias << convert
129
+
130
+ # Create a string representation of this converter's pandoc command
131
+ # line invocation. This is useful for debugging purposes.
132
+ #
133
+ # @param option_sep [String] the string to separate options with
134
+ # @return [String] This converter's command line invocation string.
135
+ def to_command(option_sep = " \\\n\t")
136
+ "pandoc\t#{to_option_string option_sep}"
137
+ end
73
138
 
74
- def to_option_string option_sep
75
- options_arr = []
76
- @options.each do |option, value|
77
- option_string = "--#{option.to_s.gsub "_", "-"}"
78
-
79
- case value
80
- when TrueClass then
81
- # Flags don"t have a value, only its name
82
- # For example: --standalone
83
- options_arr.push "#{option_string}"
84
- when FalseClass then
85
- # Skip this option; consider a flag with value false as unset
86
- when Array then
87
- # This option can occur multiple times: list each with its value.
88
- # For example: --css=main.css --css=print.css
89
- options_arr.push value.map {|val| "#{option_string}=#{val.to_s}"}.join(option_sep)
90
- else
91
- # All options that aren"t flags and can occur only once have the
92
- # same pattern: --option=value
93
- options_arr.push "#{option_string}=#{value.to_s}"
139
+ private
140
+
141
+ def to_option_string(option_sep)
142
+ options_arr = []
143
+ @options.each do |option, value|
144
+ option_string = "--#{option.to_s.gsub '_', '-'}"
145
+
146
+ case value
147
+ when TrueClass then
148
+ # Flags don't have a value, only its name
149
+ # For example: --standalone
150
+ options_arr.push "#{option_string}"
151
+ when FalseClass then
152
+ # Skip this option; consider a flag with value false as unset
153
+ when Array then
154
+ # This option can occur multiple times: list each with its value.
155
+ # For example: --css=main.css --css=print.css
156
+ options_arr.push value.map {|val| "#{option_string}=#{val.to_s.shellescape}"}.join(option_sep)
157
+ else
158
+ # All options that aren't flags and can occur only once have the
159
+ # same pattern: --option=value
160
+ options_arr.push "#{option_string}=#{value.to_s.shellescape}"
161
+ end
162
+ end
163
+ options_arr.join(option_sep)
94
164
  end
95
- end
96
- options_arr.join(option_sep)
97
- end
98
165
 
99
- # Pandoc has a number of command line options. Most are simple options,
100
- # like flags, that can be set only once. Other options can occur more than
101
- # once, such as the css option: to add more than one css file to a
102
- # generated standalone html file, use the css options once for each
103
- # stylesheet to include. Other options do have the pattern key[:value],
104
- # which can also occur multiple times, such as metadata.
105
- #
106
- # All options are specified in a pandoc_options.yaml. If it is an option
107
- # that can occur only once, the value of the option in that yaml file is
108
- # its default value. If the option can occur multiple times, its value is
109
- # an array with one value, the default value.
110
- #
111
- # For each of these options a method is defined as follows:
112
- OPTIONS = YAML.load_file File.join(__dir__, "pandoc_options.yaml")
166
+ # For each pandoc command line option a method is defined as follows:
167
+ OPTIONS = YAML.load_file File.join(__dir__, 'pandoc_options.yaml')
113
168
 
114
- OPTIONS.keys.each do |option|
115
- if OPTIONS[option].is_a? Array then
169
+ OPTIONS.keys.each do |option|
170
+ if OPTIONS[option].is_a? Array then
116
171
 
117
- # option can be set multiple times, for example adding multiple css
118
- # files
172
+ # option can be set multiple times, for example adding multiple css
173
+ # files
119
174
 
120
- default = OPTIONS[option][0]
175
+ default = OPTIONS[option][0]
121
176
 
122
- define_method(option) do |value = default|
123
- if @options[option].nil? then
124
- @options[option] = []
125
- end
177
+ define_method(option) do |value = default|
178
+ if @options[option].nil? then
179
+ @options[option] = []
180
+ end
126
181
 
127
- if value.is_a? Array then
128
- @options[option] += value
129
- else
130
- @options[option].push value
131
- end
182
+ if value.is_a? Array then
183
+ @options[option] += value
184
+ else
185
+ @options[option].push value
186
+ end
132
187
 
133
- self
134
- end
188
+ self
189
+ end
135
190
 
136
- else
191
+ else
192
+ # option can be set only once, for example a flag or a template
137
193
 
138
- # option can be set only once, for example a flag or a template
194
+ default = OPTIONS[option]
195
+ define_method(option) do |value = default|
196
+ @options[option] = value
197
+ self
198
+ end
139
199
 
140
- default = OPTIONS[option]
141
- define_method(option) do |value = default|
142
- @options[option] = value
143
- self
200
+ end
144
201
  end
145
202
 
146
- end
147
203
  end
148
204
 
149
- end
150
-
151
205
  end