bluecloth 2.0.6.pre120-x86-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. data/ChangeLog +363 -0
  2. data/LICENSE +27 -0
  3. data/LICENSE.discount +47 -0
  4. data/README +81 -0
  5. data/Rakefile +349 -0
  6. data/Rakefile.local +43 -0
  7. data/bin/bluecloth +84 -0
  8. data/ext/Csio.c +61 -0
  9. data/ext/VERSION +1 -0
  10. data/ext/amalloc.h +29 -0
  11. data/ext/bluecloth.c +391 -0
  12. data/ext/bluecloth.h +19 -0
  13. data/ext/config.h +55 -0
  14. data/ext/css.c +76 -0
  15. data/ext/cstring.h +75 -0
  16. data/ext/docheader.c +43 -0
  17. data/ext/extconf.rb +52 -0
  18. data/ext/generate.c +1602 -0
  19. data/ext/markdown.c +1078 -0
  20. data/ext/markdown.h +146 -0
  21. data/ext/mkdio.c +303 -0
  22. data/ext/mkdio.h +79 -0
  23. data/ext/resource.c +155 -0
  24. data/ext/version.c +28 -0
  25. data/ext/xml.c +82 -0
  26. data/ext/xmlpage.c +48 -0
  27. data/lib/1.8/bluecloth_ext.so +0 -0
  28. data/lib/1.9/bluecloth_ext.so +0 -0
  29. data/lib/bluecloth.rb +164 -0
  30. data/rake/191_compat.rb +26 -0
  31. data/rake/dependencies.rb +76 -0
  32. data/rake/helpers.rb +434 -0
  33. data/rake/hg.rb +273 -0
  34. data/rake/manual.rb +782 -0
  35. data/rake/packaging.rb +126 -0
  36. data/rake/publishing.rb +269 -0
  37. data/rake/rdoc.rb +30 -0
  38. data/rake/style.rb +62 -0
  39. data/rake/svn.rb +668 -0
  40. data/rake/testing.rb +187 -0
  41. data/rake/verifytask.rb +64 -0
  42. data/rake/win32.rb +190 -0
  43. data/spec/bluecloth/101_changes_spec.rb +141 -0
  44. data/spec/bluecloth/autolinks_spec.rb +49 -0
  45. data/spec/bluecloth/blockquotes_spec.rb +145 -0
  46. data/spec/bluecloth/code_spans_spec.rb +164 -0
  47. data/spec/bluecloth/emphasis_spec.rb +164 -0
  48. data/spec/bluecloth/entities_spec.rb +65 -0
  49. data/spec/bluecloth/hrules_spec.rb +90 -0
  50. data/spec/bluecloth/images_spec.rb +92 -0
  51. data/spec/bluecloth/inline_html_spec.rb +238 -0
  52. data/spec/bluecloth/links_spec.rb +171 -0
  53. data/spec/bluecloth/lists_spec.rb +294 -0
  54. data/spec/bluecloth/paragraphs_spec.rb +75 -0
  55. data/spec/bluecloth/titles_spec.rb +305 -0
  56. data/spec/bluecloth_spec.rb +281 -0
  57. data/spec/bugfix_spec.rb +172 -0
  58. data/spec/contributions_spec.rb +85 -0
  59. data/spec/data/antsugar.txt +34 -0
  60. data/spec/data/markdowntest/Amps and angle encoding.html +17 -0
  61. data/spec/data/markdowntest/Amps and angle encoding.text +21 -0
  62. data/spec/data/markdowntest/Auto links.html +18 -0
  63. data/spec/data/markdowntest/Auto links.text +13 -0
  64. data/spec/data/markdowntest/Backslash escapes.html +118 -0
  65. data/spec/data/markdowntest/Backslash escapes.text +120 -0
  66. data/spec/data/markdowntest/Blockquotes with code blocks.html +15 -0
  67. data/spec/data/markdowntest/Blockquotes with code blocks.text +11 -0
  68. data/spec/data/markdowntest/Code Blocks.html +18 -0
  69. data/spec/data/markdowntest/Code Blocks.text +14 -0
  70. data/spec/data/markdowntest/Code Spans.html +5 -0
  71. data/spec/data/markdowntest/Code Spans.text +5 -0
  72. data/spec/data/markdowntest/Hard-wrapped paragraphs with list-like lines.html +8 -0
  73. data/spec/data/markdowntest/Hard-wrapped paragraphs with list-like lines.text +8 -0
  74. data/spec/data/markdowntest/Horizontal rules.html +71 -0
  75. data/spec/data/markdowntest/Horizontal rules.text +67 -0
  76. data/spec/data/markdowntest/Inline HTML (Advanced).html +15 -0
  77. data/spec/data/markdowntest/Inline HTML (Advanced).text +15 -0
  78. data/spec/data/markdowntest/Inline HTML (Simple).html +72 -0
  79. data/spec/data/markdowntest/Inline HTML (Simple).text +69 -0
  80. data/spec/data/markdowntest/Inline HTML comments.html +13 -0
  81. data/spec/data/markdowntest/Inline HTML comments.text +13 -0
  82. data/spec/data/markdowntest/Links, inline style.html +11 -0
  83. data/spec/data/markdowntest/Links, inline style.text +12 -0
  84. data/spec/data/markdowntest/Links, reference style.html +52 -0
  85. data/spec/data/markdowntest/Links, reference style.text +71 -0
  86. data/spec/data/markdowntest/Links, shortcut references.html +9 -0
  87. data/spec/data/markdowntest/Links, shortcut references.text +20 -0
  88. data/spec/data/markdowntest/Literal quotes in titles.html +3 -0
  89. data/spec/data/markdowntest/Literal quotes in titles.text +7 -0
  90. data/spec/data/markdowntest/Markdown Documentation - Basics.html +314 -0
  91. data/spec/data/markdowntest/Markdown Documentation - Basics.text +306 -0
  92. data/spec/data/markdowntest/Markdown Documentation - Syntax.html +942 -0
  93. data/spec/data/markdowntest/Markdown Documentation - Syntax.text +888 -0
  94. data/spec/data/markdowntest/Nested blockquotes.html +9 -0
  95. data/spec/data/markdowntest/Nested blockquotes.text +5 -0
  96. data/spec/data/markdowntest/Ordered and unordered lists.html +148 -0
  97. data/spec/data/markdowntest/Ordered and unordered lists.text +131 -0
  98. data/spec/data/markdowntest/Strong and em together.html +7 -0
  99. data/spec/data/markdowntest/Strong and em together.text +7 -0
  100. data/spec/data/markdowntest/Tabs.html +25 -0
  101. data/spec/data/markdowntest/Tabs.text +21 -0
  102. data/spec/data/markdowntest/Tidyness.html +8 -0
  103. data/spec/data/markdowntest/Tidyness.text +5 -0
  104. data/spec/data/ml-announce.txt +17 -0
  105. data/spec/data/re-overflow.txt +67 -0
  106. data/spec/data/re-overflow2.txt +281 -0
  107. data/spec/discount_spec.rb +184 -0
  108. data/spec/lib/constants.rb +5 -0
  109. data/spec/lib/helpers.rb +137 -0
  110. data/spec/lib/matchers.rb +235 -0
  111. data/spec/markdowntest_spec.rb +79 -0
  112. metadata +205 -0
