markly 0.2.2 → 0.5.2
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
- data/ext/markly/extconf.rb +10 -2
- data/ext/markly/markly.c +6 -4
- data/lib/markly/markly.so +0 -0
- data/lib/markly/renderer/html_renderer.rb +13 -2
- data/lib/markly/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4da10bf65ae4145aa5ebb31764dd2316d3046edfd4fd943768b0a10792a25c59
|
4
|
+
data.tar.gz: db4ee042070865bbf43283fb51710728dd35df9bc503c72a9f31bad3de4bfe55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be0c0d657e2e6b4d26f89b9c03f042aa0661e88cb295b76f518888fd2e490e55f58ef3b7292090c5a25d23027d6b370b9a582acb68ff4b326f1c784a90b0d5bc
|
7
|
+
data.tar.gz: 5cf044c518969df725a5822eb7974477d480926fa97d8b4bff71e2b628e70faa99107e60adadeef3377e157bac6d2ee200f9c6ede02da0beaff4c16a1929b5b3
|
data/ext/markly/extconf.rb
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# Loads mkmf which is used to make makefiles for Ruby extensions
|
3
4
|
require 'mkmf'
|
4
5
|
|
5
|
-
$CFLAGS <<
|
6
|
+
$CFLAGS << " -O3 -std=c99"
|
6
7
|
|
7
|
-
|
8
|
+
gem_name = File.basename(__dir__)
|
9
|
+
extension_name = 'markly'
|
10
|
+
|
11
|
+
# The destination:
|
12
|
+
dir_config(extension_name)
|
13
|
+
|
14
|
+
# Generate the makefile to compile the native binary into `lib`:
|
15
|
+
create_makefile(File.join(gem_name, extension_name))
|
data/ext/markly/markly.c
CHANGED
@@ -47,6 +47,8 @@ static void rb_Markly_Node_free(void *data) {
|
|
47
47
|
|
48
48
|
if (cmark_node_parent(node) == NULL) {
|
49
49
|
cmark_node_free(node);
|
50
|
+
} else {
|
51
|
+
cmark_node_set_user_data(node, NULL);
|
50
52
|
}
|
51
53
|
}
|
52
54
|
}
|
@@ -329,10 +331,10 @@ static VALUE rb_node_set_string_content(VALUE self, VALUE s) {
|
|
329
331
|
* Returns a {Symbol} representing the node's type.
|
330
332
|
*/
|
331
333
|
static VALUE rb_node_get_type(VALUE self) {
|
332
|
-
int node_type;
|
333
|
-
cmark_node *node;
|
334
|
-
VALUE symbol;
|
335
|
-
const char *s;
|
334
|
+
int node_type = 0;
|
335
|
+
cmark_node *node = NULL;
|
336
|
+
VALUE symbol = Qnil;
|
337
|
+
const char *s = NULL;
|
336
338
|
|
337
339
|
TypedData_Get_Struct(self, cmark_node, &rb_Markly_Node_Type, node);
|
338
340
|
|
data/lib/markly/markly.so
CHANGED
Binary file
|
@@ -1,29 +1,40 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'cgi'
|
4
|
+
|
3
5
|
module Markly
|
4
6
|
class HTMLRenderer < Renderer
|
5
7
|
def initialize(ids: false, **options)
|
6
8
|
super(**options)
|
7
9
|
|
8
10
|
@ids = ids
|
11
|
+
@section = nil
|
9
12
|
end
|
10
13
|
|
11
14
|
def document(_)
|
15
|
+
@section = false
|
12
16
|
super
|
13
17
|
out("</ol>\n</section>\n") if @written_footnote_ix
|
18
|
+
out("</section>") if @section
|
14
19
|
end
|
15
20
|
|
16
21
|
def id_for(node)
|
17
22
|
if @ids
|
18
23
|
id = node.to_plaintext.chomp.downcase.gsub(/\s+/, '-')
|
19
24
|
|
20
|
-
return " id=\"#{id}\""
|
25
|
+
return " id=\"#{CGI.escape_html id}\""
|
21
26
|
end
|
22
27
|
end
|
23
28
|
|
24
29
|
def header(node)
|
25
30
|
block do
|
26
|
-
|
31
|
+
if @ids
|
32
|
+
out('</section>') if @section
|
33
|
+
@section = true
|
34
|
+
out("<section#{id_for(node)}>")
|
35
|
+
end
|
36
|
+
|
37
|
+
out('<h', node.header_level, "#{source_position(node)}>", :children,
|
27
38
|
'</h', node.header_level, '>')
|
28
39
|
end
|
29
40
|
end
|
data/lib/markly/version.rb
CHANGED
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.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garen Torikian
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2020-
|
13
|
+
date: 2020-08-02 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bake
|