rmultimarkdown 4.5.3.1 → 4.5.3.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
  SHA1:
3
- metadata.gz: 01eacdd7bad00819a2a4d15a640a771475a33678
4
- data.tar.gz: 84872c1f1f7979477f09f825d4cc8489c0054014
3
+ metadata.gz: d175433e6b773f208302634ae4a98fd19843a33a
4
+ data.tar.gz: 6196eef19a7bb5802a4a60b757557d83983cf6a8
5
5
  SHA512:
6
- metadata.gz: 2e28e39be1746d5c7bf6b097786ea9a177f507d1b54ed0f77a4b386e349ffcfb8f34ed3759d7f015764587b409e4be05309e57b71ba76cfb677aeff859c5b447
7
- data.tar.gz: 66c339a9513da6db084ceb048929a43f3324ce2bdc70ee1589ebc65fff1a6708e0fbc5e3aeb8add45311f1dbbda70eeb20caf2f6dbf3233798ce1e51c98761d1
6
+ metadata.gz: 94a12726d7a0e62191317902b33ae7076e1157c10176a3cba4e838c384ff00ee40e069d069dd505bd98f630a1b2474565c4ad3017816f4c90a461958146bdbf0
7
+ data.tar.gz: 18d9054243c74d3dafa979e77539cb587b9dddd554fe734d8d23fa578ba870be7ebe6940f79657163613cdeb5d724916a06fdda5cff7badba99e613249bc2410
@@ -1,9 +1,23 @@
1
1
  #include "ruby.h"
2
+ #include <ruby/encoding.h>
3
+
2
4
  #include "../MultiMarkdown-4/parser.h"
3
5
 
6
+ // Tries to convert a C string into an encoded ruby String
7
+ static VALUE encoded_str_new2(char *str, char *encoding) {
8
+ VALUE result = rb_str_new2(str);
9
+
10
+ int enc = rb_enc_find_index(encoding);
11
+ if (enc > 0) {
12
+ rb_enc_associate_index(result, enc);
13
+ }
14
+
15
+ return result;
16
+ }
17
+
4
18
  static VALUE rb_cMultiMarkdown;
5
19
 
6
- int get_exts(VALUE self) {
20
+ static int get_exts(VALUE self) {
7
21
  int extensions = 0;
8
22
  if (rb_funcall(self, rb_intern("smart"), 0) == Qtrue)
9
23
  extensions = extensions | EXT_SMART;
@@ -30,7 +44,7 @@ char *get_text(VALUE self) {
30
44
 
31
45
  static VALUE rb_multimarkdown_to_html(VALUE self) {
32
46
  char *html = markdown_to_string(get_text(self), get_exts(self), HTML_FORMAT);
33
- VALUE result = rb_str_new2(html);
47
+ VALUE result = encoded_str_new2(html, "UTF-8");
34
48
  free(html);
35
49
 
36
50
  return result;
@@ -38,7 +52,7 @@ static VALUE rb_multimarkdown_to_html(VALUE self) {
38
52
 
39
53
  static VALUE rb_multimarkdown_to_latex(VALUE self) {
40
54
  char *latex = markdown_to_string(get_text(self), get_exts(self), LATEX_FORMAT);
41
- VALUE result = rb_str_new2(latex);
55
+ VALUE result = encoded_str_new2(latex, "UTF-8");
42
56
  free(latex);
43
57
 
44
58
  return result;
@@ -46,7 +60,7 @@ static VALUE rb_multimarkdown_to_latex(VALUE self) {
46
60
 
47
61
  static VALUE rb_multimarkdown_extract_metadata_keys(VALUE self) {
48
62
  char *metadata_keys = extract_metadata_keys(get_text(self), get_exts(self));
49
- VALUE str = rb_str_new2(metadata_keys);
63
+ VALUE str = encoded_str_new2(metadata_keys, "UTF-8");
50
64
  free(metadata_keys);
51
65
 
52
66
  return rb_funcall(str, rb_intern("split"), 1, rb_str_new2("\n"));
@@ -57,7 +71,7 @@ static VALUE rb_multimarkdown_extract_metadata_value(VALUE self, VALUE key) {
57
71
  char *pkey = StringValuePtr(key);
58
72
 
59
73
  char *metadata = extract_metadata_value(get_text(self), get_exts(self), pkey);
60
- VALUE result = rb_str_new2(metadata);
74
+ VALUE result = encoded_str_new2(metadata, "UTF-8");
61
75
  free(metadata);
62
76
 
63
77
  return result;
Binary file
@@ -1,6 +1,6 @@
1
1
  class MultiMarkdown
2
2
 
3
3
  # The ruby 'multimarkdown' gem version
4
- VERSION = "4.5.3.1"
4
+ VERSION = "4.5.3.2"
5
5
 
6
6
  end
@@ -1,3 +1,5 @@
1
+ # encoding: UTF-8
2
+
1
3
  $: << File.join(File.dirname(__FILE__), "../lib")
2
4
 
3
5
  require 'test/unit'
@@ -60,5 +62,16 @@ Lorem Ipsum
60
62
  assert_equal(nil, multimarkdown.metadata["MetaTheMeta1"])
61
63
  end
62
64
 
65
+ def test_encoding
66
+ multimarkdown = MultiMarkdown.new(<<-eof)
67
+ umlauts: M€tädätä
68
+
69
+ ÄÖÜßäöüµ√
70
+ =========
71
+
72
+ eof
73
+ assert_match(/<h1[^>]*>ÄÖÜßäöüµ√<\/h1>/, multimarkdown.to_html.strip)
74
+ assert_equal("M€tädätä", multimarkdown.metadata('umlauts'))
75
+ end
63
76
 
64
77
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rmultimarkdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.5.3.1
4
+ version: 4.5.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Till Schulte-Coerne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-02 00:00:00.000000000 Z
11
+ date: 2014-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler