markup_parser 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
File without changes
@@ -0,0 +1,33 @@
1
+ # Adds classes to String class...
2
+ class String
3
+ puts "\n**************\nString Extensions loaded\n**************\n"
4
+
5
+ # Corrects the gh code block syntax mistake where one would write '~~~ .ruby'
6
+ # and the correct code should be '~~~ruby'
7
+ def correct_gh_code_syntax!
8
+ self.gsub!(/~~~\s\.([a-zA-Z]*)/, '~~~\1')
9
+ end
10
+
11
+ # Corrects the ol list elements: which only except the syntax: '1. ...'.
12
+ # Corrected syntaxes: '1)'
13
+ def correct_ol_list_parenth!
14
+ self.gsub!(/(\s*)(\d)\)/,'\1\2.')
15
+ end
16
+
17
+ # Converts tabs (\t) to 2 spaces
18
+ def convert_tabs_to_spaces!
19
+ self.gsub!(/\t/, " ")
20
+ end
21
+
22
+ # Standardize line endings
23
+ def standardize_newlines!
24
+ self.gsub!("\r\n", "\n")
25
+ self.gsub!("\r", "\n")
26
+ end
27
+
28
+ # Corrects the newlines by stripping the leading whitespace.
29
+ # NOTE: this is a hack to workaround the strange Gollum editor indentation behavior
30
+ def sub_newlines!
31
+ self.gsub!(/([\r\n|\n])[\ ]*(.)/,'\1\2')
32
+ end
33
+ end
@@ -0,0 +1,7 @@
1
+ # HTML renderer with Ultraviolet Code Lexer
2
+ class UvHtmlRender < Redcarpet::Render::HTML
3
+ puts "\n**************\nUvHtmlRender loaded\n**************\n"
4
+ def block_code(code, language)
5
+ Uv.parse(code, "xhtml", language, false, "railscasts")
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module MarkupParser
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1,81 @@
1
+ require 'minitest/autorun'
2
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
3
+ require 'markup_parser'
4
+
5
+ describe MarkupParser do
6
+ before do
7
+ create_test_markup_parser
8
+ MarkupParser.reload_parsers
9
+ end
10
+ after do
11
+ tear_down_test_markup_parser
12
+ end
13
+
14
+ describe "PARSER_PATH" do
15
+ it "is a string" do
16
+ MarkupParser::PARSER_PATH.must_be_instance_of String
17
+ end
18
+ end
19
+
20
+ describe "formats" do
21
+ it "returns all formats" do
22
+ MarkupParser.formats.must_be_instance_of Array
23
+ MarkupParser.formats.must_include "test_markup"
24
+ end
25
+ it "wont include 'version'" do
26
+ MarkupParser.formats.wont_include "version"
27
+ end
28
+ end
29
+
30
+ describe "parsers" do
31
+ it "returns all formats" do
32
+ MarkupParser.parsers.must_be_instance_of Array
33
+ MarkupParser.parsers.must_include MarkupParser::TestMarkup
34
+ end
35
+ end
36
+
37
+ describe "format_parsers" do
38
+ it "returns a hash with format {'format': Class}" do
39
+ MarkupParser.format_parsers.must_be_instance_of Hash
40
+ MarkupParser.format_parsers['test_markup'].must_equal MarkupParser::TestMarkup
41
+ end
42
+ end
43
+ end
44
+
45
+
46
+ def create_test_markup_parser
47
+ test_markup_contents = <<-CONTENT
48
+ module MarkupParser
49
+ class TestMarkup < MarkupParser::Default
50
+
51
+
52
+ private
53
+
54
+ # Markup specific Parser invokation
55
+ def parse(text)
56
+ text + " was parsed"
57
+ end
58
+
59
+ # Performs my html hotfixes
60
+ def hot_fixes(text)
61
+ text = text + " was hotfixed"
62
+ end
63
+
64
+ end
65
+ end
66
+ CONTENT
67
+ output = %x[
68
+ cd #{MarkupParser::PARSER_PATH}
69
+ touch test_markup.rb
70
+ echo \'#{test_markup_contents}\' > test_markup.rb
71
+ ]
72
+ #puts output
73
+ end
74
+
75
+ def tear_down_test_markup_parser
76
+ output = %x[
77
+ cd #{MarkupParser::PARSER_PATH}
78
+ rm test_markup.rb
79
+ ]
80
+ #puts output
81
+ end
@@ -0,0 +1,28 @@
1
+ require 'minitest/autorun'
2
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
3
+ require 'markup_parser'
4
+
5
+ describe MarkupParser::Default do
6
+
7
+ class MarkupParser::Default
8
+ def hot_fixes(text)
9
+ text + ' hot_fixes'
10
+ end
11
+ end
12
+
13
+ describe "initialize" do
14
+ it "accets 1 argument" do
15
+ MarkupParser::Default.new('arg1').must_be_instance_of MarkupParser::Default
16
+ Proc.new {MarkupParser::Default.new('arg1','arg2')}.must_raise ArgumentError
17
+ end
18
+ it "calls hot_fixes" do
19
+ MarkupParser::Default.new('arg1').original_text.must_match "hot_fixes"
20
+ end
21
+ end
22
+
23
+
24
+ it "successfully outputs text" do
25
+ MarkupParser::Default.new('test text').to_html.must_match /test text/
26
+ end
27
+
28
+ end
@@ -0,0 +1,34 @@
1
+ require 'minitest/autorun'
2
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
3
+ require 'markup_parser'
4
+
5
+ describe "other markup_parsers" do #'specs/markup_parsers/parser_files/README.*'
6
+ Dir[File.join(File.dirname(__FILE__), 'parser_files','README.*')].each do |readme|
7
+ next if readme =~ /html$/
8
+ format = readme.split('/').last.gsub(/^README\./, '')
9
+
10
+ define_method "#{format}_spec" do
11
+ source = File.read(readme)
12
+
13
+ expected_file = "#{readme}.html"
14
+ expected = File.read(expected_file)
15
+ parser_class = MarkupParser.format_parsers[format]
16
+ actual = parser_class.new(File.read(readme))
17
+
18
+ if source != expected
19
+ source.wont_equal actual, "#{format} did not render anything"
20
+ end
21
+
22
+ diff = IO.popen("diff -u - #{expected_file}", 'r+') do |f|
23
+ f.write actual
24
+ f.close_write
25
+ f.read
26
+ end
27
+
28
+ actual.must_equal expected, <<-message
29
+ #{File.basename expected_file}'s contents don't match command output:
30
+ #{diff}
31
+ message
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,2 @@
1
+ * One
2
+ * Two
@@ -0,0 +1,4 @@
1
+ <ul>
2
+ <li>One</li>
3
+ <li>Two</li>
4
+ </ul>
@@ -0,0 +1,6 @@
1
+ * One
2
+ * Two
3
+
4
+ This is an {absolute link}[http://github.com]. So is this: http://github.com
5
+
6
+ This is a {relative link}[link:rawr.html]. So is this: link:rawr.html
@@ -0,0 +1,11 @@
1
+ <ul><li>
2
+ <p>One</p>
3
+ </li><li>
4
+ <p>Two</p>
5
+ </li></ul>
6
+
7
+ <p>This is an <a href="http://github.com">absolute link</a>. So is this: <a
8
+ href="http://github.com">github.com</a></p>
9
+
10
+ <p>This is a <a href="rawr.html">relative link</a>. So is this: <a
11
+ href="rawr.html">rawr.html</a></p>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markup_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-09-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: redcarpet
16
- requirement: &70241141367760 !ruby/object:Gem::Requirement
16
+ requirement: &70189660941240 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 2.0.0b5
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70241141367760
24
+ version_requirements: *70189660941240
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: nokogiri
27
- requirement: &70241141367300 !ruby/object:Gem::Requirement
27
+ requirement: &70189660940820 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70241141367300
35
+ version_requirements: *70189660940820
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: uv
38
- requirement: &70241141366840 !ruby/object:Gem::Requirement
38
+ requirement: &70189660940340 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70241141366840
46
+ version_requirements: *70189660940340
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rdoc
49
- requirement: &70241141366300 !ruby/object:Gem::Requirement
49
+ requirement: &70189660939580 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70241141366300
57
+ version_requirements: *70189660939580
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rake
60
- requirement: &70241141365600 !ruby/object:Gem::Requirement
60
+ requirement: &70189660939000 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70241141365600
68
+ version_requirements: *70189660939000
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: minitest
71
- requirement: &70241141364920 !ruby/object:Gem::Requirement
71
+ requirement: &70189660938400 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70241141364920
79
+ version_requirements: *70189660938400
80
80
  description: ! 'Standardized markup parsers to use a single format: an object. Instantiate
81
81
  a specific markup class with text to output formated Html. Allows for easy code
82
82
  block highlighting using a Proc; defaults to Uv (ruby Ultraviolet)'
@@ -93,9 +93,19 @@ files:
93
93
  - lib/markup_parser/default.rb
94
94
  - lib/markup_parser/html.rb
95
95
  - lib/markup_parser/markdown.rb
96
+ - lib/markup_parser/markdown/class_methods.rb
97
+ - lib/markup_parser/markdown/string_extensions.rb
98
+ - lib/markup_parser/markdown/uv_html_render.rb
96
99
  - lib/markup_parser/rdoc.rb
97
100
  - lib/markup_parser/version.rb
98
101
  - markup_parser.gemspec
102
+ - specs/markup_parser_spec.rb
103
+ - specs/markup_parsers/default_spec.rb
104
+ - specs/markup_parsers/other_spec.rb
105
+ - specs/markup_parsers/parser_files/README.markdown
106
+ - specs/markup_parsers/parser_files/README.markdown.html
107
+ - specs/markup_parsers/parser_files/README.rdoc
108
+ - specs/markup_parsers/parser_files/README.rdoc.html
99
109
  homepage: https://github.com/chaffeqa/markup_parser
100
110
  licenses: []
101
111
  post_install_message: