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.
- checksums.yaml +4 -4
- data/lib/paru.rb +8 -20
- data/lib/paru/error.rb +4 -6
- data/lib/paru/filter.rb +144 -110
- data/lib/paru/filter/ast_manipulation.rb +75 -39
- data/lib/paru/filter/attr.rb +72 -36
- data/lib/paru/filter/block.rb +14 -8
- data/lib/paru/filter/block_quote.rb +12 -9
- data/lib/paru/filter/bullet_list.rb +6 -6
- data/lib/paru/filter/citation.rb +51 -25
- data/lib/paru/filter/cite.rb +29 -20
- data/lib/paru/filter/code.rb +41 -24
- data/lib/paru/filter/code_block.rb +36 -21
- data/lib/paru/filter/definition_list.rb +19 -15
- data/lib/paru/filter/definition_list_item.rb +30 -17
- data/lib/paru/filter/div.rb +29 -21
- data/lib/paru/filter/document.rb +73 -46
- data/lib/paru/filter/emph.rb +6 -6
- data/lib/paru/filter/empty_block.rb +17 -13
- data/lib/paru/filter/empty_inline.rb +24 -17
- data/lib/paru/filter/header.rb +38 -23
- data/lib/paru/filter/image.rb +13 -11
- data/lib/paru/filter/inline.rb +21 -10
- data/lib/paru/filter/line_block.rb +6 -6
- data/lib/paru/filter/line_break.rb +6 -6
- data/lib/paru/filter/link.rb +33 -21
- data/lib/paru/filter/list.rb +26 -17
- data/lib/paru/filter/list_attributes.rb +53 -32
- data/lib/paru/filter/markdown.rb +102 -59
- data/lib/paru/filter/math.rb +65 -38
- data/lib/paru/filter/meta.rb +26 -16
- data/lib/paru/filter/meta_blocks.rb +12 -9
- data/lib/paru/filter/meta_bool.rb +6 -6
- data/lib/paru/filter/meta_inlines.rb +12 -9
- data/lib/paru/filter/meta_list.rb +6 -6
- data/lib/paru/filter/meta_map.rb +49 -33
- data/lib/paru/filter/meta_string.rb +6 -6
- data/lib/paru/filter/meta_value.rb +22 -14
- data/lib/paru/filter/node.rb +204 -129
- data/lib/paru/filter/note.rb +31 -20
- data/lib/paru/filter/null.rb +6 -6
- data/lib/paru/filter/ordered_list.rb +34 -18
- data/lib/paru/filter/para.rb +20 -13
- data/lib/paru/filter/plain.rb +21 -12
- data/lib/paru/filter/quoted.rb +27 -18
- data/lib/paru/filter/raw_block.rb +32 -19
- data/lib/paru/filter/raw_inline.rb +40 -22
- data/lib/paru/filter/small_caps.rb +7 -6
- data/lib/paru/filter/soft_break.rb +6 -6
- data/lib/paru/filter/space.rb +6 -6
- data/lib/paru/filter/span.rb +28 -18
- data/lib/paru/filter/str.rb +29 -18
- data/lib/paru/filter/strikeout.rb +6 -6
- data/lib/paru/filter/strong.rb +6 -6
- data/lib/paru/filter/subscript.rb +6 -6
- data/lib/paru/filter/superscript.rb +6 -6
- data/lib/paru/filter/table.rb +51 -29
- data/lib/paru/filter/table_row.rb +21 -14
- data/lib/paru/filter/target.rb +29 -15
- data/lib/paru/filter/version.rb +23 -14
- data/lib/paru/pandoc.rb +165 -111
- data/lib/paru/pandoc_options.yaml +3 -3
- data/lib/paru/selector.rb +176 -153
- metadata +2 -3
- 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
|
-
|
21
|
-
|
22
|
-
|
20
|
+
module PandocFilter
|
21
|
+
require_relative "./list"
|
22
|
+
require_relative "./list_attributes"
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
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
|
data/lib/paru/filter/para.rb
CHANGED
@@ -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
|
-
|
21
|
-
|
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
|
-
|
30
|
-
|
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
|
data/lib/paru/filter/plain.rb
CHANGED
@@ -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
|
-
|
21
|
-
|
20
|
+
module PandocFilter
|
21
|
+
require_relative "./block"
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
-
|
30
|
-
|
31
|
-
|
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
|
data/lib/paru/filter/quoted.rb
CHANGED
@@ -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
|
-
|
21
|
-
|
20
|
+
module PandocFilter
|
21
|
+
require_relative "./inline"
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|
-
|
32
|
+
attr_accessor :quote_type
|
28
33
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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
|
-
|
21
|
-
|
20
|
+
module PandocFilter
|
21
|
+
require_relative "./block"
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|
-
|
28
|
-
|
29
|
-
|
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
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
40
|
+
# Create an AST representation of this RawBlock node
|
41
|
+
def to_ast()
|
42
|
+
[
|
43
|
+
@format,
|
44
|
+
@string
|
45
|
+
]
|
46
|
+
end
|
37
47
|
|
38
|
-
|
39
|
-
|
40
|
-
|
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
|
-
|
20
|
+
module PandocFilter
|
21
21
|
|
22
|
-
|
22
|
+
require_relative "./inline"
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
-
|
29
|
-
|
30
|
-
|
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
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
41
|
+
# The AST contents
|
42
|
+
#
|
43
|
+
# @return [Array]
|
44
|
+
def ast_contents()
|
45
|
+
[
|
46
|
+
@format,
|
47
|
+
@string
|
48
|
+
]
|
49
|
+
end
|
38
50
|
|
39
|
-
|
40
|
-
|
41
|
-
|
51
|
+
# Has this RawInline a string value?
|
52
|
+
#
|
53
|
+
# @return [Boolean] true
|
54
|
+
def has_string?()
|
55
|
+
true
|
56
|
+
end
|
42
57
|
|
43
|
-
|
44
|
-
|
45
|
-
|
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
|
-
|
21
|
-
|
20
|
+
module PandocFilter
|
21
|
+
require_relative "./inline"
|
22
22
|
|
23
|
-
|
24
|
-
|
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
|
-
|
21
|
-
|
20
|
+
module PandocFilter
|
21
|
+
require_relative "./empty_inline"
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
# A SoftBreak node
|
24
|
+
class SoftBreak < EmptyInline
|
25
|
+
end
|
25
26
|
end
|
26
|
-
end
|
27
27
|
end
|
data/lib/paru/filter/space.rb
CHANGED
@@ -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
|
-
|
21
|
-
|
20
|
+
module PandocFilter
|
21
|
+
require_relative "./empty_inline"
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
# A Space node
|
24
|
+
class Space < EmptyInline
|
25
|
+
end
|
25
26
|
end
|
26
|
-
end
|
27
27
|
end
|
data/lib/paru/filter/span.rb
CHANGED
@@ -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
|
-
|
20
|
+
module PandocFilter
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
require_relative "./inline"
|
23
|
+
require_relative "./attr"
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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
|