markly 0.2.2 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 955e2db3a2000c5172b062923678f0eaaca4b509a6141289dc3173681942b299
4
- data.tar.gz: 69b8c19e5e15d4c8596ccebd40a8cbbb491cefc7a1b8a1649711e635b9ec7af3
3
+ metadata.gz: 4da10bf65ae4145aa5ebb31764dd2316d3046edfd4fd943768b0a10792a25c59
4
+ data.tar.gz: db4ee042070865bbf43283fb51710728dd35df9bc503c72a9f31bad3de4bfe55
5
5
  SHA512:
6
- metadata.gz: e1401692edab6e63a114894fabbca6b95a5af6c2a50583bfcd858a85ac16622d1442324f3df2dc412e084b11869001afd3b5feedb2ba75a2e5c9c9762540ef76
7
- data.tar.gz: e484546eae62ca19662b5853c5d1fe2356843a52e82568c00391e0f5aed954345d4eacea6478d3481757b83e95d3c31c541880f47cb001f95a468cbc6751f3b2
6
+ metadata.gz: be0c0d657e2e6b4d26f89b9c03f042aa0661e88cb295b76f518888fd2e490e55f58ef3b7292090c5a25d23027d6b370b9a582acb68ff4b326f1c784a90b0d5bc
7
+ data.tar.gz: 5cf044c518969df725a5822eb7974477d480926fa97d8b4bff71e2b628e70faa99107e60adadeef3377e157bac6d2ee200f9c6ede02da0beaff4c16a1929b5b3
@@ -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 << ' -std=c99'
6
+ $CFLAGS << " -O3 -std=c99"
6
7
 
7
- create_makefile('markly/markly')
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))
@@ -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
 
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
- out('<h', node.header_level, "#{id_for(node)}#{source_position(node)}>", :children,
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Markly
4
- VERSION = '0.2.2'
4
+ VERSION = '0.5.2'
5
5
  end
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.2.2
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-06-17 00:00:00.000000000 Z
13
+ date: 2020-08-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bake