data/ext/resource.c ADDED
@@ -0,0 +1,155 @@
1
+ /* markdown: a C implementation of John Gruber's Markdown markup language.
2
+ *
3
+ * Copyright (C) 2007 David L Parsons.
4
+ * The redistribution terms are provided in the COPYRIGHT file that must
5
+ * be distributed with this source code.
6
+ */
7
+ #include <stdio.h>
8
+ #include <string.h>
9
+ #include <stdarg.h>
10
+ #include <stdlib.h>
11
+ #include <time.h>
12
+ #include <ctype.h>
13
+
14
+ #include "config.h"
15
+
16
+ #include "cstring.h"
17
+ #include "markdown.h"
18
+ #include "amalloc.h"
19
+
20
+ /* free a (single) line
21
+ */
22
+ void
23
+ ___mkd_freeLine(Line *ptr)
24
+ {
25
+ DELETE(ptr->text);
26
+ free(ptr);
27
+ }
28
+
29
+
30
+ /* free a list of lines
31
+ */
32
+ void
33
+ ___mkd_freeLines(Line *p)
34
+ {
35
+ if (p->next)
36
+ ___mkd_freeLines(p->next);
37
+ ___mkd_freeLine(p);
38
+ }
39
+
40
+
41
+ /* bye bye paragraph.
42
+ */
43
+ void
44
+ ___mkd_freeParagraph(Paragraph *p)
45
+ {
46
+ if (p->next)
47
+ ___mkd_freeParagraph(p->next);
48
+ if (p->down)
49
+ ___mkd_freeParagraph(p->down);
50
+ if (p->text)
51
+ ___mkd_freeLines(p->text);
52
+ if (p->ident)
53
+ free(p->ident);
54
+ free(p);
55
+ }
56
+
57
+
58
+ /* bye bye footnote.
59
+ */
60
+ void
61
+ ___mkd_freefootnote(Footnote *f)
62
+ {
63
+ DELETE(f->tag);
64
+ DELETE(f->link);
65
+ DELETE(f->title);
66
+ }
67
+
68
+
69
+ /* bye bye footnotes.
70
+ */
71
+ void
72
+ ___mkd_freefootnotes(MMIOT *f)
73
+ {
74
+ int i;
75
+
76
+ if ( f->footnotes ) {
77
+ for (i=0; i < S(*f->footnotes); i++)
78
+ ___mkd_freefootnote( &T(*f->footnotes)[i] );
79
+ DELETE(*f->footnotes);
80
+ free(f->footnotes);
81
+ }
82
+ }
83
+
84
+
85
+ /* initialize a new MMIOT
86
+ */
87
+ void
88
+ ___mkd_initmmiot(MMIOT *f, void *footnotes)
89
+ {
90
+ if ( f ) {
91
+ memset(f, 0, sizeof *f);
92
+ CREATE(f->in);
93
+ CREATE(f->out);
94
+ CREATE(f->Q);
95
+ if ( footnotes )
96
+ f->footnotes = footnotes;
97
+ else {
98
+ f->footnotes = malloc(sizeof f->footnotes[0]);
99
+ CREATE(*f->footnotes);
100
+ }
101
+ }
102
+ }
103
+
104
+
105
+ /* free the contents of a MMIOT, but leave the object alone.
106
+ */
107
+ void
108
+ ___mkd_freemmiot(MMIOT *f, void *footnotes)
109
+ {
110
+ if ( f ) {
111
+ DELETE(f->in);
112
+ DELETE(f->out);
113
+ DELETE(f->Q);
114
+ if ( f->footnotes != footnotes )
115
+ ___mkd_freefootnotes(f);
116
+ memset(f, 0, sizeof *f);
117
+ }
118
+ }
119
+
120
+
121
+ /* free lines up to an barrier.
122
+ */
123
+ void
124
+ ___mkd_freeLineRange(Line *anchor, Line *stop)
125
+ {
126
+ Line *r = anchor->next;
127
+
128
+ if ( r != stop ) {
129
+ while ( r && (r->next != stop) )
130
+ r = r->next;
131
+ if ( r ) r->next = 0;
132
+ ___mkd_freeLines(anchor->next);
133
+ }
134
+ anchor->next = 0;
135
+ }
136
+
137
+
138
+ /* clean up everything allocated in __mkd_compile()
139
+ */
140
+ void
141
+ mkd_cleanup(Document *doc)
142
+ {
143
+ if ( doc ) {
144
+ if ( doc->ctx ) {
145
+ ___mkd_freemmiot(doc->ctx, 0);
146
+ free(doc->ctx);
147
+ }
148
+
149
+ if ( doc->code) ___mkd_freeParagraph(doc->code);
150
+ if ( doc->headers ) ___mkd_freeLines(doc->headers);
151
+ if ( T(doc->content) ) ___mkd_freeLines(T(doc->content));
152
+ memset(doc, 0, sizeof doc[0]);
153
+ free(doc);
154
+ }
155
+ }
data/ext/version.c ADDED
@@ -0,0 +1,28 @@
1
+ #include "config.h"
2
+
3
+ char markdown_version[] = VERSION
4
+ #if DL_TAG_EXTENSION
5
+ " DL_TAG"
6
+ #endif
7
+ #if PANDOC_HEADER
8
+ " HEADER"
9
+ #endif
10
+ #if 4 != 4
11
+ " TAB=4"
12
+ #endif
13
+ #if USE_AMALLOC
14
+ " DEBUG"
15
+ #endif
16
+ #if SUPERSCRIPT
17
+ " SUPERSCRIPT"
18
+ #endif
19
+ #if RELAXED_EMPHASIS
20
+ " RELAXED"
21
+ #endif
22
+ #if DIV_QUOTE
23
+ " DIV"
24
+ #endif
25
+ #if ALPHA_LIST
26
+ " AL"
27
+ #endif
28
+ ;
data/ext/xml.c ADDED
@@ -0,0 +1,82 @@
1
+ /* markdown: a C implementation of John Gruber's Markdown markup language.
2
+ *
3
+ * Copyright (C) 2007 David L Parsons.
4
+ * The redistribution terms are provided in the COPYRIGHT file that must
5
+ * be distributed with this source code.
6
+ */
7
+ #include <stdio.h>
8
+ #include <string.h>
9
+ #include <stdarg.h>
10
+ #include <stdlib.h>
11
+ #include <time.h>
12
+ #include <ctype.h>
13
+
14
+ #include "config.h"
15
+
16
+ #include "cstring.h"
17
+ #include "markdown.h"
18
+ #include "amalloc.h"
19
+
20
+ /* return the xml version of a character
21
+ */
22
+ static char *
23
+ mkd_xmlchar(unsigned char c)
24
+ {
25
+ switch (c) {
26
+ case '<': return "&lt;";
27
+ case '>': return "&gt;";
28
+ case '&': return "&amp;";
29
+ case '"': return "&quot;";
30
+ case '\'': return "&apos;";
31
+ default: if ( isascii(c) || (c & 0x80) )
32
+ return 0;
33
+ return "";
34
+ }
35
+ }
36
+
37
+
38
+ /* write output in XML format
39
+ */
40
+ int
41
+ mkd_generatexml(char *p, int size, FILE *out)
42
+ {
43
+ unsigned char c;
44
+ char *entity;
45
+
46
+ while ( size-- > 0 ) {
47
+ c = *p++;
48
+
49
+ if ( entity = mkd_xmlchar(c) )
50
+ fputs(entity, out);
51
+ else
52
+ fputc(c, out);
53
+ }
54
+ return 0;
55
+ }
56
+
57
+
58
+ /* build a xml'ed version of a string
59
+ */
60
+ int
61
+ mkd_xml(char *p, int size, char **res)
62
+ {
63
+ unsigned char c;
64
+ char *entity;
65
+ Cstring f;
66
+
67
+ CREATE(f);
68
+ RESERVE(f, 100);
69
+
70
+ while ( size-- > 0 ) {
71
+ c = *p++;
72
+ if ( entity = mkd_xmlchar(c) )
73
+ Cswrite(&f, entity, strlen(entity));
74
+ else
75
+ Csputc(c, &f);
76
+ }
77
+ /* HACK ALERT! HACK ALERT! HACK ALERT! */
78
+ *res = T(f); /* we know that a T(Cstring) is a character pointer */
79
+ /* so we can simply pick it up and carry it away, */
80
+ return S(f); /* leaving the husk of the Ctring on the stack */
81
+ /* END HACK ALERT */
82
+ }
data/ext/xmlpage.c ADDED
@@ -0,0 +1,48 @@
1
+ /*
2
+ * xmlpage -- write a skeletal xhtml page
3
+ *
4
+ * Copyright (C) 2007 David L Parsons.
5
+ * The redistribution terms are provided in the COPYRIGHT file that must
6
+ * be distributed with this source code.
7
+ */
8
+ #include "config.h"
9
+ #include <stdio.h>
10
+ #include <stdlib.h>
11
+ #include <ctype.h>
12
+
13
+ #include "cstring.h"
14
+ #include "markdown.h"
15
+ #include "amalloc.h"
16
+
17
+
18
+ int
19
+ mkd_xhtmlpage(Document *p, int flags, FILE *out)
20
+ {
21
+ char *title;
22
+ extern char *mkd_doc_title(Document *);
23
+
24
+ if ( mkd_compile(p, flags) ) {
25
+ fprintf(out, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
26
+ fprintf(out, "<!DOCTYPE html "
27
+ " PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\""
28
+ " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n");
29
+
30
+ fprintf(out, "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n");
31
+
32
+ fprintf(out, "<head>\n");
33
+ if ( title = mkd_doc_title(p) )
34
+ fprintf(out, "<title>%s</title>\n", title);
35
+ mkd_generatecss(p, out);
36
+ fprintf(out, "</head>\n");
37
+
38
+ fprintf(out, "<body>\n");
39
+ mkd_generatehtml(p, out);
40
+ fprintf(out, "</body>\n");
41
+ fprintf(out, "</html>\n");
42
+
43
+ mkd_cleanup(p);
44
+
45
+ return 0;
46
+ }
47
+ return -1;
48
+ }
Binary file
Binary file
data/lib/bluecloth.rb ADDED
@@ -0,0 +1,164 @@
1
+ #!/usr/bin/ruby
2
+
3
+ #
4
+ # Bluecloth is a Ruby implementation of Markdown, a text-to-HTML conversion
5
+ # tool.
6
+ #
7
+ # == Authors
8
+ #
9
+ # * Michael Granger <ged@FaerieMUD.org>
10
+ #
11
+ # == Contributors
12
+ #
13
+ # * Martin Chase <stillflame@FaerieMUD.org> - Peer review, helpful suggestions
14
+ # * Florian Gross <flgr@ccan.de> - Filter options, suggestions
15
+ #
16
+ # This product includes software developed by David Loren Parsons
17
+ # <http://www.pell.portland.or.us/~orc>.
18
+ #
19
+ # == Version
20
+ #
21
+ # $Id$
22
+ #
23
+ # == License
24
+ #
25
+ # :include: LICENSE
26
+ #--
27
+ # Please see the LICENSE file included in the distribution for copyright and licensing details.
28
+ #
29
+ class BlueCloth
30
+
31
+ # Release Version
32
+ VERSION = '2.0.6'
33
+
34
+ # The defaults for all supported options.
35
+ DEFAULT_OPTIONS = {
36
+ :remove_links => false,
37
+ :remove_images => false,
38
+ :smartypants => true,
39
+ :pseudoprotocols => false,
40
+ :pandoc_headers => false,
41
+ :header_labels => false,
42
+ :escape_html => false,
43
+ :strict_mode => true,
44
+ :auto_links => false,
45
+ :safe_links => false,
46
+ }.freeze
47
+
48
+ # The number of characters of the original markdown source to include in the
49
+ # output of #inspect
50
+ INSPECT_TEXT_LENGTH = 50
51
+
52
+
53
+ #################################################################
54
+ ### C L A S S M E T H O D S
55
+ #################################################################
56
+
57
+ ### Convert the specified +opthash+ into a flags bitmask. If it's already a
58
+ ### Fixnum (e.g., if someone passed in an ORed flags argument instead of an
59
+ ### opthash), just return it as-is.
60
+ def self::flags_from_opthash( opthash={} )
61
+ return opthash if opthash.is_a?( Integer )
62
+
63
+ # Support BlueCloth1-style options
64
+ if opthash == :filter_html || opthash == [:filter_html]
65
+ opthash = { :escape_html => true }
66
+ elsif opthash == :filter_styles
67
+ opthash = {}
68
+ elsif !opthash.is_a?( Hash )
69
+ raise ArgumentError, "option %p not supported" % [ opthash ]
70
+ end
71
+
72
+ flags = 0
73
+
74
+ if opthash[:remove_links] then flags |= MKD_NOLINKS; end
75
+ if opthash[:remove_images] then flags |= MKD_NOIMAGE; end
76
+ if ! opthash[:smartypants] then flags |= MKD_NOPANTS; end
77
+ if ! opthash[:pseudoprotocols] then flags |= MKD_NO_EXT; end
78
+ if ! opthash[:pandoc_headers] then flags |= MKD_NOHEADER; end
79
+ if opthash[:header_labels] then flags |= MKD_TOC; end
80
+ if opthash[:mdtest_1_compat] then flags |= MKD_1_COMPAT; end
81
+ if opthash[:escape_html] then flags |= MKD_NOHTML; end
82
+ if opthash[:strict_mode] then flags |= MKD_STRICT; end
83
+ if opthash[:tagtext_mode] then flags |= MKD_TAGTEXT; end
84
+ if opthash[:auto_links] then flags |= MKD_AUTOLINK; end
85
+ if opthash[:safe_links] then flags |= MKD_SAFELINK; end
86
+
87
+ return flags
88
+ end
89
+
90
+
91
+ ### Returns a Hash that reflects the settings from the specified +flags+ Integer.
92
+ def self::opthash_from_flags( flags=0 )
93
+ flags = flags.to_i
94
+
95
+ opthash = {}
96
+ if ( flags & MKD_NOLINKS ).nonzero? then opthash[:remove_links] = true; end
97
+ if ( flags & MKD_NOIMAGE ).nonzero? then opthash[:remove_images] = true; end
98
+ if !( flags & MKD_NOPANTS ).nonzero? then opthash[:smartypants] = true; end
99
+ if !( flags & MKD_NO_EXT ).nonzero? then opthash[:pseudoprotocols] = true; end
100
+ if !( flags & MKD_NOHEADER ).nonzero? then opthash[:pandoc_headers] = true; end
101
+ if ( flags & MKD_TOC ).nonzero? then opthash[:header_labels] = true; end
102
+ if ( flags & MKD_1_COMPAT ).nonzero? then opthash[:mdtest_1_compat] = true; end
103
+ if ( flags & MKD_NOHTML ).nonzero? then opthash[:escape_html] = true; end
104
+ if ( flags & MKD_STRICT ).nonzero? then opthash[:strict_mode] = true; end
105
+ if ( flags & MKD_TAGTEXT ).nonzero? then opthash[:tagtext_mode] = true; end
106
+ if ( flags & MKD_AUTOLINK ).nonzero? then opthash[:auto_links] = true; end
107
+ if ( flags & MKD_SAFELINK ).nonzero? then opthash[:safe_links] = true; end
108
+
109
+ return opthash
110
+ end
111
+
112
+
113
+ #################################################################
114
+ ### I N S T A N C E M E T H O D S
115
+ #################################################################
116
+
117
+ ### Return a human-readable representation of the object suitable for debugging.
118
+ def inspect
119
+ return "#<%s:0x%x text: %p; options: %p>" % [
120
+ self.class.name,
121
+ self.object_id / 2,
122
+ self.text.length > INSPECT_TEXT_LENGTH ?
123
+ self.text[ 0, INSPECT_TEXT_LENGTH - 5] + '[...]' :
124
+ self.text,
125
+ self.options,
126
+ ]
127
+ end
128
+
129
+
130
+ ### Backward-compatible method: return +true+ if the object's :escape_html option was
131
+ ### set.
132
+ def filter_html
133
+ return self.options[:escape_html]
134
+ end
135
+
136
+
137
+ ### Backward-compatible method: raises an appropriate error notifying the user that
138
+ ### BlueCloth2 doesn't support this option.
139
+ def filter_html=( arg )
140
+ raise NotImplementedError,
141
+ "Sorry, this version of BlueCloth no longer supports toggling of HTML filtering" +
142
+ "via #filter_html=. You now must create the BlueCloth object with the :escape_html" +
143
+ "option set to true instead."
144
+ end
145
+
146
+
147
+
148
+ end # class BlueCloth
149
+
150
+ # Load the correct version if it's a Windows binary gem
151
+ if RUBY_PLATFORM =~/(mswin|mingw)/i
152
+ major_minor = RUBY_VERSION[ /^(\d+\.\d+)/ ] or
153
+ raise "Oops, can't extract the major/minor version from #{RUBY_VERSION.dump}"
154
+ require "#{major_minor}/nokogiri"
155
+ else
156
+ require 'bluecloth_ext'
157
+ end
158
+
159
+
160
+
161
+ # Set the top-level 'Markdown' constant if it isn't already set
162
+ ::Markdown = ::BlueCloth unless defined?( ::Markdown )
163
+
164
+