rpeg-markdown 1.0 → 1.1
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.
- data/README.markdown +12 -5
- data/Rakefile +1 -1
- data/ext/markdown.c +48 -0
- data/ext/markdown_lib.h +4 -4
- data/ext/markdown_output.c +1 -0
- metadata +2 -2
data/README.markdown
CHANGED
@@ -16,6 +16,13 @@ Synopsis
|
|
16
16
|
>> puts Markdown.new('_Hello World!_', :smart, :filter_html).to_html
|
17
17
|
<p><em>Hello World!</em></p>
|
18
18
|
|
19
|
+
>> puts Markdown.new('_Hello World!_').to_latex
|
20
|
+
\emph{Hello World!}
|
21
|
+
|
22
|
+
>> puts Markdown.new('_Hello World!_').to_groff_mm
|
23
|
+
.P
|
24
|
+
\fIHello world!\fR
|
25
|
+
|
19
26
|
>> PEGMarkdown.new('Hello! World!')
|
20
27
|
|
21
28
|
Installation / Hacking
|
@@ -26,20 +33,20 @@ systems should be fine.
|
|
26
33
|
|
27
34
|
Install from GEM:
|
28
35
|
|
29
|
-
|
36
|
+
$ sudo gem install rpeg-markdown
|
30
37
|
|
31
38
|
Hacking:
|
32
39
|
|
33
|
-
|
34
|
-
|
35
|
-
|
40
|
+
$ git clone git://github.com/rtomayko/rpeg-markdown.git
|
41
|
+
$ cd rpeg-markdown
|
42
|
+
$ rake test
|
36
43
|
|
37
44
|
Patches happily accepted via fork or email.
|
38
45
|
|
39
46
|
Changes
|
40
47
|
-------
|
41
48
|
|
42
|
-
http://github.com/rtomayko/
|
49
|
+
* [Version 1.0](http://github.com/rtomayko/rpeg-markdown/tree/v1.0)
|
43
50
|
|
44
51
|
COPYING
|
45
52
|
-------
|
data/Rakefile
CHANGED
data/ext/markdown.c
CHANGED
@@ -29,10 +29,58 @@ rb_markdown_to_html(int argc, VALUE *argv, VALUE self)
|
|
29
29
|
return result;
|
30
30
|
}
|
31
31
|
|
32
|
+
static VALUE
|
33
|
+
rb_markdown_to_latex(int argc, VALUE *argv, VALUE self)
|
34
|
+
{
|
35
|
+
/* grab char pointer to markdown input text */
|
36
|
+
VALUE text = rb_funcall(self, rb_intern("text"), 0);
|
37
|
+
Check_Type(text, T_STRING);
|
38
|
+
char * ptext = StringValuePtr(text);
|
39
|
+
|
40
|
+
/* flip extension bits - note that defaults are different than
|
41
|
+
* for HTML */
|
42
|
+
int extensions = EXT_SMART | EXT_NOTES | EXT_FILTER_HTML | EXT_FILTER_STYLES;
|
43
|
+
if ( rb_funcall(self, rb_intern("smart"), 0) == Qfalse )
|
44
|
+
extensions = extensions & ~ EXT_SMART ;
|
45
|
+
if ( rb_funcall(self, rb_intern("notes"), 0) == Qfalse )
|
46
|
+
extensions = extensions & ~ EXT_NOTES ;
|
47
|
+
|
48
|
+
char *latex = markdown_to_string(ptext, extensions, LATEX_FORMAT);
|
49
|
+
VALUE result = rb_str_new2(latex);
|
50
|
+
free(latex);
|
51
|
+
|
52
|
+
return result;
|
53
|
+
}
|
54
|
+
|
55
|
+
static VALUE
|
56
|
+
rb_markdown_to_groff_mm(int argc, VALUE *argv, VALUE self)
|
57
|
+
{
|
58
|
+
/* grab char pointer to markdown input text */
|
59
|
+
VALUE text = rb_funcall(self, rb_intern("text"), 0);
|
60
|
+
Check_Type(text, T_STRING);
|
61
|
+
char * ptext = StringValuePtr(text);
|
62
|
+
|
63
|
+
/* flip extension bits - note that defaults are different than
|
64
|
+
* for HTML */
|
65
|
+
int extensions = EXT_SMART | EXT_NOTES | EXT_FILTER_HTML | EXT_FILTER_STYLES;
|
66
|
+
if ( rb_funcall(self, rb_intern("smart"), 0) == Qfalse )
|
67
|
+
extensions = extensions & ~ EXT_SMART ;
|
68
|
+
if ( rb_funcall(self, rb_intern("notes"), 0) == Qfalse )
|
69
|
+
extensions = extensions & ~ EXT_NOTES ;
|
70
|
+
|
71
|
+
char *groff = markdown_to_string(ptext, extensions, GROFF_MM_FORMAT);
|
72
|
+
VALUE result = rb_str_new2(groff);
|
73
|
+
free(groff);
|
74
|
+
|
75
|
+
return result;
|
76
|
+
}
|
77
|
+
|
32
78
|
void Init_peg_markdown()
|
33
79
|
{
|
34
80
|
rb_cMarkdown = rb_define_class("PEGMarkdown", rb_cObject);
|
35
81
|
rb_define_method(rb_cMarkdown, "to_html", rb_markdown_to_html, -1);
|
82
|
+
rb_define_method(rb_cMarkdown, "to_latex", rb_markdown_to_latex, -1);
|
83
|
+
rb_define_method(rb_cMarkdown, "to_groff_mm", rb_markdown_to_groff_mm, -1);
|
36
84
|
}
|
37
85
|
|
38
86
|
// vim: ts=4 sw=4
|
data/ext/markdown_lib.h
CHANGED
@@ -3,10 +3,10 @@
|
|
3
3
|
#include <glib.h>
|
4
4
|
|
5
5
|
enum markdown_extensions {
|
6
|
-
EXT_SMART =
|
7
|
-
EXT_NOTES =
|
8
|
-
EXT_FILTER_HTML =
|
9
|
-
EXT_FILTER_STYLES =
|
6
|
+
EXT_SMART = 0x01,
|
7
|
+
EXT_NOTES = 0x02,
|
8
|
+
EXT_FILTER_HTML = 0x04,
|
9
|
+
EXT_FILTER_STYLES = 0x08
|
10
10
|
};
|
11
11
|
|
12
12
|
enum markdown_formats {
|
data/ext/markdown_output.c
CHANGED
@@ -734,6 +734,7 @@ static void print_groff_mm_element(GString *out, element *elt, int count) {
|
|
734
734
|
|
735
735
|
void print_element_list(GString *out, element *elt, int format, int exts) {
|
736
736
|
extensions = exts;
|
737
|
+
padded = 2; /* set padding to 2, so no extra blank lines at beginning */
|
737
738
|
switch (format) {
|
738
739
|
case HTML_FORMAT:
|
739
740
|
print_html_element_list(out, elt, false);
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rpeg-markdown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: "1.
|
4
|
+
version: "1.1"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Tomayko
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-08-
|
12
|
+
date: 2008-08-09 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|