markly 0.13.1 → 0.14.0
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/ext/markly/extconf.rb +3 -3
- data/lib/markly/node/inspect.rb +10 -10
- data/lib/markly/node.rb +13 -13
- data/lib/markly/renderer/generic.rb +28 -28
- data/lib/markly/renderer/html.rb +94 -70
- data/lib/markly/version.rb +2 -2
- data/lib/markly.rb +6 -6
- data/license.md +1 -1
- data/readme.md +10 -4
- data/releases.md +5 -0
- data.tar.gz.sig +0 -0
- metadata +4 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 487f63b7eea5d3c60a7cf13c96de66b338d4b1617d2e7e6951b5410329548427
|
4
|
+
data.tar.gz: 42b55e0aa850ec338ad66b03a8e75be8766e2de2d503d780f975587257140dcd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: baac74312598fc9d95e0bfee6f3d5f53f92381470a0b667a8565766d171dfca591830390f4435aa84561c619f14f831bc154df58849e364ab9081958794a674d
|
7
|
+
data.tar.gz: 2503c20036daa9d1ec67ca6ffe573bf2f443c346f981a8f1a20315821d2df67bf6eb7333b400490c56c97e8e501156583db33496ecca194262af1c7fc9ad9c6d
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/ext/markly/extconf.rb
CHANGED
@@ -6,14 +6,14 @@
|
|
6
6
|
# Copyright, 2015-2019, by Garen Torikian.
|
7
7
|
# Copyright, 2016-2017, by Yuki Izumi.
|
8
8
|
# Copyright, 2017, by Ashe Connor.
|
9
|
-
# Copyright, 2020-
|
9
|
+
# Copyright, 2020-2025, by Samuel Williams.
|
10
10
|
|
11
|
-
require
|
11
|
+
require "mkmf"
|
12
12
|
|
13
13
|
append_cflags(["-O3", "-Wall", "-Wno-unknown-pragmas", "-std=c99"])
|
14
14
|
|
15
15
|
gem_name = File.basename(__dir__)
|
16
|
-
extension_name =
|
16
|
+
extension_name = "markly"
|
17
17
|
|
18
18
|
# The destination:
|
19
19
|
dir_config(extension_name)
|
data/lib/markly/node/inspect.rb
CHANGED
@@ -4,24 +4,24 @@
|
|
4
4
|
# Copyright, 2017, by Goro Fuji.
|
5
5
|
# Copyright, 2017-2019, by Garen Torikian.
|
6
6
|
# Copyright, 2020, by Olle Jonsson.
|
7
|
-
# Copyright, 2020-
|
7
|
+
# Copyright, 2020-2025, by Samuel Williams.
|
8
8
|
|
9
|
-
require
|
9
|
+
require "pp"
|
10
10
|
|
11
11
|
module Markly
|
12
12
|
class Node
|
13
13
|
module Inspect
|
14
14
|
PP_INDENT_SIZE = 2
|
15
|
-
|
15
|
+
|
16
16
|
def inspect
|
17
|
-
PP.pp(self, +
|
17
|
+
PP.pp(self, +"", Float::INFINITY)
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
# @param printer [PrettyPrint] pp
|
21
21
|
def pretty_print(printer)
|
22
|
-
printer.group(PP_INDENT_SIZE, "#<#{self.class}(#{type}):",
|
22
|
+
printer.group(PP_INDENT_SIZE, "#<#{self.class}(#{type}):", ">") do
|
23
23
|
printer.breakable
|
24
|
-
|
24
|
+
|
25
25
|
attrs = %i[
|
26
26
|
source_position
|
27
27
|
string_content
|
@@ -39,12 +39,12 @@ module Markly
|
|
39
39
|
nil
|
40
40
|
end
|
41
41
|
end.compact
|
42
|
-
|
42
|
+
|
43
43
|
printer.seplist(attrs) do |name, value|
|
44
44
|
printer.text "#{name}="
|
45
45
|
printer.pp value
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
if first_child
|
49
49
|
printer.breakable
|
50
50
|
printer.group(PP_INDENT_SIZE) do
|
@@ -54,7 +54,7 @@ module Markly
|
|
54
54
|
children << node
|
55
55
|
node = node.next
|
56
56
|
end
|
57
|
-
printer.text
|
57
|
+
printer.text "children="
|
58
58
|
printer.pp children
|
59
59
|
end
|
60
60
|
end
|
data/lib/markly/node.rb
CHANGED
@@ -5,9 +5,9 @@
|
|
5
5
|
# Copyright, 2016-2017, by Yuki Izumi.
|
6
6
|
# Copyright, 2017, by Goro Fuji.
|
7
7
|
# Copyright, 2018, by Jerry van Leeuwen.
|
8
|
-
# Copyright, 2020-
|
8
|
+
# Copyright, 2020-2025, by Samuel Williams.
|
9
9
|
|
10
|
-
require_relative
|
10
|
+
require_relative "node/inspect"
|
11
11
|
|
12
12
|
module Markly
|
13
13
|
class Node
|
@@ -32,13 +32,13 @@ module Markly
|
|
32
32
|
# blk - A {Proc} representing the action to take for each child
|
33
33
|
def walk(&block)
|
34
34
|
return enum_for(:walk) unless block_given?
|
35
|
-
|
35
|
+
|
36
36
|
yield self
|
37
37
|
each do |child|
|
38
38
|
child.walk(&block)
|
39
39
|
end
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
# Public: Convert the node to an HTML string.
|
43
43
|
#
|
44
44
|
# options - A {Symbol} or {Array of Symbol}s indicating the render options
|
@@ -46,9 +46,9 @@ module Markly
|
|
46
46
|
#
|
47
47
|
# Returns a {String}.
|
48
48
|
def to_html(flags: DEFAULT, extensions: [])
|
49
|
-
_render_html(flags, extensions).force_encoding(
|
49
|
+
_render_html(flags, extensions).force_encoding("utf-8")
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
# Public: Convert the node to a CommonMark string.
|
53
53
|
#
|
54
54
|
# options - A {Symbol} or {Array of Symbol}s indicating the render options
|
@@ -56,11 +56,11 @@ module Markly
|
|
56
56
|
#
|
57
57
|
# Returns a {String}.
|
58
58
|
def to_commonmark(flags: DEFAULT, width: 0)
|
59
|
-
_render_commonmark(flags, width).force_encoding(
|
59
|
+
_render_commonmark(flags, width).force_encoding("utf-8")
|
60
60
|
end
|
61
|
-
|
61
|
+
|
62
62
|
alias to_markdown to_commonmark
|
63
|
-
|
63
|
+
|
64
64
|
# Public: Convert the node to a plain text string.
|
65
65
|
#
|
66
66
|
# options - A {Symbol} or {Array of Symbol}s indicating the render options
|
@@ -68,13 +68,13 @@ module Markly
|
|
68
68
|
#
|
69
69
|
# Returns a {String}.
|
70
70
|
def to_plaintext(flags: DEFAULT, width: 0)
|
71
|
-
_render_plaintext(flags, width).force_encoding(
|
71
|
+
_render_plaintext(flags, width).force_encoding("utf-8")
|
72
72
|
end
|
73
|
-
|
73
|
+
|
74
74
|
# Public: Iterate over the children (if any) of the current pointer.
|
75
75
|
def each
|
76
76
|
return enum_for(:each) unless block_given?
|
77
|
-
|
77
|
+
|
78
78
|
child = first_child
|
79
79
|
while child
|
80
80
|
next_child = child.next
|
@@ -179,6 +179,6 @@ module Markly
|
|
179
179
|
|
180
180
|
fragment
|
181
181
|
end
|
182
|
-
|
182
|
+
|
183
183
|
end
|
184
184
|
end
|
@@ -3,32 +3,32 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2015-2019, by Garen Torikian.
|
5
5
|
# Copyright, 2016-2017, by Yuki Izumi.
|
6
|
-
# Copyright, 2020-
|
6
|
+
# Copyright, 2020-2025, by Samuel Williams.
|
7
7
|
|
8
|
-
require
|
9
|
-
require
|
8
|
+
require "set"
|
9
|
+
require "stringio"
|
10
10
|
|
11
11
|
module Markly
|
12
12
|
module Renderer
|
13
13
|
class Generic
|
14
14
|
def initialize(flags: DEFAULT, extensions: [])
|
15
15
|
@flags = flags
|
16
|
-
@stream = StringIO.new(+
|
16
|
+
@stream = StringIO.new(+"")
|
17
17
|
@need_blocksep = false
|
18
18
|
@in_tight = false
|
19
19
|
@in_plain = false
|
20
20
|
@tagfilter = extensions.include?(:tagfilter)
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
attr_accessor :in_tight
|
24
24
|
attr_accessor :in_plain
|
25
|
-
|
25
|
+
|
26
26
|
def out(*args)
|
27
27
|
args.each do |arg|
|
28
28
|
if arg == :children
|
29
|
-
@node.each {
|
29
|
+
@node.each {|child| out(child)}
|
30
30
|
elsif arg.is_a?(Array)
|
31
|
-
arg.each {
|
31
|
+
arg.each {|x| render(x)}
|
32
32
|
elsif arg.is_a?(Node)
|
33
33
|
render(arg)
|
34
34
|
else
|
@@ -36,72 +36,72 @@ module Markly
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
def render(node)
|
41
41
|
@node = node
|
42
42
|
if node.type == :document
|
43
43
|
document(node)
|
44
44
|
@stream.string
|
45
45
|
elsif @in_plain && node.type != :text && node.type != :softbreak
|
46
|
-
node.each {
|
46
|
+
node.each {|child| render(child)}
|
47
47
|
else
|
48
48
|
send(node.type, node)
|
49
49
|
end
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
def document(_node)
|
53
53
|
out(:children)
|
54
54
|
end
|
55
|
-
|
55
|
+
|
56
56
|
def code_block(node)
|
57
57
|
code_block(node)
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
60
|
def reference_def(_node); end
|
61
|
-
|
61
|
+
|
62
62
|
def cr
|
63
63
|
return if @stream.string.empty? || @stream.string[-1] == "\n"
|
64
|
-
|
64
|
+
|
65
65
|
out("\n")
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
68
|
def blocksep
|
69
69
|
out("\n")
|
70
70
|
end
|
71
|
-
|
71
|
+
|
72
72
|
def containersep
|
73
73
|
cr unless @in_tight
|
74
74
|
end
|
75
|
-
|
75
|
+
|
76
76
|
def block
|
77
77
|
cr
|
78
78
|
yield
|
79
79
|
cr
|
80
80
|
end
|
81
|
-
|
81
|
+
|
82
82
|
def container(starter, ender)
|
83
83
|
out(starter)
|
84
84
|
yield
|
85
85
|
out(ender)
|
86
86
|
end
|
87
|
-
|
87
|
+
|
88
88
|
def plain
|
89
89
|
old_in_plain = @in_plain
|
90
90
|
@in_plain = true
|
91
91
|
yield
|
92
92
|
@in_plain = old_in_plain
|
93
93
|
end
|
94
|
-
|
94
|
+
|
95
95
|
private
|
96
|
-
|
96
|
+
|
97
97
|
def escape_href(str)
|
98
98
|
@node.html_escape_href(str)
|
99
99
|
end
|
100
|
-
|
100
|
+
|
101
101
|
def escape_html(str)
|
102
102
|
@node.html_escape_html(str)
|
103
103
|
end
|
104
|
-
|
104
|
+
|
105
105
|
def tagfilter(str)
|
106
106
|
if @tagfilter
|
107
107
|
str.gsub(
|
@@ -119,15 +119,15 @@ module Markly
|
|
119
119
|
str
|
120
120
|
end
|
121
121
|
end
|
122
|
-
|
122
|
+
|
123
123
|
def source_position(node)
|
124
|
-
return
|
125
|
-
|
124
|
+
return "" unless flag_enabled?(SOURCE_POSITION)
|
125
|
+
|
126
126
|
s = node.source_position
|
127
127
|
" data-sourcepos=\"#{s[:start_line]}:#{s[:start_column]}-" \
|
128
128
|
"#{s[:end_line]}:#{s[:end_column]}\""
|
129
129
|
end
|
130
|
-
|
130
|
+
|
131
131
|
def flag_enabled?(flag)
|
132
132
|
(@flags & flag) != 0
|
133
133
|
end
|
data/lib/markly/renderer/html.rb
CHANGED
@@ -6,10 +6,10 @@
|
|
6
6
|
# Copyright, 2017, by Yuki Izumi.
|
7
7
|
# Copyright, 2017-2019, by Ashe Connor.
|
8
8
|
# Copyright, 2018, by Michael Camilleri.
|
9
|
-
# Copyright, 2020-
|
9
|
+
# Copyright, 2020-2025, by Samuel Williams.
|
10
10
|
|
11
|
-
require_relative
|
12
|
-
require
|
11
|
+
require_relative "generic"
|
12
|
+
require "cgi"
|
13
13
|
|
14
14
|
module Markly
|
15
15
|
module Renderer
|
@@ -30,51 +30,75 @@ module Markly
|
|
30
30
|
out("</ol>\n</section>\n") if @written_footnote_ix
|
31
31
|
out("</section>") if @section
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
def id_for(node)
|
35
35
|
if @ids
|
36
|
-
|
37
|
-
|
38
|
-
return " id=\"#{CGI.escape_html id}\""
|
36
|
+
anchor = self.class.anchor_for(node)
|
37
|
+
return " id=\"#{CGI.escape_html anchor}\""
|
39
38
|
end
|
40
39
|
end
|
41
|
-
|
40
|
+
|
41
|
+
def self.anchor_for(node)
|
42
|
+
# Convert to plaintext, strip trailing whitespace, convert to lowercase
|
43
|
+
text = node.to_plaintext.chomp.downcase
|
44
|
+
|
45
|
+
# Replace sequences of whitespace with hyphens
|
46
|
+
text = text.gsub(/\s+/, "-")
|
47
|
+
|
48
|
+
# Replace periods with hyphens (useful for version numbers like v1.0.0 → v1-0-0)
|
49
|
+
text = text.gsub(/\./, "-")
|
50
|
+
|
51
|
+
# Remove characters that are not URL-safe for anchors
|
52
|
+
# Keep: letters, numbers, hyphens, underscores
|
53
|
+
# Remove: punctuation, special characters, symbols
|
54
|
+
text = text.gsub(/[^\w\-]/, "")
|
55
|
+
|
56
|
+
# Remove leading/trailing hyphens and collapse multiple hyphens
|
57
|
+
text = text.gsub(/^-+|-+$/, "").gsub(/-+/, "-")
|
58
|
+
|
59
|
+
text
|
60
|
+
end
|
61
|
+
|
62
|
+
def anchor_for(node)
|
63
|
+
self.class.anchor_for(node)
|
64
|
+
end
|
65
|
+
|
42
66
|
def header(node)
|
43
67
|
block do
|
44
68
|
if @ids
|
45
|
-
out(
|
69
|
+
out("</section>") if @section
|
46
70
|
@section = true
|
47
71
|
out("<section#{id_for(node)}>")
|
48
72
|
end
|
49
73
|
|
50
|
-
out(
|
51
|
-
|
74
|
+
out("<h", node.header_level, "#{source_position(node)}>", :children,
|
75
|
+
"</h", node.header_level, ">")
|
52
76
|
end
|
53
77
|
end
|
54
|
-
|
78
|
+
|
55
79
|
def paragraph(node)
|
56
80
|
if @tight && node.parent.type != :blockquote
|
57
81
|
out(:children)
|
58
82
|
else
|
59
83
|
block do
|
60
|
-
container("<p#{source_position(node)}>",
|
84
|
+
container("<p#{source_position(node)}>", "</p>") do
|
61
85
|
out(:children)
|
62
86
|
if node.parent.type == :footnote_definition && node.next.nil?
|
63
|
-
out(
|
87
|
+
out(" ")
|
64
88
|
out_footnote_backref
|
65
89
|
end
|
66
90
|
end
|
67
91
|
end
|
68
92
|
end
|
69
93
|
end
|
70
|
-
|
94
|
+
|
71
95
|
def list(node)
|
72
96
|
old_tight = @tight
|
73
97
|
@tight = node.list_tight
|
74
|
-
|
98
|
+
|
75
99
|
block do
|
76
100
|
if node.list_type == :bullet_list
|
77
|
-
container("<ul#{source_position(node)}>\n",
|
101
|
+
container("<ul#{source_position(node)}>\n", "</ul>") do
|
78
102
|
out(:children)
|
79
103
|
end
|
80
104
|
else
|
@@ -83,27 +107,27 @@ module Markly
|
|
83
107
|
else
|
84
108
|
"<ol start=\"#{node.list_start}\"#{source_position(node)}>\n"
|
85
109
|
end
|
86
|
-
container(start,
|
110
|
+
container(start, "</ol>") do
|
87
111
|
out(:children)
|
88
112
|
end
|
89
113
|
end
|
90
114
|
end
|
91
|
-
|
115
|
+
|
92
116
|
@tight = old_tight
|
93
117
|
end
|
94
|
-
|
118
|
+
|
95
119
|
def list_item(node)
|
96
120
|
block do
|
97
121
|
tasklist_data = tasklist(node)
|
98
|
-
container("<li#{source_position(node)}#{tasklist_data}>#{' ' if tasklist?(node)}",
|
122
|
+
container("<li#{source_position(node)}#{tasklist_data}>#{' ' if tasklist?(node)}", "</li>") do
|
99
123
|
out(:children)
|
100
124
|
end
|
101
125
|
end
|
102
126
|
end
|
103
|
-
|
127
|
+
|
104
128
|
def tasklist(node)
|
105
|
-
return
|
106
|
-
|
129
|
+
return "" unless tasklist?(node)
|
130
|
+
|
107
131
|
state = if checked?(node)
|
108
132
|
'checked="" disabled=""'
|
109
133
|
else
|
@@ -111,109 +135,109 @@ module Markly
|
|
111
135
|
end
|
112
136
|
"><input type=\"checkbox\" #{state} /"
|
113
137
|
end
|
114
|
-
|
138
|
+
|
115
139
|
def blockquote(node)
|
116
140
|
block do
|
117
|
-
container("<blockquote#{source_position(node)}>\n",
|
141
|
+
container("<blockquote#{source_position(node)}>\n", "</blockquote>") do
|
118
142
|
out(:children)
|
119
143
|
end
|
120
144
|
end
|
121
145
|
end
|
122
|
-
|
146
|
+
|
123
147
|
def hrule(node)
|
124
148
|
block do
|
125
149
|
out("<hr#{source_position(node)} />")
|
126
150
|
end
|
127
151
|
end
|
128
|
-
|
152
|
+
|
129
153
|
def code_block(node)
|
130
154
|
block do
|
131
155
|
if flag_enabled?(GITHUB_PRE_LANG)
|
132
156
|
out("<pre#{source_position(node)}")
|
133
157
|
out(' lang="', node.fence_info.split(/\s+/)[0], '"') if node.fence_info && !node.fence_info.empty?
|
134
|
-
out(
|
158
|
+
out("><code>")
|
135
159
|
else
|
136
160
|
out("<pre#{source_position(node)}><code")
|
137
161
|
if node.fence_info && !node.fence_info.empty?
|
138
162
|
out(' class="language-', node.fence_info.split(/\s+/)[0], '">')
|
139
163
|
else
|
140
|
-
out(
|
164
|
+
out(">")
|
141
165
|
end
|
142
166
|
end
|
143
167
|
out(escape_html(node.string_content))
|
144
|
-
out(
|
168
|
+
out("</code></pre>")
|
145
169
|
end
|
146
170
|
end
|
147
|
-
|
171
|
+
|
148
172
|
def html(node)
|
149
173
|
block do
|
150
174
|
if flag_enabled?(UNSAFE)
|
151
175
|
out(tagfilter(node.string_content))
|
152
176
|
else
|
153
|
-
out(
|
177
|
+
out("<!-- raw HTML omitted -->")
|
154
178
|
end
|
155
179
|
end
|
156
180
|
end
|
157
|
-
|
181
|
+
|
158
182
|
def inline_html(node)
|
159
183
|
if flag_enabled?(UNSAFE)
|
160
184
|
out(tagfilter(node.string_content))
|
161
185
|
else
|
162
|
-
out(
|
186
|
+
out("<!-- raw HTML omitted -->")
|
163
187
|
end
|
164
188
|
end
|
165
|
-
|
189
|
+
|
166
190
|
def emph(node)
|
167
|
-
out(
|
191
|
+
out("<em>", :children, "</em>")
|
168
192
|
end
|
169
|
-
|
193
|
+
|
170
194
|
def strong(node)
|
171
195
|
if node.parent.nil? || node.parent.type == node.type
|
172
196
|
out(:children)
|
173
197
|
else
|
174
|
-
out(
|
198
|
+
out("<strong>", :children, "</strong>")
|
175
199
|
end
|
176
200
|
end
|
177
|
-
|
201
|
+
|
178
202
|
def link(node)
|
179
|
-
out('<a href="', node.url.nil? ?
|
203
|
+
out('<a href="', node.url.nil? ? "" : escape_href(node.url), '"')
|
180
204
|
out(' title="', escape_html(node.title), '"') if node.title && !node.title.empty?
|
181
|
-
out(
|
205
|
+
out(">", :children, "</a>")
|
182
206
|
end
|
183
|
-
|
207
|
+
|
184
208
|
def image(node)
|
185
209
|
out('<img src="', escape_href(node.url), '"')
|
186
210
|
plain do
|
187
211
|
out(' alt="', :children, '"')
|
188
212
|
end
|
189
213
|
out(' title="', escape_html(node.title), '"') if node.title && !node.title.empty?
|
190
|
-
out(
|
214
|
+
out(" />")
|
191
215
|
end
|
192
|
-
|
216
|
+
|
193
217
|
def text(node)
|
194
218
|
out(escape_html(node.string_content))
|
195
219
|
end
|
196
|
-
|
220
|
+
|
197
221
|
def code(node)
|
198
|
-
out(
|
222
|
+
out("<code>")
|
199
223
|
out(escape_html(node.string_content))
|
200
|
-
out(
|
224
|
+
out("</code>")
|
201
225
|
end
|
202
|
-
|
226
|
+
|
203
227
|
def linebreak(_node)
|
204
228
|
out("<br />\n")
|
205
229
|
end
|
206
|
-
|
230
|
+
|
207
231
|
def softbreak(_)
|
208
232
|
if flag_enabled?(HARD_BREAKS)
|
209
233
|
out("<br />\n")
|
210
234
|
elsif flag_enabled?(NO_BREAKS)
|
211
|
-
out(
|
235
|
+
out(" ")
|
212
236
|
else
|
213
237
|
out("\n")
|
214
238
|
end
|
215
239
|
end
|
216
|
-
|
240
|
+
|
217
241
|
def table(node)
|
218
242
|
@alignments = node.table_alignments
|
219
243
|
@needs_close_tbody = false
|
@@ -221,15 +245,15 @@ module Markly
|
|
221
245
|
out("</tbody>\n") if @needs_close_tbody
|
222
246
|
out("</table>\n")
|
223
247
|
end
|
224
|
-
|
248
|
+
|
225
249
|
def table_header(node)
|
226
250
|
@column_index = 0
|
227
|
-
|
251
|
+
|
228
252
|
@in_header = true
|
229
253
|
out("<thead>\n<tr#{source_position(node)}>\n", :children, "</tr>\n</thead>\n")
|
230
254
|
@in_header = false
|
231
255
|
end
|
232
|
-
|
256
|
+
|
233
257
|
def table_row(node)
|
234
258
|
@column_index = 0
|
235
259
|
if !@in_header && !@needs_close_tbody
|
@@ -238,36 +262,36 @@ module Markly
|
|
238
262
|
end
|
239
263
|
out("<tr#{source_position(node)}>\n", :children, "</tr>\n")
|
240
264
|
end
|
241
|
-
|
265
|
+
|
242
266
|
TABLE_CELL_ALIGNMENT = {
|
243
267
|
left: ' align="left"',
|
244
268
|
right: ' align="right"',
|
245
269
|
center: ' align="center"'
|
246
270
|
}.freeze
|
247
|
-
|
271
|
+
|
248
272
|
def table_cell(node)
|
249
|
-
align = TABLE_CELL_ALIGNMENT.fetch(@alignments[@column_index],
|
273
|
+
align = TABLE_CELL_ALIGNMENT.fetch(@alignments[@column_index], "")
|
250
274
|
out(@in_header ? "<th#{align}#{source_position(node)}>" : "<td#{align}#{source_position(node)}>", :children, @in_header ? "</th>\n" : "</td>\n")
|
251
275
|
@column_index += 1
|
252
276
|
end
|
253
|
-
|
277
|
+
|
254
278
|
def strikethrough(_)
|
255
|
-
out(
|
279
|
+
out("<del>", :children, "</del>")
|
256
280
|
end
|
257
|
-
|
281
|
+
|
258
282
|
def footnote_reference(node)
|
259
283
|
label = node.parent_footnote_def.string_content
|
260
284
|
|
261
285
|
out("<sup class=\"footnote-ref\"><a href=\"#fn-#{label}\" id=\"fnref-#{label}\" data-footnote-ref>#{node.string_content}</a></sup>")
|
262
286
|
# out(node.to_html)
|
263
287
|
end
|
264
|
-
|
288
|
+
|
265
289
|
def footnote_definition(node)
|
266
290
|
unless @footnote_ix
|
267
291
|
out("<section class=\"footnotes\" data-footnotes>\n<ol>\n")
|
268
292
|
@footnote_ix = 0
|
269
293
|
end
|
270
|
-
|
294
|
+
|
271
295
|
@footnote_ix += 1
|
272
296
|
label = node.string_content
|
273
297
|
@footnotes[@footnote_ix] = label
|
@@ -278,22 +302,22 @@ module Markly
|
|
278
302
|
# </ol>
|
279
303
|
# </section>
|
280
304
|
end
|
281
|
-
|
305
|
+
|
282
306
|
private
|
283
|
-
|
307
|
+
|
284
308
|
def out_footnote_backref
|
285
309
|
return false if @written_footnote_ix == @footnote_ix
|
286
|
-
|
310
|
+
|
287
311
|
@written_footnote_ix = @footnote_ix
|
288
|
-
|
312
|
+
|
289
313
|
out("<a href=\"#fnref-#{@footnotes[@footnote_ix]}\" class=\"footnote-backref\" data-footnote-backref data-footnote-backref-idx=\"#{@footnote_ix}\" aria-label=\"Back to reference #{@footnote_ix}\">↩</a>")
|
290
314
|
true
|
291
315
|
end
|
292
|
-
|
316
|
+
|
293
317
|
def tasklist?(node)
|
294
|
-
node.type_string ==
|
318
|
+
node.type_string == "tasklist"
|
295
319
|
end
|
296
|
-
|
320
|
+
|
297
321
|
def checked?(node)
|
298
322
|
node.tasklist_item_checked?
|
299
323
|
end
|
data/lib/markly/version.rb
CHANGED
@@ -4,8 +4,8 @@
|
|
4
4
|
# Copyright, 2015-2020, by Garen Torikian.
|
5
5
|
# Copyright, 2016-2017, by Yuki Izumi.
|
6
6
|
# Copyright, 2017-2018, by Ashe Connor.
|
7
|
-
# Copyright, 2020-
|
7
|
+
# Copyright, 2020-2025, by Samuel Williams.
|
8
8
|
|
9
9
|
module Markly
|
10
|
-
VERSION =
|
10
|
+
VERSION = "0.14.0"
|
11
11
|
end
|
data/lib/markly.rb
CHANGED
@@ -6,15 +6,15 @@
|
|
6
6
|
# Copyright, 2015-2019, by Garen Torikian.
|
7
7
|
# Copyright, 2015, by Nick Wellnhofer.
|
8
8
|
# Copyright, 2016-2017, by Yuki Izumi.
|
9
|
-
# Copyright, 2020-
|
9
|
+
# Copyright, 2020-2025, by Samuel Williams.
|
10
10
|
|
11
|
-
require
|
11
|
+
require "markly/markly"
|
12
12
|
|
13
|
-
require_relative
|
14
|
-
require_relative
|
15
|
-
require_relative
|
13
|
+
require_relative "markly/flags"
|
14
|
+
require_relative "markly/node"
|
15
|
+
require_relative "markly/renderer/html"
|
16
16
|
|
17
|
-
require_relative
|
17
|
+
require_relative "markly/version"
|
18
18
|
|
19
19
|
module Markly
|
20
20
|
# Public: Parses a Markdown string into a `document` node.
|
data/license.md
CHANGED
@@ -18,7 +18,7 @@ Copyright, 2018, by Danny Iachini.
|
|
18
18
|
Copyright, 2019-2020, by Tomoya Chiba.
|
19
19
|
Copyright, 2019, by Brett Walker.
|
20
20
|
Copyright, 2020, by Olle Jonsson.
|
21
|
-
Copyright, 2020-
|
21
|
+
Copyright, 2020-2025, by Samuel Williams.
|
22
22
|
Copyright, 2024, by Ross Kaffenberger.
|
23
23
|
|
24
24
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
data/readme.md
CHANGED
@@ -18,11 +18,17 @@ functionality, and so this fork was created to continue to provide these (and mo
|
|
18
18
|
|
19
19
|
Please see the [project documentation](https://ioquatix.github.io/markly/) for more details.
|
20
20
|
|
21
|
-
- [Getting Started](https://ioquatix.github.io/markly/guides/getting-started/index) - This guide explains now to
|
22
|
-
install and use Markly.
|
21
|
+
- [Getting Started](https://ioquatix.github.io/markly/guides/getting-started/index) - This guide explains now to install and use Markly.
|
23
22
|
|
24
|
-
- [Abstract Syntax Tree](https://ioquatix.github.io/markly/guides/abstract-syntax-tree/index) - This guide explains
|
25
|
-
|
23
|
+
- [Abstract Syntax Tree](https://ioquatix.github.io/markly/guides/abstract-syntax-tree/index) - This guide explains how to use Markly's abstract syntax tree (AST) to parse and manipulate Markdown documents.
|
24
|
+
|
25
|
+
## Releases
|
26
|
+
|
27
|
+
Please see the [project releases](https://ioquatix.github.io/markly/releases/index) for all releases.
|
28
|
+
|
29
|
+
### v0.14.0
|
30
|
+
|
31
|
+
- Expose `Markly::Renderer::HTML.anchor_for` method to generate URL-safe anchors from headers.
|
26
32
|
|
27
33
|
## Contributing
|
28
34
|
|
data/releases.md
ADDED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: markly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garen Torikian
|
@@ -142,6 +142,7 @@ files:
|
|
142
142
|
- lib/markly/version.rb
|
143
143
|
- license.md
|
144
144
|
- readme.md
|
145
|
+
- releases.md
|
145
146
|
homepage: https://github.com/ioquatix/markly
|
146
147
|
licenses:
|
147
148
|
- MIT
|
@@ -156,14 +157,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
156
157
|
requirements:
|
157
158
|
- - ">="
|
158
159
|
- !ruby/object:Gem::Version
|
159
|
-
version: '3.
|
160
|
+
version: '3.2'
|
160
161
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
162
|
requirements:
|
162
163
|
- - ">="
|
163
164
|
- !ruby/object:Gem::Version
|
164
165
|
version: '0'
|
165
166
|
requirements: []
|
166
|
-
rubygems_version: 3.6.
|
167
|
+
rubygems_version: 3.6.9
|
167
168
|
specification_version: 4
|
168
169
|
summary: CommonMark parser and renderer. Written in C, wrapped in Ruby.
|
169
170
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|