commonmarker 0.9.1 → 0.9.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/README.md +1 -0
- data/Rakefile +9 -9
- data/ext/commonmarker/cmark/api_test/main.c +5 -0
- data/ext/commonmarker/cmark/build/CMakeCache.txt +459 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/3.5.2/CMakeCCompiler.cmake +67 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/3.5.2/CMakeCXXCompiler.cmake +68 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/3.5.2/CMakeDetermineCompilerABI_C.bin +0 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/3.5.2/CMakeDetermineCompilerABI_CXX.bin +0 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/3.5.2/CMakeSystem.cmake +15 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/3.5.2/CompilerIdC/CMakeCCompilerId.c +544 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/3.5.2/CompilerIdC/a.out +0 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/3.5.2/CompilerIdCXX/CMakeCXXCompilerId.cpp +533 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/3.5.2/CompilerIdCXX/a.out +0 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/CMakeDirectoryInformation.cmake +16 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/CMakeError.log +14 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/CMakeOutput.log +562 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/Makefile.cmake +150 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/Makefile2 +295 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/TargetDirectories.txt +39 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/cmake.check_cache +1 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/feature_tests.bin +0 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/feature_tests.c +34 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/feature_tests.cxx +405 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/progress.marks +1 -0
- data/ext/commonmarker/cmark/build/CTestTestfile.cmake +10 -0
- data/ext/commonmarker/cmark/build/Makefile +250 -0
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/CMakeDirectoryInformation.cmake +16 -0
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/DependInfo.cmake +35 -0
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/build.make +168 -0
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/cmake_clean.cmake +12 -0
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/depend.make +2 -0
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/flags.make +17 -0
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/link.txt +1 -0
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/progress.make +5 -0
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/progress.marks +1 -0
- data/ext/commonmarker/cmark/build/api_test/Makefile +300 -0
- data/ext/commonmarker/cmark/build/api_test/cmake_install.cmake +29 -0
- data/ext/commonmarker/cmark/build/cmake_install.cmake +48 -0
- data/ext/commonmarker/cmark/build/man/CMakeFiles/CMakeDirectoryInformation.cmake +16 -0
- data/ext/commonmarker/cmark/build/man/CMakeFiles/progress.marks +1 -0
- data/ext/commonmarker/cmark/build/man/Makefile +194 -0
- data/ext/commonmarker/cmark/build/man/cmake_install.cmake +37 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/CMakeDirectoryInformation.cmake +16 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/DependInfo.cmake +41 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/build.make +626 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/cmake_clean.cmake +29 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/depend.make +2 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/flags.make +10 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/link.txt +1 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/progress.make +22 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/DependInfo.cmake +46 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/build.make +603 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/cmake_clean.cmake +29 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/depend.make +2 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/flags.make +10 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/link.txt +1 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/progress.make +21 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/C.includecache +468 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/DependInfo.cmake +40 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/blocks.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/buffer.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/build.make +600 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/cmake_clean.cmake +28 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/cmake_clean_target.cmake +3 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/cmark.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/cmark_ctype.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/commonmark.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/depend.internal +211 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/depend.make +211 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/flags.make +10 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/houdini_href_e.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/houdini_html_e.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/houdini_html_u.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/html.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/inlines.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/iterator.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/latex.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/link.txt +2 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/man.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/node.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/progress.make +21 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/references.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/render.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/scanners.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/utf8.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/xml.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/progress.marks +1 -0
- data/ext/commonmarker/cmark/build/src/Makefile +956 -0
- data/ext/commonmarker/cmark/build/src/cmake_install.cmake +77 -0
- data/ext/commonmarker/cmark/build/src/cmark_export.h +41 -0
- data/ext/commonmarker/cmark/build/src/cmark_version.h +7 -0
- data/ext/commonmarker/cmark/build/src/config.h +84 -0
- data/ext/commonmarker/cmark/build/src/libcmark.a +0 -0
- data/ext/commonmarker/cmark/build/src/libcmark.pc +10 -0
- data/ext/commonmarker/cmark/build/testdir/CMakeFiles/CMakeDirectoryInformation.cmake +16 -0
- data/ext/commonmarker/cmark/build/testdir/CMakeFiles/progress.marks +1 -0
- data/ext/commonmarker/cmark/build/testdir/CTestTestfile.cmake +14 -0
- data/ext/commonmarker/cmark/build/testdir/Makefile +194 -0
- data/ext/commonmarker/cmark/build/testdir/cmake_install.cmake +29 -0
- data/ext/commonmarker/cmark/man/man1/cmark.1 +11 -4
- data/ext/commonmarker/cmark/man/man3/cmark.3 +66 -11
- data/ext/commonmarker/cmark/src/blocks.c +232 -235
- data/ext/commonmarker/cmark/src/buffer.c +19 -56
- data/ext/commonmarker/cmark/src/buffer.h +7 -20
- data/ext/commonmarker/cmark/src/chunk.h +19 -19
- data/ext/commonmarker/cmark/src/cmark.c +14 -0
- data/ext/commonmarker/cmark/src/cmark.h +45 -6
- data/ext/commonmarker/cmark/src/cmark_ctype.c +2 -0
- data/ext/commonmarker/cmark/src/cmark_ctype.h +2 -0
- data/ext/commonmarker/cmark/src/commonmark.c +42 -29
- data/ext/commonmarker/cmark/src/config.h.in +8 -0
- data/ext/commonmarker/cmark/src/html.c +3 -1
- data/ext/commonmarker/cmark/src/inlines.c +111 -150
- data/ext/commonmarker/cmark/src/inlines.h +4 -4
- data/ext/commonmarker/cmark/src/iterator.c +6 -7
- data/ext/commonmarker/cmark/src/iterator.h +2 -0
- data/ext/commonmarker/cmark/src/latex.c +10 -8
- data/ext/commonmarker/cmark/src/main.c +6 -2
- data/ext/commonmarker/cmark/src/man.c +9 -5
- data/ext/commonmarker/cmark/src/node.c +38 -29
- data/ext/commonmarker/cmark/src/node.h +15 -11
- data/ext/commonmarker/cmark/src/parser.h +4 -2
- data/ext/commonmarker/cmark/src/references.c +23 -22
- data/ext/commonmarker/cmark/src/references.h +3 -1
- data/ext/commonmarker/cmark/src/render.c +9 -7
- data/ext/commonmarker/cmark/src/render.h +3 -1
- data/ext/commonmarker/cmark/src/scanners.c +30 -22
- data/ext/commonmarker/cmark/src/xml.c +1 -1
- data/ext/commonmarker/cmark/test/CMakeLists.txt +8 -8
- data/ext/commonmarker/cmark/test/cmark.py +34 -14
- data/ext/commonmarker/cmark/test/roundtrip_tests.py +47 -0
- data/ext/commonmarker/cmark/test/spec.txt +96 -6
- data/ext/commonmarker/cmark/test/spec_tests.py +5 -8
- data/ext/commonmarker/commonmarker.c +14 -8
- data/lib/commonmarker/config.rb +2 -2
- data/lib/commonmarker/renderer.rb +17 -7
- data/lib/commonmarker/renderer/html_renderer.rb +16 -21
- data/lib/commonmarker/version.rb +1 -1
- data/test/test_pathological_inputs.rb +11 -11
- metadata +99 -4
- data/ext/commonmarker/cmark/test/roundtrip.bat +0 -1
- data/ext/commonmarker/cmark/test/roundtrip.sh +0 -2
|
@@ -13,12 +13,90 @@ license: '[CC-BY-SA 4.0](http://creativecommons.org/licenses/by-sa/4.0/)'
|
|
|
13
13
|
Markdown is a plain text format for writing structured documents,
|
|
14
14
|
based on conventions used for indicating formatting in email and
|
|
15
15
|
usenet posts. It was developed in 2004 by John Gruber, who wrote
|
|
16
|
-
the first Markdown-to-HTML converter in
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
Markdown syntax with conventions for footnotes,
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
the first Markdown-to-HTML converter in Perl, and it soon became
|
|
17
|
+
ubiquitous. In the next decade, dozens of implementations were
|
|
18
|
+
developed in many languages. Some extended the original
|
|
19
|
+
Markdown syntax with conventions for footnotes, tables, and
|
|
20
|
+
other document elements. Some allowed Markdown documents to be
|
|
21
|
+
rendered in formats other than HTML. Websites like Reddit,
|
|
22
|
+
StackOverflow, and GitHub had millions of people using Markdown.
|
|
23
|
+
And Markdown started to be used beyond the web, to author books,
|
|
24
|
+
articles, slide shows, letters, and lecture notes.
|
|
25
|
+
|
|
26
|
+
What distinguishes Markdown from many other lightweight markup
|
|
27
|
+
syntaxes, which are often easier to write, is its readability.
|
|
28
|
+
As Gruber writes:
|
|
29
|
+
|
|
30
|
+
> The overriding design goal for Markdown's formatting syntax is
|
|
31
|
+
> to make it as readable as possible. The idea is that a
|
|
32
|
+
> Markdown-formatted document should be publishable as-is, as
|
|
33
|
+
> plain text, without looking like it's been marked up with tags
|
|
34
|
+
> or formatting instructions.
|
|
35
|
+
> (<http://daringfireball.net/projects/markdown/>)
|
|
36
|
+
|
|
37
|
+
The point can be illustrated by comparing a sample of
|
|
38
|
+
[AsciiDoc](http://www.methods.co.nz/asciidoc/) with
|
|
39
|
+
an equivalent sample of Markdown. Here is a sample of
|
|
40
|
+
AsciiDoc from the AsciiDoc manual:
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
1. List item one.
|
|
44
|
+
+
|
|
45
|
+
List item one continued with a second paragraph followed by an
|
|
46
|
+
Indented block.
|
|
47
|
+
+
|
|
48
|
+
.................
|
|
49
|
+
$ ls *.sh
|
|
50
|
+
$ mv *.sh ~/tmp
|
|
51
|
+
.................
|
|
52
|
+
+
|
|
53
|
+
List item continued with a third paragraph.
|
|
54
|
+
|
|
55
|
+
2. List item two continued with an open block.
|
|
56
|
+
+
|
|
57
|
+
--
|
|
58
|
+
This paragraph is part of the preceding list item.
|
|
59
|
+
|
|
60
|
+
a. This list is nested and does not require explicit item
|
|
61
|
+
continuation.
|
|
62
|
+
+
|
|
63
|
+
This paragraph is part of the preceding list item.
|
|
64
|
+
|
|
65
|
+
b. List item b.
|
|
66
|
+
|
|
67
|
+
This paragraph belongs to item two of the outer list.
|
|
68
|
+
--
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
And here is the equivalent in Markdown:
|
|
72
|
+
```
|
|
73
|
+
1. List item one.
|
|
74
|
+
|
|
75
|
+
List item one continued with a second paragraph followed by an
|
|
76
|
+
Indented block.
|
|
77
|
+
|
|
78
|
+
$ ls *.sh
|
|
79
|
+
$ mv *.sh ~/tmp
|
|
80
|
+
|
|
81
|
+
List item continued with a third paragraph.
|
|
82
|
+
|
|
83
|
+
2. List item two continued with an open block.
|
|
84
|
+
|
|
85
|
+
This paragraph is part of the preceding list item.
|
|
86
|
+
|
|
87
|
+
1. This list is nested and does not require explicit item continuation.
|
|
88
|
+
|
|
89
|
+
This paragraph is part of the preceding list item.
|
|
90
|
+
|
|
91
|
+
2. List item b.
|
|
92
|
+
|
|
93
|
+
This paragraph belongs to item two of the outer list.
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
The AsciiDoc version is, arguably, easier to write. You don't need
|
|
97
|
+
to worry about indentation. But the Markdown version is much easier
|
|
98
|
+
to read. The nesting of list items is apparent to the eye in the
|
|
99
|
+
source, not just in the processed document.
|
|
22
100
|
|
|
23
101
|
## Why is a spec needed?
|
|
24
102
|
|
|
@@ -4080,6 +4158,18 @@ Here are some list items that start with a blank line but are not empty:
|
|
|
4080
4158
|
</ul>
|
|
4081
4159
|
````````````````````````````````
|
|
4082
4160
|
|
|
4161
|
+
When the list item starts with a blank line, the number of spaces
|
|
4162
|
+
following the list marker doesn't change the required indentation:
|
|
4163
|
+
|
|
4164
|
+
```````````````````````````````` example
|
|
4165
|
+
-
|
|
4166
|
+
foo
|
|
4167
|
+
.
|
|
4168
|
+
<ul>
|
|
4169
|
+
<li>foo</li>
|
|
4170
|
+
</ul>
|
|
4171
|
+
````````````````````````````````
|
|
4172
|
+
|
|
4083
4173
|
|
|
4084
4174
|
A list item can begin with at most one blank line.
|
|
4085
4175
|
In the following example, `foo` is not part of the list
|
|
@@ -38,8 +38,8 @@ def out(str):
|
|
|
38
38
|
def print_test_header(headertext, example_number, start_line, end_line):
|
|
39
39
|
out("Example %d (lines %d-%d) %s\n" % (example_number,start_line,end_line,headertext))
|
|
40
40
|
|
|
41
|
-
def do_test(test, normalize, result_counts):
|
|
42
|
-
[retcode, actual_html, err] =
|
|
41
|
+
def do_test(converter, test, normalize, result_counts):
|
|
42
|
+
[retcode, actual_html, err] = converter(test['markdown'])
|
|
43
43
|
if retcode == 0:
|
|
44
44
|
expected_html = test['html']
|
|
45
45
|
unicode_error = None
|
|
@@ -135,12 +135,9 @@ if __name__ == "__main__":
|
|
|
135
135
|
exit(0)
|
|
136
136
|
else:
|
|
137
137
|
skipped = len(all_tests) - len(tests)
|
|
138
|
-
|
|
138
|
+
converter = CMark(prog=args.program, library_dir=args.library_dir).to_html
|
|
139
139
|
result_counts = {'pass': 0, 'fail': 0, 'error': 0, 'skip': skipped}
|
|
140
140
|
for test in tests:
|
|
141
|
-
do_test(test, args.normalize, result_counts)
|
|
141
|
+
do_test(converter, test, args.normalize, result_counts)
|
|
142
142
|
out("{pass} passed, {fail} failed, {error} errored, {skip} skipped\n".format(**result_counts))
|
|
143
|
-
|
|
144
|
-
exit(0)
|
|
145
|
-
else:
|
|
146
|
-
exit(1)
|
|
143
|
+
exit(result_counts['fail'] + result_counts['error'])
|
|
@@ -870,10 +870,14 @@ static VALUE rb_node_set_fence_info(VALUE self, VALUE info) {
|
|
|
870
870
|
/* Internal: Escapes href URLs safely. */
|
|
871
871
|
static VALUE rb_html_escape_href(VALUE self, VALUE rb_text) {
|
|
872
872
|
char *result;
|
|
873
|
-
|
|
874
|
-
|
|
873
|
+
cmark_node *node;
|
|
875
874
|
Check_Type(rb_text, T_STRING);
|
|
876
875
|
|
|
876
|
+
Data_Get_Struct(self, cmark_node, node);
|
|
877
|
+
|
|
878
|
+
cmark_mem *mem = cmark_node_mem(node);
|
|
879
|
+
cmark_strbuf buf = CMARK_BUF_INIT(mem);
|
|
880
|
+
|
|
877
881
|
if (houdini_escape_href(&buf, (const uint8_t *)RSTRING_PTR(rb_text),
|
|
878
882
|
RSTRING_LEN(rb_text))) {
|
|
879
883
|
result = (char *)cmark_strbuf_detach(&buf);
|
|
@@ -886,10 +890,14 @@ static VALUE rb_html_escape_href(VALUE self, VALUE rb_text) {
|
|
|
886
890
|
/* Internal: Escapes HTML content safely. */
|
|
887
891
|
static VALUE rb_html_escape_html(VALUE self, VALUE rb_text) {
|
|
888
892
|
char *result;
|
|
889
|
-
|
|
890
|
-
|
|
893
|
+
cmark_node *node;
|
|
891
894
|
Check_Type(rb_text, T_STRING);
|
|
892
895
|
|
|
896
|
+
Data_Get_Struct(self, cmark_node, node);
|
|
897
|
+
|
|
898
|
+
cmark_mem *mem = cmark_node_mem(node);
|
|
899
|
+
cmark_strbuf buf = CMARK_BUF_INIT(mem);
|
|
900
|
+
|
|
893
901
|
if (houdini_escape_html0(&buf, (const uint8_t *)RSTRING_PTR(rb_text),
|
|
894
902
|
RSTRING_LEN(rb_text), 0)) {
|
|
895
903
|
result = (char *)cmark_strbuf_detach(&buf);
|
|
@@ -961,8 +969,6 @@ __attribute__((visibility("default"))) void Init_commonmarker() {
|
|
|
961
969
|
rb_define_method(rb_mNode, "fence_info", rb_node_get_fence_info, 0);
|
|
962
970
|
rb_define_method(rb_mNode, "fence_info=", rb_node_set_fence_info, 1);
|
|
963
971
|
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
rb_define_singleton_method(rb_mNode, "html_escape_html", rb_html_escape_html,
|
|
967
|
-
1);
|
|
972
|
+
rb_define_method(rb_mNode, "html_escape_href", rb_html_escape_href, 1);
|
|
973
|
+
rb_define_method(rb_mNode, "html_escape_html", rb_html_escape_html, 1);
|
|
968
974
|
}
|
data/lib/commonmarker/config.rb
CHANGED
|
@@ -30,13 +30,13 @@ module CommonMarker
|
|
|
30
30
|
# neckbearding around. the map will both check the opts and then bitwise-OR it
|
|
31
31
|
option.map { |o| check_option(o, type); type.to_h[o] }.inject(0, :|)
|
|
32
32
|
else
|
|
33
|
-
|
|
33
|
+
raise TypeError, 'option type must be a valid symbol or array of symbols'
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
def self.check_option(option, type)
|
|
38
38
|
unless type.keys.include?(option)
|
|
39
|
-
|
|
39
|
+
raise TypeError, "option ':#{option}' does not exist for #{type}"
|
|
40
40
|
end
|
|
41
41
|
end
|
|
42
42
|
end
|
|
@@ -39,7 +39,7 @@ module CommonMarker
|
|
|
39
39
|
begin
|
|
40
40
|
send(node.type, node)
|
|
41
41
|
rescue NoMethodError => e
|
|
42
|
-
@warnings.add(
|
|
42
|
+
@warnings.add("WARNING: #{node.type} not implemented.")
|
|
43
43
|
raise e
|
|
44
44
|
end
|
|
45
45
|
end
|
|
@@ -69,23 +69,33 @@ module CommonMarker
|
|
|
69
69
|
cr unless @in_tight
|
|
70
70
|
end
|
|
71
71
|
|
|
72
|
-
def block
|
|
72
|
+
def block
|
|
73
73
|
cr
|
|
74
|
-
|
|
74
|
+
yield
|
|
75
75
|
cr
|
|
76
76
|
end
|
|
77
77
|
|
|
78
|
-
def container(starter, ender
|
|
78
|
+
def container(starter, ender)
|
|
79
79
|
out(starter)
|
|
80
|
-
|
|
80
|
+
yield
|
|
81
81
|
out(ender)
|
|
82
82
|
end
|
|
83
83
|
|
|
84
|
-
def plain
|
|
84
|
+
def plain
|
|
85
85
|
old_in_plain = @in_plain
|
|
86
86
|
@in_plain = true
|
|
87
|
-
|
|
87
|
+
yield
|
|
88
88
|
@in_plain = old_in_plain
|
|
89
89
|
end
|
|
90
|
+
|
|
91
|
+
private
|
|
92
|
+
|
|
93
|
+
def escape_href(str)
|
|
94
|
+
@node.html_escape_href(str)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def escape_html(str)
|
|
98
|
+
@node.html_escape_html(str)
|
|
99
|
+
end
|
|
90
100
|
end
|
|
91
101
|
end
|
|
@@ -7,7 +7,7 @@ module CommonMarker
|
|
|
7
7
|
def header(node)
|
|
8
8
|
block do
|
|
9
9
|
out('<h', node.header_level, '>', :children,
|
|
10
|
-
|
|
10
|
+
'</h', node.header_level, '>')
|
|
11
11
|
end
|
|
12
12
|
end
|
|
13
13
|
|
|
@@ -33,8 +33,11 @@ module CommonMarker
|
|
|
33
33
|
out(:children)
|
|
34
34
|
end
|
|
35
35
|
else
|
|
36
|
-
start = node.list_start == 1
|
|
37
|
-
|
|
36
|
+
start = if node.list_start == 1
|
|
37
|
+
"<ol>\n"
|
|
38
|
+
else
|
|
39
|
+
"<ol start=\"#{node.list_start}\">\n"
|
|
40
|
+
end
|
|
38
41
|
container(start, '</ol>') do
|
|
39
42
|
out(:children)
|
|
40
43
|
end
|
|
@@ -44,7 +47,7 @@ module CommonMarker
|
|
|
44
47
|
@in_tight = old_in_tight
|
|
45
48
|
end
|
|
46
49
|
|
|
47
|
-
def list_item(
|
|
50
|
+
def list_item(_)
|
|
48
51
|
block do
|
|
49
52
|
container('<li>', '</li>') do
|
|
50
53
|
out(:children)
|
|
@@ -52,7 +55,7 @@ module CommonMarker
|
|
|
52
55
|
end
|
|
53
56
|
end
|
|
54
57
|
|
|
55
|
-
def blockquote(
|
|
58
|
+
def blockquote(_)
|
|
56
59
|
block do
|
|
57
60
|
container("<blockquote>\n", '</blockquote>') do
|
|
58
61
|
out(:children)
|
|
@@ -60,7 +63,7 @@ module CommonMarker
|
|
|
60
63
|
end
|
|
61
64
|
end
|
|
62
65
|
|
|
63
|
-
def hrule(
|
|
66
|
+
def hrule(_)
|
|
64
67
|
block do
|
|
65
68
|
out('<hr />')
|
|
66
69
|
end
|
|
@@ -69,10 +72,10 @@ module CommonMarker
|
|
|
69
72
|
def code_block(node)
|
|
70
73
|
block do
|
|
71
74
|
out('<pre><code')
|
|
72
|
-
if node.fence_info && node.fence_info.
|
|
75
|
+
if node.fence_info && !node.fence_info.empty?
|
|
73
76
|
out(' class="language-', node.fence_info.split(/\s+/)[0], '">')
|
|
74
77
|
else
|
|
75
|
-
out(
|
|
78
|
+
out('>')
|
|
76
79
|
end
|
|
77
80
|
out(escape_html(node.string_content))
|
|
78
81
|
out('</code></pre>')
|
|
@@ -89,17 +92,17 @@ module CommonMarker
|
|
|
89
92
|
out(node.string_content)
|
|
90
93
|
end
|
|
91
94
|
|
|
92
|
-
def emph(
|
|
95
|
+
def emph(_)
|
|
93
96
|
out('<em>', :children, '</em>')
|
|
94
97
|
end
|
|
95
98
|
|
|
96
|
-
def strong(
|
|
99
|
+
def strong(_)
|
|
97
100
|
out('<strong>', :children, '</strong>')
|
|
98
101
|
end
|
|
99
102
|
|
|
100
103
|
def link(node)
|
|
101
104
|
out('<a href="', node.url.nil? ? '' : escape_href(node.url), '"')
|
|
102
|
-
if node.title && node.title.
|
|
105
|
+
if node.title && !node.title.empty?
|
|
103
106
|
out(' title="', escape_html(node.title), '"')
|
|
104
107
|
end
|
|
105
108
|
out('>', :children, '</a>')
|
|
@@ -110,7 +113,7 @@ module CommonMarker
|
|
|
110
113
|
plain do
|
|
111
114
|
out(' alt="', :children, '"')
|
|
112
115
|
end
|
|
113
|
-
if node.title && node.title.
|
|
116
|
+
if node.title && !node.title.empty?
|
|
114
117
|
out(' title="', escape_html(node.title), '"')
|
|
115
118
|
end
|
|
116
119
|
out(' />')
|
|
@@ -131,16 +134,8 @@ module CommonMarker
|
|
|
131
134
|
softbreak(node)
|
|
132
135
|
end
|
|
133
136
|
|
|
134
|
-
def softbreak(
|
|
137
|
+
def softbreak(_)
|
|
135
138
|
out("\n")
|
|
136
139
|
end
|
|
137
|
-
|
|
138
|
-
def escape_href(str)
|
|
139
|
-
CommonMarker::Node.html_escape_href(str)
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
def escape_html(str)
|
|
143
|
-
CommonMarker::Node.html_escape_html(str)
|
|
144
|
-
end
|
|
145
140
|
end
|
|
146
141
|
end
|
data/lib/commonmarker/version.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require 'test_helper'
|
|
2
|
-
require 'minitest/benchmark' if ENV[
|
|
2
|
+
require 'minitest/benchmark' if ENV['BENCH']
|
|
3
3
|
|
|
4
4
|
def markdown(s)
|
|
5
5
|
CommonMarker.render_doc(s).to_html
|
|
@@ -28,39 +28,39 @@ pathological = {
|
|
|
28
28
|
'link openers and emph closers' =>
|
|
29
29
|
[('[ a_' * 50_000),
|
|
30
30
|
Regexp.compile('(\[ a_){50000}')],
|
|
31
|
-
'hard link/emph case'
|
|
32
|
-
[
|
|
31
|
+
'hard link/emph case' =>
|
|
32
|
+
['**x [a*b**c*](d)',
|
|
33
33
|
Regexp.compile('\\*\\*x <a href=\'d\'>a<em>b</em><em>c</em></a>')],
|
|
34
|
-
'nested brackets'
|
|
34
|
+
'nested brackets' =>
|
|
35
35
|
[('[' * 50_000) + 'a' + (']' * 50_000),
|
|
36
36
|
Regexp.compile('\[{50000}a\]{50000}')],
|
|
37
|
-
'nested block quotes'
|
|
37
|
+
'nested block quotes' =>
|
|
38
38
|
[(('> ' * 50_000) + 'a'),
|
|
39
39
|
Regexp.compile('(<blockquote>\n){50000}')],
|
|
40
|
-
'U+0000 in input'
|
|
41
|
-
[
|
|
40
|
+
'U+0000 in input' =>
|
|
41
|
+
['abc\u0000de\u0000',
|
|
42
42
|
Regexp.compile('abc\ufffd?de\ufffd?')]
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
pathological.each_pair do |name, description|
|
|
46
46
|
define_method("test_#{name}") do
|
|
47
|
-
input,
|
|
47
|
+
input, = description
|
|
48
48
|
assert markdown(input)
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
51
|
|
|
52
|
-
if ENV[
|
|
52
|
+
if ENV['BENCH']
|
|
53
53
|
class PathologicalInputsPerformanceTest < Minitest::Benchmark
|
|
54
54
|
def bench_pathological_1
|
|
55
55
|
assert_performance_linear 0.99 do |n|
|
|
56
|
-
star = '*'
|
|
56
|
+
star = '*' * (n * 10)
|
|
57
57
|
markdown("#{star}#{star}hi#{star}#{star}")
|
|
58
58
|
end
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
def bench_pathological_2
|
|
62
62
|
assert_performance_linear 0.99 do |n|
|
|
63
|
-
c =
|
|
63
|
+
c = '`t`t`t`t`t`t' * (n * 10)
|
|
64
64
|
markdown(c)
|
|
65
65
|
end
|
|
66
66
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: commonmarker
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.9.
|
|
4
|
+
version: 0.9.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Garen Torikian
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-
|
|
11
|
+
date: 2016-06-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: ruby-enum
|
|
@@ -139,6 +139,102 @@ files:
|
|
|
139
139
|
- ext/commonmarker/cmark/bench/statistics.py
|
|
140
140
|
- ext/commonmarker/cmark/bench/stats.py
|
|
141
141
|
- ext/commonmarker/cmark/benchmarks.md
|
|
142
|
+
- ext/commonmarker/cmark/build/CMakeCache.txt
|
|
143
|
+
- ext/commonmarker/cmark/build/CMakeFiles/3.5.2/CMakeCCompiler.cmake
|
|
144
|
+
- ext/commonmarker/cmark/build/CMakeFiles/3.5.2/CMakeCXXCompiler.cmake
|
|
145
|
+
- ext/commonmarker/cmark/build/CMakeFiles/3.5.2/CMakeDetermineCompilerABI_C.bin
|
|
146
|
+
- ext/commonmarker/cmark/build/CMakeFiles/3.5.2/CMakeDetermineCompilerABI_CXX.bin
|
|
147
|
+
- ext/commonmarker/cmark/build/CMakeFiles/3.5.2/CMakeSystem.cmake
|
|
148
|
+
- ext/commonmarker/cmark/build/CMakeFiles/3.5.2/CompilerIdC/CMakeCCompilerId.c
|
|
149
|
+
- ext/commonmarker/cmark/build/CMakeFiles/3.5.2/CompilerIdC/a.out
|
|
150
|
+
- ext/commonmarker/cmark/build/CMakeFiles/3.5.2/CompilerIdCXX/CMakeCXXCompilerId.cpp
|
|
151
|
+
- ext/commonmarker/cmark/build/CMakeFiles/3.5.2/CompilerIdCXX/a.out
|
|
152
|
+
- ext/commonmarker/cmark/build/CMakeFiles/CMakeDirectoryInformation.cmake
|
|
153
|
+
- ext/commonmarker/cmark/build/CMakeFiles/CMakeError.log
|
|
154
|
+
- ext/commonmarker/cmark/build/CMakeFiles/CMakeOutput.log
|
|
155
|
+
- ext/commonmarker/cmark/build/CMakeFiles/Makefile.cmake
|
|
156
|
+
- ext/commonmarker/cmark/build/CMakeFiles/Makefile2
|
|
157
|
+
- ext/commonmarker/cmark/build/CMakeFiles/TargetDirectories.txt
|
|
158
|
+
- ext/commonmarker/cmark/build/CMakeFiles/cmake.check_cache
|
|
159
|
+
- ext/commonmarker/cmark/build/CMakeFiles/feature_tests.bin
|
|
160
|
+
- ext/commonmarker/cmark/build/CMakeFiles/feature_tests.c
|
|
161
|
+
- ext/commonmarker/cmark/build/CMakeFiles/feature_tests.cxx
|
|
162
|
+
- ext/commonmarker/cmark/build/CMakeFiles/progress.marks
|
|
163
|
+
- ext/commonmarker/cmark/build/CTestTestfile.cmake
|
|
164
|
+
- ext/commonmarker/cmark/build/Makefile
|
|
165
|
+
- ext/commonmarker/cmark/build/api_test/CMakeFiles/CMakeDirectoryInformation.cmake
|
|
166
|
+
- ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/DependInfo.cmake
|
|
167
|
+
- ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/build.make
|
|
168
|
+
- ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/cmake_clean.cmake
|
|
169
|
+
- ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/depend.make
|
|
170
|
+
- ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/flags.make
|
|
171
|
+
- ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/link.txt
|
|
172
|
+
- ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/progress.make
|
|
173
|
+
- ext/commonmarker/cmark/build/api_test/CMakeFiles/progress.marks
|
|
174
|
+
- ext/commonmarker/cmark/build/api_test/Makefile
|
|
175
|
+
- ext/commonmarker/cmark/build/api_test/cmake_install.cmake
|
|
176
|
+
- ext/commonmarker/cmark/build/cmake_install.cmake
|
|
177
|
+
- ext/commonmarker/cmark/build/man/CMakeFiles/CMakeDirectoryInformation.cmake
|
|
178
|
+
- ext/commonmarker/cmark/build/man/CMakeFiles/progress.marks
|
|
179
|
+
- ext/commonmarker/cmark/build/man/Makefile
|
|
180
|
+
- ext/commonmarker/cmark/build/man/cmake_install.cmake
|
|
181
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/CMakeDirectoryInformation.cmake
|
|
182
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/DependInfo.cmake
|
|
183
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/build.make
|
|
184
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/cmake_clean.cmake
|
|
185
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/depend.make
|
|
186
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/flags.make
|
|
187
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/link.txt
|
|
188
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/progress.make
|
|
189
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/DependInfo.cmake
|
|
190
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/build.make
|
|
191
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/cmake_clean.cmake
|
|
192
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/depend.make
|
|
193
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/flags.make
|
|
194
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/link.txt
|
|
195
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/progress.make
|
|
196
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/C.includecache
|
|
197
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/DependInfo.cmake
|
|
198
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/blocks.c.o
|
|
199
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/buffer.c.o
|
|
200
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/build.make
|
|
201
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/cmake_clean.cmake
|
|
202
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/cmake_clean_target.cmake
|
|
203
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/cmark.c.o
|
|
204
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/cmark_ctype.c.o
|
|
205
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/commonmark.c.o
|
|
206
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/depend.internal
|
|
207
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/depend.make
|
|
208
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/flags.make
|
|
209
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/houdini_href_e.c.o
|
|
210
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/houdini_html_e.c.o
|
|
211
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/houdini_html_u.c.o
|
|
212
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/html.c.o
|
|
213
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/inlines.c.o
|
|
214
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/iterator.c.o
|
|
215
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/latex.c.o
|
|
216
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/link.txt
|
|
217
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/man.c.o
|
|
218
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/node.c.o
|
|
219
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/progress.make
|
|
220
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/references.c.o
|
|
221
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/render.c.o
|
|
222
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/scanners.c.o
|
|
223
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/utf8.c.o
|
|
224
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/xml.c.o
|
|
225
|
+
- ext/commonmarker/cmark/build/src/CMakeFiles/progress.marks
|
|
226
|
+
- ext/commonmarker/cmark/build/src/Makefile
|
|
227
|
+
- ext/commonmarker/cmark/build/src/cmake_install.cmake
|
|
228
|
+
- ext/commonmarker/cmark/build/src/cmark_export.h
|
|
229
|
+
- ext/commonmarker/cmark/build/src/cmark_version.h
|
|
230
|
+
- ext/commonmarker/cmark/build/src/config.h
|
|
231
|
+
- ext/commonmarker/cmark/build/src/libcmark.a
|
|
232
|
+
- ext/commonmarker/cmark/build/src/libcmark.pc
|
|
233
|
+
- ext/commonmarker/cmark/build/testdir/CMakeFiles/CMakeDirectoryInformation.cmake
|
|
234
|
+
- ext/commonmarker/cmark/build/testdir/CMakeFiles/progress.marks
|
|
235
|
+
- ext/commonmarker/cmark/build/testdir/CTestTestfile.cmake
|
|
236
|
+
- ext/commonmarker/cmark/build/testdir/Makefile
|
|
237
|
+
- ext/commonmarker/cmark/build/testdir/cmake_install.cmake
|
|
142
238
|
- ext/commonmarker/cmark/changelog.txt
|
|
143
239
|
- ext/commonmarker/cmark/data/CaseFolding-3.2.0.txt
|
|
144
240
|
- ext/commonmarker/cmark/man/CMakeLists.txt
|
|
@@ -241,8 +337,7 @@ files:
|
|
|
241
337
|
- ext/commonmarker/cmark/test/normalize.py
|
|
242
338
|
- ext/commonmarker/cmark/test/pathological_tests.py
|
|
243
339
|
- ext/commonmarker/cmark/test/regression.txt
|
|
244
|
-
- ext/commonmarker/cmark/test/
|
|
245
|
-
- ext/commonmarker/cmark/test/roundtrip.sh
|
|
340
|
+
- ext/commonmarker/cmark/test/roundtrip_tests.py
|
|
246
341
|
- ext/commonmarker/cmark/test/smart_punct.txt
|
|
247
342
|
- ext/commonmarker/cmark/test/spec.txt
|
|
248
343
|
- ext/commonmarker/cmark/test/spec_tests.py
|