rmultimarkdown 4.5.3.1 → 4.5.3.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/multi_markdown.c +19 -5
- data/lib/multi_markdown.bundle +0 -0
- data/lib/multi_markdown/version.rb +1 -1
- data/test/multi_markdown_test.rb +13 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d175433e6b773f208302634ae4a98fd19843a33a
|
|
4
|
+
data.tar.gz: 6196eef19a7bb5802a4a60b757557d83983cf6a8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 94a12726d7a0e62191317902b33ae7076e1157c10176a3cba4e838c384ff00ee40e069d069dd505bd98f630a1b2474565c4ad3017816f4c90a461958146bdbf0
|
|
7
|
+
data.tar.gz: 18d9054243c74d3dafa979e77539cb587b9dddd554fe734d8d23fa578ba870be7ebe6940f79657163613cdeb5d724916a06fdda5cff7badba99e613249bc2410
|
data/ext/multi_markdown.c
CHANGED
|
@@ -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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
74
|
+
VALUE result = encoded_str_new2(metadata, "UTF-8");
|
|
61
75
|
free(metadata);
|
|
62
76
|
|
|
63
77
|
return result;
|
data/lib/multi_markdown.bundle
CHANGED
|
Binary file
|
data/test/multi_markdown_test.rb
CHANGED
|
@@ -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.
|
|
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-
|
|
11
|
+
date: 2014-07-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|