paru 0.2.4.2 → 0.2.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,42 @@
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 "./list"
22
- require_relative "./list_attributes"
20
+ module PandocFilter
21
+ require_relative "./list"
22
+ require_relative "./list_attributes"
23
23
 
24
- # OrderedList ListAttributes [[Block]]
25
- class OrderedList < List
26
- attr_accessor :list_attributes
24
+ # An OrderedList Node
25
+ #
26
+ # @example In markdown an ordered list looks like
27
+ # 1. this is the first item
28
+ # 2. this the second
29
+ # 3. and so on
30
+ #
31
+ # It has an ListAttributes object and a list of items
32
+ #
33
+ # @!attribute list_attributes
34
+ # @return [ListAttributes]
35
+ class OrderedList < List
36
+ attr_accessor :list_attributes
27
37
 
28
- def initialize contents
29
- @list_attributes = ListAttributes.new contents[0]
30
- super contents[1]
31
- end
38
+ # Create a new OrderedList node based on the contents
39
+ #
40
+ # @param contents [Array]
41
+ def initialize(contents)
42
+ @list_attributes = ListAttributes.new contents[0]
43
+ super contents[1]
44
+ end
32
45
 
33
- def ast_contents
34
- [
35
- @list_attributes.to_ast,
36
- super
37
- ]
38
- end
46
+ # The AST contents
47
+ #
48
+ # @return [Array]
49
+ def ast_contents
50
+ [
51
+ @list_attributes.to_ast,
52
+ super
53
+ ]
54
+ end
39
55
 
56
+ end
40
57
  end
41
- end
42
58
  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,19 +17,26 @@
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
-
23
- # Para [Inline]
24
- class Para < Block
25
- def initialize contents
26
- super contents, true
27
- end
20
+ module PandocFilter
21
+ require_relative "./block"
28
22
 
29
- def has_inline?
30
- true
31
- end
23
+ # A Para is a paragraph: a list of Inline nodes
24
+ class Para < Block
32
25
 
26
+ # Create a new Para node based on the contents
27
+ #
28
+ # @param contents [Array]
29
+ def initialize(contents)
30
+ super contents, true
31
+ end
32
+
33
+ # Does a Para have inline content?
34
+ #
35
+ # @return [Boolean] true
36
+ def has_inline?
37
+ true
38
+ end
39
+
40
+ end
33
41
  end
34
- end
35
42
  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,18 +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
- # Plain [Inline]
24
- class Plain < Block
25
- def initialize contents
26
- super contents, true
27
- end
23
+ # A Plain node is a basic Block level node with Inline children. Not
24
+ # to be confused with Para, which represents a paragraph. A Plain
25
+ # is more general.
26
+ class Plain < Block
28
27
 
29
- def has_inline?
30
- true
31
- end
28
+ # Create a new Plain node based on contents
29
+ #
30
+ # @param contents [Array]
31
+ def initialize(contents)
32
+ super contents, true
33
+ end
34
+
35
+ # Has a Plain node inline contents?
36
+ #
37
+ # @return [Boolean] true
38
+ def has_inline?
39
+ true
40
+ end
41
+ end
32
42
  end
33
- end
34
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,26 +17,35 @@
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
- # Quoted QuoteType [Inline]
24
- class Quoted < Inline
25
- QUOTE_TYPE = ["SingleQuote", "DoubleQuote"]
23
+ # A Quoted node represents a quote with a type and the contents of the
24
+ # quote
25
+ #
26
+ # @!attribute quote_type
27
+ # @return [QUOTE_TYPE]
28
+ class Quoted < Inline
29
+ # A quote is either a single quote or a double quote
30
+ QUOTE_TYPE = ["SingleQuote", "DoubleQuote"]
26
31
 
27
- attr_accessor :quote_type
32
+ attr_accessor :quote_type
28
33
 
29
- def initialize contents
30
- @quote_type = contents[0]
31
- super contents[1]
32
- end
34
+ # Create a new Quote node based on the contents
35
+ #
36
+ # @param contents [Array]
37
+ def initialize(contents)
38
+ @quote_type = contents[0]
39
+ super contents[1]
40
+ end
33
41
 
34
- def ast_contents
35
- [
36
- @quote_type,
37
- super
38
- ]
39
- end
42
+ # The AST contents of a Quote node
43
+ def ast_contents()
44
+ [
45
+ @quote_type,
46
+ super
47
+ ]
48
+ end
49
+ end
40
50
  end
41
- end
42
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,27 +17,40 @@
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
- # RawBlock Format String
24
- class RawBlock < Block
25
- attr_accessor :format, :string
23
+ # A RawBlock node has a format and a string contents
24
+ #
25
+ # @!attribute format
26
+ # @return [String]
27
+ #
28
+ # @!attribute string
29
+ # @return [String]
30
+ class RawBlock < Block
31
+ attr_accessor :format, :string
26
32
 
27
- def initialize(contents)
28
- @format, @string = contents
29
- end
33
+ # Create a new RawBlock node based on the contents
34
+ #
35
+ # @param contents [Array]
36
+ def initialize(contents)
37
+ @format, @string = contents
38
+ end
30
39
 
31
- def to_ast
32
- [
33
- @format,
34
- @string
35
- ]
36
- end
40
+ # Create an AST representation of this RawBlock node
41
+ def to_ast()
42
+ [
43
+ @format,
44
+ @string
45
+ ]
46
+ end
37
47
 
38
- def has_string?
39
- true
40
- end
48
+ # Has this RawBlock node a string value?
49
+ #
50
+ # @return [Boolean] true
51
+ def has_string?
52
+ true
53
+ end
54
+ end
41
55
  end
42
- end
43
56
  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,32 +17,50 @@
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
21
 
22
- require_relative "./inline"
22
+ require_relative "./inline"
23
23
 
24
- # RawInline Format String
25
- class RawInline < Inline
26
- attr_accessor :format, :string
24
+ # A RawInline node has a format and a string value
25
+ #
26
+ # @!attribute format
27
+ # @return [String]
28
+ #
29
+ # @!attribute string
30
+ # @return [String]
31
+ class RawInline < Inline
32
+ attr_accessor :format, :string
27
33
 
28
- def initialize contents
29
- @format, @string = contents
30
- end
34
+ # Create a new RawInline node based on the contents
35
+ #
36
+ # @param contents [Array]
37
+ def initialize(contents)
38
+ @format, @string = contents
39
+ end
31
40
 
32
- def ast_contents
33
- [
34
- @format,
35
- @string
36
- ]
37
- end
41
+ # The AST contents
42
+ #
43
+ # @return [Array]
44
+ def ast_contents()
45
+ [
46
+ @format,
47
+ @string
48
+ ]
49
+ end
38
50
 
39
- def has_string?
40
- true
41
- end
51
+ # Has this RawInline a string value?
52
+ #
53
+ # @return [Boolean] true
54
+ def has_string?()
55
+ true
56
+ end
42
57
 
43
- def has_inline?
44
- false
45
- end
58
+ # Has this RawInline inline contents?
59
+ #
60
+ # @return [Boolean] false
61
+ def has_inline?()
62
+ false
63
+ end
64
+ end
46
65
  end
47
- end
48
66
  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,13 @@
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
- # SmallCaps [Inline]
24
- class SmallCaps < Inline
23
+ # A SmallCaps node is an inline level node representing SMALL CAPS
24
+ # text
25
+ class SmallCaps < Inline
26
+ end
25
27
  end
26
- end
27
28
  end
28
29
 
@@ -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,11 +17,11 @@
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 "./empty_inline"
20
+ module PandocFilter
21
+ require_relative "./empty_inline"
22
22
 
23
- # SoftBreak
24
- class SoftBreak < EmptyInline
23
+ # A SoftBreak node
24
+ class SoftBreak < EmptyInline
25
+ end
25
26
  end
26
- end
27
27
  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,11 +17,11 @@
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 "./empty_inline"
20
+ module PandocFilter
21
+ require_relative "./empty_inline"
22
22
 
23
- # Space
24
- class Space < EmptyInline
23
+ # A Space node
24
+ class Space < EmptyInline
25
+ end
25
26
  end
26
- end
27
27
  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,26 +17,36 @@
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
21
 
22
- require_relative "./inline"
23
- require_relative "./attr"
22
+ require_relative "./inline"
23
+ require_relative "./attr"
24
24
 
25
- # Span Attr [Inline]
26
- class Span < Inline
27
- attr_accessor :attr
25
+ # A Span node is a general Inline level node with attributes and
26
+ # contens
27
+ #
28
+ # @!attribute attr
29
+ # @return [Attr]
30
+ class Span < Inline
31
+ attr_accessor :attr
28
32
 
29
- def initialize contents
30
- @attr = Attr.new contents[0]
31
- super contents[1]
32
- end
33
+ # Create a new Span node based on the contents
34
+ #
35
+ # @param contents [Array]
36
+ def initialize(contents)
37
+ @attr = Attr.new contents[0]
38
+ super contents[1]
39
+ end
33
40
 
34
- def ast_contents
35
- [
36
- @attr.to_ast,
37
- super
38
- ]
39
- end
41
+ # The AST contents
42
+ #
43
+ # @return [Array]
44
+ def ast_contents()
45
+ [
46
+ @attr.to_ast,
47
+ super
48
+ ]
49
+ end
50
+ end
40
51
  end
41
- end
42
52
  end