bluecloth 2.0.7-x86-mingw32 → 2.0.11pre158-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.gemtest +0 -0
  3. data/History.md +4 -0
  4. data/LICENSE +1 -1
  5. data/Manifest.txt +103 -0
  6. data/README.md +103 -0
  7. data/Rakefile +95 -301
  8. data/ext/VERSION +1 -1
  9. data/ext/bluecloth.c +69 -23
  10. data/ext/bluecloth.h +13 -2
  11. data/ext/config.h +13 -2
  12. data/ext/css.c +14 -5
  13. data/ext/cstring.h +4 -2
  14. data/ext/docheader.c +13 -7
  15. data/ext/emmatch.c +188 -0
  16. data/ext/extconf.rb +7 -9
  17. data/ext/generate.c +333 -293
  18. data/ext/html5.c +24 -0
  19. data/ext/markdown.c +326 -185
  20. data/ext/markdown.h +52 -29
  21. data/ext/mkdio.c +82 -41
  22. data/ext/mkdio.h +44 -23
  23. data/ext/resource.c +4 -2
  24. data/ext/setup.c +47 -0
  25. data/ext/tags.c +123 -0
  26. data/ext/tags.h +19 -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 +77 -42
  30. data/spec/bluecloth/101_changes_spec.rb +18 -21
  31. data/spec/bluecloth/TEMPLATE +36 -0
  32. data/spec/bluecloth/autolinks_spec.rb +4 -7
  33. data/spec/bluecloth/blockquotes_spec.rb +20 -23
  34. data/spec/bluecloth/code_spans_spec.rb +2 -5
  35. data/spec/bluecloth/emphasis_spec.rb +2 -5
  36. data/spec/bluecloth/entities_spec.rb +2 -5
  37. data/spec/bluecloth/hrules_spec.rb +2 -5
  38. data/spec/bluecloth/images_spec.rb +2 -5
  39. data/spec/bluecloth/inline_html_spec.rb +26 -66
  40. data/spec/bluecloth/links_spec.rb +1 -5
  41. data/spec/bluecloth/lists_spec.rb +2 -5
  42. data/spec/bluecloth/paragraphs_spec.rb +2 -5
  43. data/spec/bluecloth/titles_spec.rb +2 -5
  44. data/spec/bluecloth_spec.rb +36 -22
  45. data/spec/bugfix_spec.rb +90 -10
  46. data/spec/contributions_spec.rb +2 -3
  47. data/spec/discount_spec.rb +50 -10
  48. data/spec/lib/helpers.rb +18 -117
  49. data/spec/lib/matchers.rb +7 -18
  50. data/spec/markdowntest_spec.rb +3 -39
  51. metadata +257 -143
  52. metadata.gz.sig +0 -0
  53. data/ChangeLog +0 -387
  54. data/README +0 -81
  55. data/Rakefile.local +0 -41
  56. data/rake/191_compat.rb +0 -26
  57. data/rake/dependencies.rb +0 -76
  58. data/rake/helpers.rb +0 -435
  59. data/rake/hg.rb +0 -273
  60. data/rake/manual.rb +0 -782
  61. data/rake/packaging.rb +0 -123
  62. data/rake/publishing.rb +0 -274
  63. data/rake/rdoc.rb +0 -30
  64. data/rake/style.rb +0 -62
  65. data/rake/svn.rb +0 -668
  66. data/rake/testing.rb +0 -187
  67. data/rake/verifytask.rb +0 -64
data/ext/resource.c CHANGED
@@ -140,14 +140,16 @@ ___mkd_freeLineRange(Line *anchor, Line *stop)
140
140
  void
141
141
  mkd_cleanup(Document *doc)
142
142
  {
143
- if ( doc ) {
143
+ if ( doc && (doc->magic == VALID_DOCUMENT) ) {
144
144
  if ( doc->ctx ) {
145
145
  ___mkd_freemmiot(doc->ctx, 0);
146
146
  free(doc->ctx);
147
147
  }
148
148
 
149
149
  if ( doc->code) ___mkd_freeParagraph(doc->code);
150
- if ( doc->headers ) ___mkd_freeLines(doc->headers);
150
+ if ( doc->title) ___mkd_freeLine(doc->title);
151
+ if ( doc->author) ___mkd_freeLine(doc->author);
152
+ if ( doc->date) ___mkd_freeLine(doc->date);
151
153
  if ( T(doc->content) ) ___mkd_freeLines(T(doc->content));
152
154
  memset(doc, 0, sizeof doc[0]);
153
155
  free(doc);
data/ext/setup.c ADDED
@@ -0,0 +1,47 @@
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 "config.h"
8
+
9
+ #include <stdio.h>
10
+ #include <string.h>
11
+ #include <stdarg.h>
12
+ #include <stdlib.h>
13
+ #include <time.h>
14
+ #include <ctype.h>
15
+
16
+ #include "cstring.h"
17
+ #include "markdown.h"
18
+ #include "amalloc.h"
19
+ #include "tags.h"
20
+
21
+ static int need_to_setup = 1;
22
+ static int need_to_initrng = 1;
23
+
24
+ void
25
+ mkd_initialize()
26
+ {
27
+
28
+ if ( need_to_initrng ) {
29
+ need_to_initrng = 0;
30
+ INITRNG(time(0));
31
+ }
32
+ if ( need_to_setup ) {
33
+ need_to_setup = 0;
34
+ mkd_prepare_tags();
35
+ }
36
+ }
37
+
38
+
39
+ void
40
+ mkd_shlib_destructor()
41
+ {
42
+ if ( !need_to_setup ) {
43
+ need_to_setup = 1;
44
+ mkd_deallocate_tags();
45
+ }
46
+ }
47
+
data/ext/tags.c ADDED
@@ -0,0 +1,123 @@
1
+ /* block-level tags for passing html blocks through the blender
2
+ */
3
+ #define __WITHOUT_AMALLOC 1
4
+ #include "cstring.h"
5
+ #include "tags.h"
6
+
7
+ STRING(struct kw) blocktags;
8
+
9
+
10
+ /* define a html block tag
11
+ */
12
+ void
13
+ mkd_define_tag(char *id, int selfclose)
14
+ {
15
+ struct kw *p = &EXPAND(blocktags);
16
+
17
+ p->id = id;
18
+ p->size = strlen(id);
19
+ p->selfclose = selfclose;
20
+ }
21
+
22
+
23
+ /* case insensitive string sort (for qsort() and bsearch() of block tags)
24
+ */
25
+ static int
26
+ casort(struct kw *a, struct kw *b)
27
+ {
28
+ if ( a->size != b->size )
29
+ return a->size - b->size;
30
+ return strncasecmp(a->id, b->id, b->size);
31
+ }
32
+
33
+
34
+ /* stupid cast to make gcc shut up about the function types being
35
+ * passed into qsort() and bsearch()
36
+ */
37
+ typedef int (*stfu)(const void*,const void*);
38
+
39
+
40
+ /* sort the list of html block tags for later searching
41
+ */
42
+ void
43
+ mkd_sort_tags()
44
+ {
45
+ qsort(T(blocktags), S(blocktags), sizeof(struct kw), (stfu)casort);
46
+ }
47
+
48
+
49
+
50
+ /* look for a token in the html block tag list
51
+ */
52
+ struct kw*
53
+ mkd_search_tags(char *pat, int len)
54
+ {
55
+ struct kw key;
56
+
57
+ key.id = pat;
58
+ key.size = len;
59
+
60
+ return bsearch(&key, T(blocktags), S(blocktags), sizeof key, (stfu)casort);
61
+ }
62
+
63
+
64
+ static int populated = 0;
65
+
66
+
67
+ /* load in the standard collection of html tags that markdown supports
68
+ */
69
+ void
70
+ mkd_prepare_tags()
71
+ {
72
+
73
+ #define KW(x) mkd_define_tag(x, 0)
74
+ #define SC(x) mkd_define_tag(x, 1)
75
+
76
+ if ( populated ) return;
77
+ populated = 1;
78
+
79
+ KW("STYLE");
80
+ KW("SCRIPT");
81
+ KW("ADDRESS");
82
+ KW("BDO");
83
+ KW("BLOCKQUOTE");
84
+ KW("CENTER");
85
+ KW("DFN");
86
+ KW("DIV");
87
+ KW("OBJECT");
88
+ KW("H1");
89
+ KW("H2");
90
+ KW("H3");
91
+ KW("H4");
92
+ KW("H5");
93
+ KW("H6");
94
+ KW("LISTING");
95
+ KW("NOBR");
96
+ KW("UL");
97
+ KW("P");
98
+ KW("OL");
99
+ KW("DL");
100
+ KW("PLAINTEXT");
101
+ KW("PRE");
102
+ KW("TABLE");
103
+ KW("WBR");
104
+ KW("XMP");
105
+ SC("HR");
106
+ SC("BR");
107
+ KW("IFRAME");
108
+ KW("MAP");
109
+
110
+ mkd_sort_tags();
111
+ } /* mkd_prepare_tags */
112
+
113
+
114
+ /* destroy the blocktags list (for shared libraries)
115
+ */
116
+ void
117
+ mkd_deallocate_tags()
118
+ {
119
+ if ( S(blocktags) > 0 ) {
120
+ populated = 0;
121
+ DELETE(blocktags);
122
+ }
123
+ } /* mkd_deallocate_tags */
data/ext/tags.h ADDED
@@ -0,0 +1,19 @@
1
+ /* block-level tags for passing html blocks through the blender
2
+ */
3
+ #ifndef _TAGS_D
4
+ #define _TAGS_D
5
+
6
+ struct kw {
7
+ char *id;
8
+ int size;
9
+ int selfclose;
10
+ } ;
11
+
12
+
13
+ struct kw* mkd_search_tags(char *, int);
14
+ void mkd_prepare_tags();
15
+ void mkd_deallocate_tags();
16
+ void mkd_sort_tags();
17
+ void mkd_define_tag(char *, int);
18
+
19
+ #endif
Binary file
Binary file
data/lib/bluecloth.rb CHANGED
@@ -18,7 +18,7 @@
18
18
  #
19
19
  # == Version
20
20
  #
21
- # $Id$
21
+ # $Id: bluecloth.rb,v fd890510cecf 2011/02/10 15:39:54 ged $
22
22
  #
23
23
  # == License
24
24
  #
@@ -29,20 +29,31 @@
29
29
  class BlueCloth
30
30
 
31
31
  # Release Version
32
- VERSION = '2.0.7'
32
+ VERSION = '2.0.11'
33
33
 
34
34
  # The defaults for all supported options.
35
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,
36
+ :alphalists => true,
37
+ :auto_links => false,
38
+ :definition_lists => false,
39
+ :divquotes => false,
40
+ :escape_html => false,
41
+ :expand_tabs => true,
42
+ :header_labels => false,
43
+ :mdtest_1_compat => false,
44
+ :pandoc_headers => false,
45
+ :pseudoprotocols => false,
46
+ :relaxed => false,
47
+ :remove_images => false,
48
+ :remove_links => false,
49
+ :safe_links => false,
50
+ :smartypants => true,
51
+ :strict_mode => true,
52
+ :strikethrough => true,
53
+ :superscript => false,
54
+ :tables => false,
55
+ :tagtext_mode => false,
56
+ :xml_cdata => false,
46
57
  }.freeze
47
58
 
48
59
  # The number of characters of the original markdown source to include in the
@@ -71,18 +82,27 @@ class BlueCloth
71
82
 
72
83
  flags = 0
73
84
 
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
85
+ if opthash[:remove_links] then flags |= MKD_NOLINKS; end
86
+ if opthash[:remove_images] then flags |= MKD_NOIMAGE; end
87
+ if ! opthash[:smartypants] then flags |= MKD_NOPANTS; end
88
+ if opthash[:escape_html] then flags |= MKD_NOHTML; end
89
+ if opthash[:strict_mode] then flags |= MKD_STRICT; end
90
+ if opthash[:tagtext_mode] then flags |= MKD_TAGTEXT; end
91
+ if ! opthash[:pseudoprotocols] then flags |= MKD_NO_EXT; end
92
+ if opthash[:xml_cdata] then flags |= MKD_CDATA; end
93
+ if ! opthash[:superscript] then flags |= MKD_NOSUPERSCRIPT; end
94
+ if ! opthash[:relaxed] then flags |= MKD_NORELAXED; end
95
+ if ! opthash[:tables] then flags |= MKD_NOTABLES; end
96
+ if ! opthash[:strikethrough] then flags |= MKD_NOSTRIKETHROUGH; end
97
+ if opthash[:header_labels] then flags |= MKD_TOC; end
98
+ if opthash[:mdtest_1_compat] then flags |= MKD_1_COMPAT; end
99
+ if opthash[:auto_links] then flags |= MKD_AUTOLINK; end
100
+ if opthash[:safe_links] then flags |= MKD_SAFELINK; end
101
+ if ! opthash[:pandoc_headers] then flags |= MKD_NOHEADER; end
102
+ if opthash[:expand_tabs] then flags |= MKD_TABSTOP; end
103
+ if ! opthash[:divquotes] then flags |= MKD_NODIVQUOTE; end
104
+ if ! opthash[:alphalists] then flags |= MKD_NOALPHALIST; end
105
+ if ! opthash[:definition_lists] then flags |= MKD_NODLIST; end
86
106
 
87
107
  return flags
88
108
  end
@@ -93,18 +113,27 @@ class BlueCloth
93
113
  flags = flags.to_i
94
114
 
95
115
  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
116
+ if ( flags & MKD_NOLINKS ).nonzero? then opthash[:remove_links] = true; end
117
+ if ( flags & MKD_NOIMAGE ).nonzero? then opthash[:remove_images] = true; end
118
+ if !( flags & MKD_NOPANTS ).nonzero? then opthash[:smartypants] = true; end
119
+ if ( flags & MKD_NOHTML ).nonzero? then opthash[:escape_html] = true; end
120
+ if ( flags & MKD_STRICT ).nonzero? then opthash[:strict_mode] = true; end
121
+ if ( flags & MKD_TAGTEXT ).nonzero? then opthash[:tagtext_mode] = true; end
122
+ if !( flags & MKD_NO_EXT ).nonzero? then opthash[:pseudoprotocols] = true; end
123
+ if ( flags & MKD_CDATA ).nonzero? then opthash[:xml_cdata] = true; end
124
+ if !( flags & MKD_NOSUPERSCRIPT ).nonzero? then opthash[:superscript] = true; end
125
+ if !( flags & MKD_NORELAXED ).nonzero? then opthash[:relaxed] = true; end
126
+ if !( flags & MKD_NOTABLES ).nonzero? then opthash[:tables] = true; end
127
+ if !( flags & MKD_NOSTRIKETHROUGH ).nonzero? then opthash[:strikethrough] = true; end
128
+ if ( flags & MKD_TOC ).nonzero? then opthash[:header_labels] = true; end
129
+ if ( flags & MKD_1_COMPAT ).nonzero? then opthash[:mdtest_1_compat] = true; end
130
+ if ( flags & MKD_AUTOLINK ).nonzero? then opthash[:auto_links] = true; end
131
+ if ( flags & MKD_SAFELINK ).nonzero? then opthash[:safe_links] = true; end
132
+ if !( flags & MKD_NOHEADER ).nonzero? then opthash[:pandoc_headers] = true; end
133
+ if ( flags & MKD_TABSTOP ).nonzero? then opthash[:expand_tabs] = true; end
134
+ if !( flags & MKD_NODIVQUOTE ).nonzero? then opthash[:divquotes] = true; end
135
+ if !( flags & MKD_NOALPHALIST ).nonzero? then opthash[:alphalists] = true; end
136
+ if !( flags & MKD_NODLIST ).nonzero? then opthash[:definition_lists] = true; end
108
137
 
109
138
  return opthash
110
139
  end
@@ -147,17 +176,23 @@ class BlueCloth
147
176
 
148
177
  end # class BlueCloth
149
178
 
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}/bluecloth_ext"
155
- else
179
+ begin
156
180
  require 'bluecloth_ext'
181
+ rescue LoadError => err
182
+ # If it's a Windows binary gem, try the <major>.<minor> subdirectory
183
+ if RUBY_PLATFORM =~/(mswin|mingw)/i
184
+ major_minor = RUBY_VERSION[ /^(\d+\.\d+)/ ] or
185
+ raise "Oops, can't extract the major/minor version from #{RUBY_VERSION.dump}"
186
+ require "#{major_minor}/bluecloth_ext"
187
+ else
188
+ raise
189
+ end
190
+
157
191
  end
158
192
 
159
193
 
160
194
 
195
+
161
196
  # Set the top-level 'Markdown' constant if it isn't already set
162
197
  ::Markdown = ::BlueCloth unless defined?( ::Markdown )
163
198
 
@@ -4,29 +4,26 @@
4
4
  BEGIN {
5
5
  require 'pathname'
6
6
  basedir = Pathname.new( __FILE__ ).dirname.parent.parent
7
-
7
+
8
8
  libdir = basedir + 'lib'
9
9
  extdir = basedir + 'ext'
10
-
10
+
11
+ $LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
11
12
  $LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
12
13
  $LOAD_PATH.unshift( extdir ) unless $LOAD_PATH.include?( extdir )
13
14
  }
14
15
 
15
- require 'spec'
16
+ require 'rspec'
16
17
  require 'bluecloth'
17
18
 
18
19
  require 'spec/lib/helpers'
19
- require 'spec/lib/constants'
20
- require 'spec/lib/matchers'
21
20
 
22
21
 
23
22
  #####################################################################
24
23
  ### C O N T E X T S
25
24
  #####################################################################
26
25
 
27
- describe BlueCloth, "1.0.1 changes" do
28
- include BlueCloth::TestConstants,
29
- BlueCloth::Matchers
26
+ describe BlueCloth, "after the 1.0.1 changes" do
30
27
 
31
28
  it "doesn't touch escapes in code blocks" do
32
29
  the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
@@ -35,16 +32,16 @@ describe BlueCloth, "1.0.1 changes" do
35
32
  formatting syntax. For example, if you wanted to surround a word with
36
33
  literal asterisks (instead of an HTML `<em>` tag), you can backslashes
37
34
  before the asterisks, like this:
38
-
35
+
39
36
  \\*literal asterisks\\*
40
-
37
+
41
38
  ---
42
39
  <p>Markdown allows you to use backslash escapes to generate literal
43
40
  characters which would otherwise have special meaning in Markdown's
44
41
  formatting syntax. For example, if you wanted to surround a word with
45
42
  literal asterisks (instead of an HTML <code>&lt;em&gt;</code> tag), you can backslashes
46
43
  before the asterisks, like this:</p>
47
-
44
+
48
45
  <pre><code>\\*literal asterisks\\*
49
46
  </code></pre>
50
47
  ---
@@ -62,11 +59,11 @@ describe BlueCloth, "1.0.1 changes" do
62
59
  it "converts reference-style links at or deeper than tab width to code blocks" do
63
60
  the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
64
61
  An [example][ex] reference-style link.
65
-
62
+
66
63
  [ex]: http://www.bluefi.com/
67
64
  ---
68
65
  <p>An [example][ex] reference-style link.</p>
69
-
66
+
70
67
  <pre><code>[ex]: http://www.bluefi.com/
71
68
  </code></pre>
72
69
  ---
@@ -114,23 +111,23 @@ describe BlueCloth, "1.0.1 changes" do
114
111
  it "correctly marks up header + list + code" do
115
112
  the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
116
113
  ## This is a header.
117
-
114
+
118
115
  1. This is the first list item.
119
116
  2. This is the second list item.
120
-
117
+
121
118
  Here's some example code:
122
-
119
+
123
120
  return shell_exec("echo $input | $markdown_script");
124
121
  ---
125
122
  <h2>This is a header.</h2>
126
-
123
+
127
124
  <ol>
128
- <li>This is the first list item.</li>
129
- <li>This is the second list item.</li>
125
+ <li> This is the first list item.</li>
126
+ <li> This is the second list item.</li>
130
127
  </ol>
131
-
128
+
132
129
  <p>Here's some example code:</p>
133
-
130
+
134
131
  <pre><code>return shell_exec("echo $input | $markdown_script");
135
132
  </code></pre>
136
133
  ---