markly 0.1.0 → 0.2.0

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: 3121bb14bcb09883bfb84879b6b69e28d47e3781f0bcd6225737734040ac2ec5
4
- data.tar.gz: 2f47e7add1ee43c03e7b75b45e5f2c7ec2c322cac842aa5f5bdb8e539fbca8d5
3
+ metadata.gz: 93a192bb4cf0e216365ffa17fc619ecc726cb7cbd9a3661ae3357ce5a8dbb1c4
4
+ data.tar.gz: ec39190db7ad173cdbbcddd73850fc07faa578d37892217cedd329efad060610
5
5
  SHA512:
6
- metadata.gz: 6da8e6ef6f672489b7bcd4b6e378c86d3240e4b3f9d67aaba26bbe5414a363c4a071be3695bca85bb9658c0213cf1e59d32edb389b5ec8a0aebd9689a8245ff7
7
- data.tar.gz: ce28eac1fcca2c0dfc6e637ca937e16ffbb211d4d64c596f3869b56860fb04227b20065c86a5d335cb8d11cdd49c1e924a09b0caa0b515e404e123420ed39e7d
6
+ metadata.gz: 5668b9796316e769f73a6d97c495116e3361b9cc0a12fa92c8ec35461954a63d7568e8975af4720d060605ccb2ecdcc96bf123da2074271216a2e55e3afa378d
7
+ data.tar.gz: 132e25acaad81e6953c4c25a206dc6e37ba0f2cff3176887fb81882817edd81fa6c2a8eb24cf274046635b30f1179832f2daeb00ec78e18f4afb537166e4aab7
@@ -262,6 +262,21 @@ static VALUE rb_node_new(VALUE self, VALUE type) {
262
262
  return rb_Markly_Node_wrap(node);
263
263
  }
264
264
 
265
+ static VALUE rb_node_replace(VALUE self, VALUE other) {
266
+ cmark_node *current_node = NULL, *replacement_node = NULL;
267
+
268
+ TypedData_Get_Struct(self, cmark_node, &rb_Markly_Node_Type, current_node);
269
+ TypedData_Get_Struct(other, cmark_node, &rb_Markly_Node_Type, replacement_node);
270
+
271
+ int result = cmark_node_replace(current_node, replacement_node);
272
+
273
+ if (result == 0) {
274
+ rb_raise(rb_Markly_Error, "could not replace node");
275
+ }
276
+
277
+ return other;
278
+ }
279
+
265
280
  static VALUE encode_utf8_string(const char *c_string) {
266
281
  VALUE string = rb_str_new2(c_string);
267
282
  int enc = rb_enc_find_index("UTF-8");
@@ -1182,6 +1197,9 @@ __attribute__((visibility("default"))) void Init_markly() {
1182
1197
 
1183
1198
  rb_Markly_Node = rb_define_class_under(rb_Markly, "Node", rb_cObject);
1184
1199
  rb_define_singleton_method(rb_Markly_Node, "new", rb_node_new, 1);
1200
+
1201
+ rb_define_method(rb_Markly_Node, "replace", rb_node_replace, 1);
1202
+
1185
1203
  rb_define_method(rb_Markly_Node, "string_content", rb_node_get_string_content, 0);
1186
1204
  rb_define_method(rb_Markly_Node, "string_content=", rb_node_set_string_content, 1);
1187
1205
  rb_define_method(rb_Markly_Node, "type", rb_node_get_type, 0);
@@ -39,6 +39,8 @@ module Markly
39
39
  _render_commonmark(flags, width).force_encoding('utf-8')
40
40
  end
41
41
 
42
+ alias to_markdown to_commonmark
43
+
42
44
  # Public: Convert the node to a plain text string.
43
45
  #
44
46
  # options - A {Symbol} or {Array of Symbol}s indicating the render options
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Markly
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
5
5
  end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen Torikian
8
8
  - Ashe Connor
9
9
  - Samuel Williams
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-05-24 00:00:00.000000000 Z
13
+ date: 2020-06-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bake
@@ -96,8 +96,8 @@ dependencies:
96
96
  - - "~>"
97
97
  - !ruby/object:Gem::Version
98
98
  version: '0.9'
99
- description:
100
- email:
99
+ description:
100
+ email:
101
101
  executables:
102
102
  - markly
103
103
  extensions:
@@ -189,7 +189,7 @@ licenses:
189
189
  - MIT
190
190
  metadata:
191
191
  funding_uri: https://github.com/sponsors/ioquatix/
192
- post_install_message:
192
+ post_install_message:
193
193
  rdoc_options: []
194
194
  require_paths:
195
195
  - lib
@@ -205,7 +205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
205
205
  version: '0'
206
206
  requirements: []
207
207
  rubygems_version: 3.1.2
208
- signing_key:
208
+ signing_key:
209
209
  specification_version: 4
210
210
  summary: CommonMark parser and renderer. Written in C, wrapped in Ruby.
211
211
  test_files: []