markly 0.13.1 → 0.14.1
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 +83 -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: 7eb58c81c8fca95217e5a1469baf3034785126d6ff42e9929a7d074e358b9508
|
4
|
+
data.tar.gz: f28760fe0280ce1ab132d7ec639584284dde3ba8077e68f2cd3617715d1211cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ded6fff6a6355a8e78b2daa19a1581d982a35ddbcbddc38efe25d1866e9ce6136ea6eea62c1638874ff9953546a176df11e6ce462c9131ab38648185dec50a7a
|
7
|
+
data.tar.gz: ccc6eb379235978b3a512dee8553a425ca456b01e9f60b10d16927ae1862cda069152fcc62a02a1a60d46b274a1c8aa760183a636c528b8cdc7fdf43a367abd8
|
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,64 @@ 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.gsub!(/\s+/, "-")
|
47
|
+
|
48
|
+
return text
|
49
|
+
end
|
50
|
+
|
51
|
+
def anchor_for(node)
|
52
|
+
self.class.anchor_for(node)
|
53
|
+
end
|
54
|
+
|
42
55
|
def header(node)
|
43
56
|
block do
|
44
57
|
if @ids
|
45
|
-
out(
|
58
|
+
out("</section>") if @section
|
46
59
|
@section = true
|
47
60
|
out("<section#{id_for(node)}>")
|
48
61
|
end
|
49
62
|
|
50
|
-
out(
|
51
|
-
|
63
|
+
out("<h", node.header_level, "#{source_position(node)}>", :children,
|
64
|
+
"</h", node.header_level, ">")
|
52
65
|
end
|
53
66
|
end
|
54
|
-
|
67
|
+
|
55
68
|
def paragraph(node)
|
56
69
|
if @tight && node.parent.type != :blockquote
|
57
70
|
out(:children)
|
58
71
|
else
|
59
72
|
block do
|
60
|
-
container("<p#{source_position(node)}>",
|
73
|
+
container("<p#{source_position(node)}>", "</p>") do
|
61
74
|
out(:children)
|
62
75
|
if node.parent.type == :footnote_definition && node.next.nil?
|
63
|
-
out(
|
76
|
+
out(" ")
|
64
77
|
out_footnote_backref
|
65
78
|
end
|
66
79
|
end
|
67
80
|
end
|
68
81
|
end
|
69
82
|
end
|
70
|
-
|
83
|
+
|
71
84
|
def list(node)
|
72
85
|
old_tight = @tight
|
73
86
|
@tight = node.list_tight
|
74
|
-
|
87
|
+
|
75
88
|
block do
|
76
89
|
if node.list_type == :bullet_list
|
77
|
-
container("<ul#{source_position(node)}>\n",
|
90
|
+
container("<ul#{source_position(node)}>\n", "</ul>") do
|
78
91
|
out(:children)
|
79
92
|
end
|
80
93
|
else
|
@@ -83,27 +96,27 @@ module Markly
|
|
83
96
|
else
|
84
97
|
"<ol start=\"#{node.list_start}\"#{source_position(node)}>\n"
|
85
98
|
end
|
86
|
-
container(start,
|
99
|
+
container(start, "</ol>") do
|
87
100
|
out(:children)
|
88
101
|
end
|
89
102
|
end
|
90
103
|
end
|
91
|
-
|
104
|
+
|
92
105
|
@tight = old_tight
|
93
106
|
end
|
94
|
-
|
107
|
+
|
95
108
|
def list_item(node)
|
96
109
|
block do
|
97
110
|
tasklist_data = tasklist(node)
|
98
|
-
container("<li#{source_position(node)}#{tasklist_data}>#{' ' if tasklist?(node)}",
|
111
|
+
container("<li#{source_position(node)}#{tasklist_data}>#{' ' if tasklist?(node)}", "</li>") do
|
99
112
|
out(:children)
|
100
113
|
end
|
101
114
|
end
|
102
115
|
end
|
103
|
-
|
116
|
+
|
104
117
|
def tasklist(node)
|
105
|
-
return
|
106
|
-
|
118
|
+
return "" unless tasklist?(node)
|
119
|
+
|
107
120
|
state = if checked?(node)
|
108
121
|
'checked="" disabled=""'
|
109
122
|
else
|
@@ -111,109 +124,109 @@ module Markly
|
|
111
124
|
end
|
112
125
|
"><input type=\"checkbox\" #{state} /"
|
113
126
|
end
|
114
|
-
|
127
|
+
|
115
128
|
def blockquote(node)
|
116
129
|
block do
|
117
|
-
container("<blockquote#{source_position(node)}>\n",
|
130
|
+
container("<blockquote#{source_position(node)}>\n", "</blockquote>") do
|
118
131
|
out(:children)
|
119
132
|
end
|
120
133
|
end
|
121
134
|
end
|
122
|
-
|
135
|
+
|
123
136
|
def hrule(node)
|
124
137
|
block do
|
125
138
|
out("<hr#{source_position(node)} />")
|
126
139
|
end
|
127
140
|
end
|
128
|
-
|
141
|
+
|
129
142
|
def code_block(node)
|
130
143
|
block do
|
131
144
|
if flag_enabled?(GITHUB_PRE_LANG)
|
132
145
|
out("<pre#{source_position(node)}")
|
133
146
|
out(' lang="', node.fence_info.split(/\s+/)[0], '"') if node.fence_info && !node.fence_info.empty?
|
134
|
-
out(
|
147
|
+
out("><code>")
|
135
148
|
else
|
136
149
|
out("<pre#{source_position(node)}><code")
|
137
150
|
if node.fence_info && !node.fence_info.empty?
|
138
151
|
out(' class="language-', node.fence_info.split(/\s+/)[0], '">')
|
139
152
|
else
|
140
|
-
out(
|
153
|
+
out(">")
|
141
154
|
end
|
142
155
|
end
|
143
156
|
out(escape_html(node.string_content))
|
144
|
-
out(
|
157
|
+
out("</code></pre>")
|
145
158
|
end
|
146
159
|
end
|
147
|
-
|
160
|
+
|
148
161
|
def html(node)
|
149
162
|
block do
|
150
163
|
if flag_enabled?(UNSAFE)
|
151
164
|
out(tagfilter(node.string_content))
|
152
165
|
else
|
153
|
-
out(
|
166
|
+
out("<!-- raw HTML omitted -->")
|
154
167
|
end
|
155
168
|
end
|
156
169
|
end
|
157
|
-
|
170
|
+
|
158
171
|
def inline_html(node)
|
159
172
|
if flag_enabled?(UNSAFE)
|
160
173
|
out(tagfilter(node.string_content))
|
161
174
|
else
|
162
|
-
out(
|
175
|
+
out("<!-- raw HTML omitted -->")
|
163
176
|
end
|
164
177
|
end
|
165
|
-
|
178
|
+
|
166
179
|
def emph(node)
|
167
|
-
out(
|
180
|
+
out("<em>", :children, "</em>")
|
168
181
|
end
|
169
|
-
|
182
|
+
|
170
183
|
def strong(node)
|
171
184
|
if node.parent.nil? || node.parent.type == node.type
|
172
185
|
out(:children)
|
173
186
|
else
|
174
|
-
out(
|
187
|
+
out("<strong>", :children, "</strong>")
|
175
188
|
end
|
176
189
|
end
|
177
|
-
|
190
|
+
|
178
191
|
def link(node)
|
179
|
-
out('<a href="', node.url.nil? ?
|
192
|
+
out('<a href="', node.url.nil? ? "" : escape_href(node.url), '"')
|
180
193
|
out(' title="', escape_html(node.title), '"') if node.title && !node.title.empty?
|
181
|
-
out(
|
194
|
+
out(">", :children, "</a>")
|
182
195
|
end
|
183
|
-
|
196
|
+
|
184
197
|
def image(node)
|
185
198
|
out('<img src="', escape_href(node.url), '"')
|
186
199
|
plain do
|
187
200
|
out(' alt="', :children, '"')
|
188
201
|
end
|
189
202
|
out(' title="', escape_html(node.title), '"') if node.title && !node.title.empty?
|
190
|
-
out(
|
203
|
+
out(" />")
|
191
204
|
end
|
192
|
-
|
205
|
+
|
193
206
|
def text(node)
|
194
207
|
out(escape_html(node.string_content))
|
195
208
|
end
|
196
|
-
|
209
|
+
|
197
210
|
def code(node)
|
198
|
-
out(
|
211
|
+
out("<code>")
|
199
212
|
out(escape_html(node.string_content))
|
200
|
-
out(
|
213
|
+
out("</code>")
|
201
214
|
end
|
202
|
-
|
215
|
+
|
203
216
|
def linebreak(_node)
|
204
217
|
out("<br />\n")
|
205
218
|
end
|
206
|
-
|
219
|
+
|
207
220
|
def softbreak(_)
|
208
221
|
if flag_enabled?(HARD_BREAKS)
|
209
222
|
out("<br />\n")
|
210
223
|
elsif flag_enabled?(NO_BREAKS)
|
211
|
-
out(
|
224
|
+
out(" ")
|
212
225
|
else
|
213
226
|
out("\n")
|
214
227
|
end
|
215
228
|
end
|
216
|
-
|
229
|
+
|
217
230
|
def table(node)
|
218
231
|
@alignments = node.table_alignments
|
219
232
|
@needs_close_tbody = false
|
@@ -221,15 +234,15 @@ module Markly
|
|
221
234
|
out("</tbody>\n") if @needs_close_tbody
|
222
235
|
out("</table>\n")
|
223
236
|
end
|
224
|
-
|
237
|
+
|
225
238
|
def table_header(node)
|
226
239
|
@column_index = 0
|
227
|
-
|
240
|
+
|
228
241
|
@in_header = true
|
229
242
|
out("<thead>\n<tr#{source_position(node)}>\n", :children, "</tr>\n</thead>\n")
|
230
243
|
@in_header = false
|
231
244
|
end
|
232
|
-
|
245
|
+
|
233
246
|
def table_row(node)
|
234
247
|
@column_index = 0
|
235
248
|
if !@in_header && !@needs_close_tbody
|
@@ -238,36 +251,36 @@ module Markly
|
|
238
251
|
end
|
239
252
|
out("<tr#{source_position(node)}>\n", :children, "</tr>\n")
|
240
253
|
end
|
241
|
-
|
254
|
+
|
242
255
|
TABLE_CELL_ALIGNMENT = {
|
243
256
|
left: ' align="left"',
|
244
257
|
right: ' align="right"',
|
245
258
|
center: ' align="center"'
|
246
259
|
}.freeze
|
247
|
-
|
260
|
+
|
248
261
|
def table_cell(node)
|
249
|
-
align = TABLE_CELL_ALIGNMENT.fetch(@alignments[@column_index],
|
262
|
+
align = TABLE_CELL_ALIGNMENT.fetch(@alignments[@column_index], "")
|
250
263
|
out(@in_header ? "<th#{align}#{source_position(node)}>" : "<td#{align}#{source_position(node)}>", :children, @in_header ? "</th>\n" : "</td>\n")
|
251
264
|
@column_index += 1
|
252
265
|
end
|
253
|
-
|
266
|
+
|
254
267
|
def strikethrough(_)
|
255
|
-
out(
|
268
|
+
out("<del>", :children, "</del>")
|
256
269
|
end
|
257
|
-
|
270
|
+
|
258
271
|
def footnote_reference(node)
|
259
272
|
label = node.parent_footnote_def.string_content
|
260
273
|
|
261
274
|
out("<sup class=\"footnote-ref\"><a href=\"#fn-#{label}\" id=\"fnref-#{label}\" data-footnote-ref>#{node.string_content}</a></sup>")
|
262
275
|
# out(node.to_html)
|
263
276
|
end
|
264
|
-
|
277
|
+
|
265
278
|
def footnote_definition(node)
|
266
279
|
unless @footnote_ix
|
267
280
|
out("<section class=\"footnotes\" data-footnotes>\n<ol>\n")
|
268
281
|
@footnote_ix = 0
|
269
282
|
end
|
270
|
-
|
283
|
+
|
271
284
|
@footnote_ix += 1
|
272
285
|
label = node.string_content
|
273
286
|
@footnotes[@footnote_ix] = label
|
@@ -278,22 +291,22 @@ module Markly
|
|
278
291
|
# </ol>
|
279
292
|
# </section>
|
280
293
|
end
|
281
|
-
|
294
|
+
|
282
295
|
private
|
283
|
-
|
296
|
+
|
284
297
|
def out_footnote_backref
|
285
298
|
return false if @written_footnote_ix == @footnote_ix
|
286
|
-
|
299
|
+
|
287
300
|
@written_footnote_ix = @footnote_ix
|
288
|
-
|
301
|
+
|
289
302
|
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
303
|
true
|
291
304
|
end
|
292
|
-
|
305
|
+
|
293
306
|
def tasklist?(node)
|
294
|
-
node.type_string ==
|
307
|
+
node.type_string == "tasklist"
|
295
308
|
end
|
296
|
-
|
309
|
+
|
297
310
|
def checked?(node)
|
298
311
|
node.tasklist_item_checked?
|
299
312
|
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.1"
|
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.1
|
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
|