rdiscount 1.6.5 → 1.6.8

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.
@@ -0,0 +1,34 @@
1
+ BUILDING rdiscount
2
+ ==================
3
+
4
+ You'll be needing Ruby, rake, and a basic build environment.
5
+
6
+ Build the rdiscount extension for tests and local development:
7
+
8
+ $ rake build
9
+
10
+ Use your rdiscount working copy when running ruby programs:
11
+
12
+ $ export RUBYLIB=~/rdiscount/lib:$RUBYLIB
13
+ $ ruby some-program.rb
14
+
15
+ Gathering changes from an upstream Orc/discount.git clone requires first
16
+ grabbing the discount submodule into the root of the project and then running
17
+ the rake gather task to copy discount source files into the ext/ directory:
18
+
19
+ $ git submodule init
20
+ Submodule 'discount' (git://github.com/rtomayko/discount.git) registered for path 'discount'
21
+ $ rake gather
22
+ $ rake build
23
+
24
+ The rtomayko/discount.git repository's master branch is the default submodule
25
+ head. It exists to merge branches for rdiscount specific patches to the upstream
26
+ discount codebase.
27
+
28
+ Do work in the submodule and then add a remote for your clone THAT YOU FORKED ON
29
+ GITHUB BECAUSE YOU'RE GOING TO SEND ME A PULL REQUEST. After you've committed
30
+ your great changes somewhere, push them up with:
31
+
32
+ $ cd discount
33
+ $ git remote add you git@github.com:you/discount.git
34
+ $ git push you HEAD:topic-branch-name
@@ -31,7 +31,10 @@ The RDiscount sources are available via Git:
31
31
  $ cd rdiscount
32
32
  $ rake --tasks
33
33
 
34
+ See the file [BUILDING][] for hacking instructions.
35
+
34
36
  [gemcutter]: http://gemcutter.org/gems/rdiscount
37
+ [BUILDING]: BUILDING
35
38
 
36
39
  USAGE
37
40
  -----
data/Rakefile CHANGED
@@ -8,7 +8,7 @@ task :default => :test
8
8
  # Ruby Extension
9
9
  # ==========================================================
10
10
 
11
- DLEXT = Config::CONFIG['DLEXT']
11
+ DLEXT = Config::MAKEFILE_CONFIG['DLEXT']
12
12
  RUBYDIGEST = Digest::MD5.hexdigest(`#{RUBY} --version`)
13
13
 
14
14
  file "ext/ruby-#{RUBYDIGEST}" do |f|
@@ -109,7 +109,7 @@ CLEAN.include 'doc'
109
109
  # ==========================================================
110
110
 
111
111
  desc 'Gather required discount sources into extension directory'
112
- task :gather => 'discount' do |t|
112
+ task :gather => 'discount/markdown.h' do |t|
113
113
  files =
114
114
  FileList[
115
115
  'discount/{markdown,mkdio,amalloc,cstring,tags}.h',
@@ -121,22 +121,8 @@ task :gather => 'discount' do |t|
121
121
  cp 'discount/markdown.7', 'man/'
122
122
  end
123
123
 
124
- # best. task. ever.
125
- file 'discount' do |f|
126
- STDERR.puts((<<-TEXT).gsub(/^ +/, ''))
127
- Sorry, this operation requires a human. Tell your human to:
128
-
129
- Grab a discount tarball from:
130
- http://www.pell.portland.or.us/~orc/Code/discount/
131
-
132
- Extract here with something like:
133
- tar xvzf discount-1.2.9.tar.gz
134
-
135
- Create a discount symlink pointing at the version directory:
136
- ln -hsf discount-1.2.9 discount
137
-
138
- TEXT
139
- fail "discount sources required."
124
+ file 'discount/markdown.h' do |t|
125
+ abort "The discount submodule is required. See the file BUILDING for getting set up."
140
126
  end
141
127
 
142
128
  # PACKAGING =================================================================
@@ -18,7 +18,7 @@
18
18
  #include "amalloc.h"
19
19
 
20
20
  typedef int (*stfu)(const void*,const void*);
21
-
21
+ typedef void (*spanhandler)(MMIOT*,int);
22
22
 
23
23
  /* forward declarations */
24
24
  static void text(MMIOT *f);
@@ -164,16 +164,6 @@ Qprintf(MMIOT *f, char *fmt, ...)
164
164
  }
165
165
 
166
166
 
167
- /* Qcopy()
168
- */
169
- static void
170
- Qcopy(int count, MMIOT *f)
171
- {
172
- while ( count-- > 0 )
173
- Qchar(pull(f), f);
174
- }
175
-
176
-
177
167
  /* Qem()
178
168
  */
179
169
  static void
@@ -272,12 +262,12 @@ parenthetical(int in, int out, MMIOT *f)
272
262
  for ( indent=1,size=0; indent; size++ ) {
273
263
  if ( (c = pull(f)) == EOF )
274
264
  return EOF;
275
- else if ( c == in )
276
- ++indent;
277
- else if ( (c == '\\') && (peek(f,1) == out) ) {
265
+ else if ( (c == '\\') && (peek(f,1) == out || peek(f,1) == in) ) {
278
266
  ++size;
279
267
  pull(f);
280
268
  }
269
+ else if ( c == in )
270
+ ++indent;
281
271
  else if ( c == out )
282
272
  --indent;
283
273
  }
@@ -664,11 +654,11 @@ mangle(char *s, int len, MMIOT *f)
664
654
  /* nrticks() -- count up a row of tick marks
665
655
  */
666
656
  static int
667
- nrticks(int offset, MMIOT *f)
657
+ nrticks(int offset, int tickchar, MMIOT *f)
668
658
  {
669
659
  int tick = 0;
670
660
 
671
- while ( peek(f, offset+tick) == '`' ) tick++;
661
+ while ( peek(f, offset+tick) == tickchar ) tick++;
672
662
 
673
663
  return tick;
674
664
  } /* nrticks */
@@ -677,36 +667,34 @@ nrticks(int offset, MMIOT *f)
677
667
  /* matchticks() -- match a certain # of ticks, and if that fails
678
668
  * match the largest subset of those ticks.
679
669
  *
680
- * if a subset was matched, modify the passed in
681
- * # of ticks so that the caller (text()) can
682
- * appropriately process the horrible thing.
670
+ * if a subset was matched, return the # of ticks
671
+ * that were matched.
683
672
  */
684
673
  static int
685
- matchticks(MMIOT *f, int *ticks)
674
+ matchticks(MMIOT *f, int tickchar, int ticks, int *endticks)
686
675
  {
687
- int size, tick, c;
676
+ int size, count, c;
688
677
  int subsize=0, subtick=0;
689
678
 
690
- for (size = *ticks; (c=peek(f,size)) != EOF; ) {
691
- if ( c == '`' )
692
- if ( (tick=nrticks(size,f)) == *ticks )
679
+ *endticks = ticks;
680
+ for (size = 0; (c=peek(f,size+ticks)) != EOF; size ++) {
681
+ if ( (c == tickchar) && ( count = nrticks(size+ticks,tickchar,f)) ) {
682
+ if ( count == ticks )
693
683
  return size;
694
- else {
695
- if ( tick > subtick ) {
684
+ else if ( count ) {
685
+ if ( (count > subtick) && (count < ticks) ) {
696
686
  subsize = size;
697
- subtick = tick;
687
+ subtick = count;
698
688
  }
699
- size += tick;
689
+ size += count;
700
690
  }
701
- else
702
- size++;
691
+ }
703
692
  }
704
693
  if ( subsize ) {
705
- *ticks = subtick;
694
+ *endticks = subtick;
706
695
  return subsize;
707
696
  }
708
697
  return 0;
709
-
710
698
  } /* matchticks */
711
699
 
712
700
 
@@ -727,13 +715,24 @@ code(MMIOT *f, char *s, int length)
727
715
  } /* code */
728
716
 
729
717
 
718
+ /* delspan() -- write out a chunk of text, blocking with <del>...</del>
719
+ */
720
+ static void
721
+ delspan(MMIOT *f, int size)
722
+ {
723
+ Qstring("<del>", f);
724
+ ___mkd_reparse(cursor(f)-1, size, 0, f);
725
+ Qstring("</del>", f);
726
+ }
727
+
728
+
730
729
  /* codespan() -- write out a chunk of text as code, trimming one
731
730
  * space off the front and/or back as appropriate.
732
731
  */
733
732
  static void
734
733
  codespan(MMIOT *f, int size)
735
734
  {
736
- int i=0, c;
735
+ int i=0;
737
736
 
738
737
  if ( size > 1 && peek(f, size-1) == ' ' ) --size;
739
738
  if ( peek(f,i) == ' ' ) ++i, --size;
@@ -864,7 +863,7 @@ maybe_tag_or_link(MMIOT *f)
864
863
  }
865
864
  else if ( isspace(c) )
866
865
  break;
867
- else if ( ! (c == '/' || isalnum(c) ) )
866
+ else if ( ! (c == '/' || c == '-' || c == '_' || isalnum(c) ) )
868
867
  maybetag=0;
869
868
  }
870
869
 
@@ -1058,6 +1057,30 @@ smartypants(int c, int *flags, MMIOT *f)
1058
1057
  } /* smartypants */
1059
1058
 
1060
1059
 
1060
+ /* process a body of text encased in some sort of tick marks. If it
1061
+ * works, generate the output and return 1, otherwise just return 0 and
1062
+ * let the caller figure it out.
1063
+ */
1064
+ static int
1065
+ tickhandler(MMIOT *f, int tickchar, int minticks, spanhandler spanner)
1066
+ {
1067
+ int endticks, size;
1068
+ int tick = nrticks(0, tickchar, f);
1069
+
1070
+ if ( (tick >= minticks) && (size = matchticks(f,tickchar,tick,&endticks)) ) {
1071
+ if ( endticks < tick ) {
1072
+ size += (tick - endticks);
1073
+ tick = endticks;
1074
+ }
1075
+
1076
+ shift(f, tick);
1077
+ (*spanner)(f,size);
1078
+ shift(f, size+tick-1);
1079
+ return 1;
1080
+ }
1081
+ return 0;
1082
+ }
1083
+
1061
1084
  #define tag_text(f) (f->flags & INSIDE_TAG)
1062
1085
 
1063
1086
 
@@ -1151,21 +1174,12 @@ text(MMIOT *f)
1151
1174
  }
1152
1175
  break;
1153
1176
 
1154
- case '`': if ( tag_text(f) )
1177
+ case '~': if ( (f->flags & (NOSTRIKETHROUGH|INSIDE_TAG|STRICT)) || !tickhandler(f,c,2,delspan) )
1155
1178
  Qchar(c, f);
1156
- else {
1157
- int size, tick = nrticks(0, f);
1179
+ break;
1158
1180
 
1159
- if ( size = matchticks(f, &tick) ) {
1160
- shift(f, tick);
1161
- codespan(f, size-tick);
1162
- shift(f, size-1);
1163
- }
1164
- else {
1165
- Qchar(c, f);
1166
- Qcopy(tick-1, f);
1167
- }
1168
- }
1181
+ case '`': if ( tag_text(f) || !tickhandler(f,c,1,codespan) )
1182
+ Qchar(c, f);
1169
1183
  break;
1170
1184
 
1171
1185
  case '\\': switch ( c = pull(f) ) {
@@ -1333,8 +1347,8 @@ static int
1333
1347
  printblock(Paragraph *pp, MMIOT *f)
1334
1348
  {
1335
1349
  Line *t = pp->text;
1336
- static char *Begin[] = { "", "<p>", "<center>" };
1337
- static char *End[] = { "", "</p>","</center>" };
1350
+ static char *Begin[] = { "", "<p>", "<p style=\"text-align:center;\">" };
1351
+ static char *End[] = { "", "</p>","</p>" };
1338
1352
 
1339
1353
  while (t) {
1340
1354
  if ( S(t->text) ) {
@@ -86,6 +86,7 @@ typedef struct mmiot {
86
86
  #define NO_PSEUDO_PROTO 0x0040
87
87
  #define CDATA_OUTPUT 0x0080
88
88
  #define NOTABLES 0x0400
89
+ #define NOSTRIKETHROUGH 0x0800
89
90
  #define TOC 0x1000
90
91
  #define MKD_1_COMPAT 0x2000
91
92
  #define AUTOLINK 0x4000
@@ -74,6 +74,7 @@ extern char markdown_version[];
74
74
  #define MKD_NO_EXT 0x0040 /* don't allow pseudo-protocols */
75
75
  #define MKD_CDATA 0x0080 /* generate code for xml ![CDATA[...]] */
76
76
  #define MKD_NOTABLES 0x0400 /* disallow tables */
77
+ #define MKD_NOSTRIKETHROUGH 0x0800/* forbid ~~strikethrough~~ */
77
78
  #define MKD_TOC 0x1000 /* do table-of-contents processing */
78
79
  #define MKD_1_COMPAT 0x2000 /* compatability with MarkdownTest_1.0 */
79
80
  #define MKD_AUTOLINK 0x4000 /* make http://foo.com link even without <>s */
data/ext/tags.c CHANGED
@@ -83,6 +83,7 @@ mkd_prepare_tags()
83
83
  KW("CENTER");
84
84
  KW("DFN");
85
85
  KW("DIV");
86
+ KW("OBJECT");
86
87
  KW("H1");
87
88
  KW("H2");
88
89
  KW("H3");
@@ -24,7 +24,7 @@
24
24
  # end
25
25
  #
26
26
  class RDiscount
27
- VERSION = '1.6.5'
27
+ VERSION = '1.6.8'
28
28
 
29
29
  # Original Markdown formatted text.
30
30
  attr_reader :text
@@ -1,18 +1,20 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'rdiscount'
3
- s.version = '1.6.5'
3
+ s.version = '1.6.8'
4
4
  s.summary = "Fast Implementation of Gruber's Markdown in C"
5
- s.date = '2010-06-15'
5
+ s.date = '2011-01-25'
6
6
  s.email = 'rtomayko@gmail.com'
7
7
  s.homepage = 'http://github.com/rtomayko/rdiscount'
8
8
  s.has_rdoc = true
9
9
  s.authors = ["Ryan Tomayko", "David Loren Parsons", "Andrew White"]
10
10
  # = MANIFEST =
11
11
  s.files = %w[
12
+ BUILDING
12
13
  COPYING
13
14
  README.markdown
14
15
  Rakefile
15
16
  bin/rdiscount
17
+ discount
16
18
  ext/Csio.c
17
19
  ext/amalloc.h
18
20
  ext/basename.c
@@ -103,4 +103,9 @@ EOS
103
103
  rd = RDiscount.new("[foo](id:bar)", :no_pseudo_protocols)
104
104
  assert_equal "<p>[foo](id:bar)</p>\n", rd.to_html
105
105
  end
106
+
107
+ def test_that_tags_can_have_dashes_and_underscores
108
+ rd = RDiscount.new("foo <asdf-qwerty>bar</asdf-qwerty> and <a_b>baz</a_b>")
109
+ assert_equal "<p>foo <asdf-qwerty>bar</asdf-qwerty> and <a_b>baz</a_b></p>\n", rd.to_html
110
+ end
106
111
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdiscount
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 31
4
5
  prerelease: false
5
6
  segments:
6
7
  - 1
7
8
  - 6
8
- - 5
9
- version: 1.6.5
9
+ - 8
10
+ version: 1.6.8
10
11
  platform: ruby
11
12
  authors:
12
13
  - Ryan Tomayko
@@ -16,7 +17,7 @@ autorequire:
16
17
  bindir: bin
17
18
  cert_chain: []
18
19
 
19
- date: 2010-06-15 00:00:00 -07:00
20
+ date: 2011-01-25 00:00:00 -08:00
20
21
  default_executable:
21
22
  dependencies: []
22
23
 
@@ -29,6 +30,7 @@ extensions:
29
30
  extra_rdoc_files:
30
31
  - COPYING
31
32
  files:
33
+ - BUILDING
32
34
  - COPYING
33
35
  - README.markdown
34
36
  - Rakefile
@@ -75,23 +77,27 @@ rdoc_options: []
75
77
  require_paths:
76
78
  - lib
77
79
  required_ruby_version: !ruby/object:Gem::Requirement
80
+ none: false
78
81
  requirements:
79
82
  - - ">="
80
83
  - !ruby/object:Gem::Version
84
+ hash: 3
81
85
  segments:
82
86
  - 0
83
87
  version: "0"
84
88
  required_rubygems_version: !ruby/object:Gem::Requirement
89
+ none: false
85
90
  requirements:
86
91
  - - ">="
87
92
  - !ruby/object:Gem::Version
93
+ hash: 3
88
94
  segments:
89
95
  - 0
90
96
  version: "0"
91
97
  requirements: []
92
98
 
93
99
  rubyforge_project: wink
94
- rubygems_version: 1.3.6
100
+ rubygems_version: 1.3.7
95
101
  signing_key:
96
102
  specification_version: 3
97
103
  summary: Fast Implementation of Gruber's Markdown in C