rpeg-multimarkdown 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.markdown +3 -3
- data/Rakefile +1 -1
- data/ext/markdown.c +17 -2
- data/test/multimarkdown_test.rb +28 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a2db27270d9a4205d98c91760432207cf2cddcf
|
4
|
+
data.tar.gz: 8b3a88efb70610fb70c2db1bd173d7926b5c038f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e5452b984d43c447b563973760b0879fc515257eca20c5f7310fc026bf93e0b46585b6e72ffd80a45104007e2455702be46520c775242f8b7ae5859637ca828
|
7
|
+
data.tar.gz: 9182a060242a16d96d62d61db84244c469676b3761c7807b6c49843f00854888cd51e6bdfe3baf0602ba8f192461e169f2e64f6030d2c2c27bdca7c377c5647e
|
data/README.markdown
CHANGED
@@ -50,10 +50,10 @@ Hacking:
|
|
50
50
|
Changes
|
51
51
|
-------
|
52
52
|
|
53
|
-
* [Version 0.2.
|
54
|
-
* Fixed ruby module tests, which weren't actually running
|
55
|
-
* [Version 0.2](http://github.com/djungelvral/rpeg-multimarkdown/tree/v0.2)
|
53
|
+
* [Version 0.2.2](http://github.com/djungelvral/rpeg-multimarkdown/tree/v0.2.2)
|
56
54
|
* Bringing everything up to date with the last version of peg-multimarkdown
|
55
|
+
* Fixed ruby module tests, which weren't actually running
|
56
|
+
* Preserve encoding, e.g. for UTF-8
|
57
57
|
* [Version 0.1.1](http://github.com/djungelvral/rpeg-multimarkdown/tree/v0.1.1)
|
58
58
|
|
59
59
|
COPYING
|
data/Rakefile
CHANGED
data/ext/markdown.c
CHANGED
@@ -35,7 +35,10 @@ rb_multimarkdown_to_html(int argc, VALUE *argv, VALUE self)
|
|
35
35
|
char *html = markdown_to_string(ptext, extensions, HTML_FORMAT);
|
36
36
|
VALUE result = rb_str_new2(html);
|
37
37
|
free(html);
|
38
|
-
|
38
|
+
|
39
|
+
/* Take the encoding from the input, and apply to output */
|
40
|
+
rb_enc_copy(result, text);
|
41
|
+
|
39
42
|
return result;
|
40
43
|
}
|
41
44
|
|
@@ -53,6 +56,9 @@ rb_multimarkdown_to_latex(int argc, VALUE *argv, VALUE self)
|
|
53
56
|
VALUE result = rb_str_new2(latex);
|
54
57
|
free(latex);
|
55
58
|
|
59
|
+
/* Take the encoding from the input, and apply to output */
|
60
|
+
rb_enc_copy(result, text);
|
61
|
+
|
56
62
|
return result;
|
57
63
|
}
|
58
64
|
|
@@ -71,9 +77,18 @@ rb_multimarkdown_extract_metadata(VALUE self, VALUE key)
|
|
71
77
|
|
72
78
|
/* Display metadata on request */
|
73
79
|
char *metadata = extract_metadata_value(ptext, extensions, pkey);
|
74
|
-
|
80
|
+
int exists = metadata != NULL;
|
81
|
+
/* metadata might be null, if not present */
|
82
|
+
/* rb_str_new2 == rb_str_new_cstr */
|
83
|
+
VALUE result = exists ? rb_str_new2(metadata) : Qnil;
|
75
84
|
free(metadata);
|
76
85
|
|
86
|
+
/* Take the encoding from the input, and apply to output */
|
87
|
+
if(exists)
|
88
|
+
{
|
89
|
+
rb_enc_copy(result, text);
|
90
|
+
}
|
91
|
+
|
77
92
|
return result;
|
78
93
|
}
|
79
94
|
|
data/test/multimarkdown_test.rb
CHANGED
@@ -7,7 +7,7 @@ require 'multimarkdown'
|
|
7
7
|
MARKDOWN_TEST_DIR = "#{File.dirname(__FILE__)}/MultiMarkdownTest"
|
8
8
|
|
9
9
|
class MultiMarkdownTest < MiniTest::Test
|
10
|
-
|
10
|
+
|
11
11
|
def test_that_extension_methods_are_present_on_multimarkdown_class
|
12
12
|
assert MultiMarkdown.instance_methods.include?(:to_html),
|
13
13
|
"MultiMarkdown class should respond to #to_html"
|
@@ -60,6 +60,33 @@ class MultiMarkdownTest < MiniTest::Test
|
|
60
60
|
multimarkdown.to_html(true)
|
61
61
|
end
|
62
62
|
|
63
|
+
def test_that_encoding_is_preserved_for_html
|
64
|
+
test = "Écouté bien!"
|
65
|
+
html = MultiMarkdown.new(test, :smart).to_html
|
66
|
+
assert_equal html.encoding, test.encoding
|
67
|
+
assert_equal "<p>Écouté bien!</p>", html.strip
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_that_encoding_is_preserved_for_latex
|
71
|
+
test = "Écouté bien!"
|
72
|
+
latex = MultiMarkdown.new(test, :smart).to_latex
|
73
|
+
assert_equal latex.encoding, test.encoding
|
74
|
+
assert_equal "Écouté bien!", latex.strip
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_that_encoding_is_preserved_for_metadata
|
78
|
+
test = "Title: Some åccentéd document\n\nÉcouté bien!"
|
79
|
+
title = MultiMarkdown.new(test, :smart).extract_metadata("title")
|
80
|
+
refute_nil title
|
81
|
+
assert_equal title.encoding, test.encoding
|
82
|
+
assert_equal "Some åccentéd document", title.strip
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_that_missing_metadata_returns_nil
|
86
|
+
test = "Title: Some document\n\nHere's some text"
|
87
|
+
author = MultiMarkdown.new(test, :smart).extract_metadata("author")
|
88
|
+
assert_nil author
|
89
|
+
end
|
63
90
|
|
64
91
|
|
65
92
|
# Build tests for each file in the MarkdownTest test suite
|