markabb 1.0.0 → 1.0.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.md CHANGED
@@ -9,9 +9,26 @@ To get the latest stable version install the gem by adding
9
9
 
10
10
  to your Gemfile
11
11
 
12
- ## Documentation
12
+ ## Usage
13
13
 
14
- See the [Wiki](https://github.com/Arcath/Markabb/wiki) for the documentation.
14
+ Before you can use Markabb you need to configure it. To do this create an intializer (config/intializers in rails) and pass a block to Markabb.configure like this:
15
+
16
+ Markabb.configure do |c|
17
+ end
18
+
19
+ `c` is an instance of Markabb::Config which is used by Markabb when ever you parse a string. You can pass any config options you want here.
20
+
21
+ To parse a string simply call `.markabb` on it e.g.
22
+
23
+ "[b]foo[/b] [i]bar[/i]".markabb # => <b>foo</b><i>bar</i>
24
+
25
+ If you need to configure Markabb for a one off parse e.g. if you want to disable links when parsing a forum post etc... to do that pass a block to `Markabb.parse`
26
+
27
+ Markabb.parse "[b]foo[/b] [i]bar[/i]" do |c|
28
+ c.disable_bold = true
29
+ end # => [b]foo[/b] <i>bar</i>
30
+
31
+ See the [Wiki](https://github.com/Arcath/Markabb/wiki) for instructions on Markabbs more advanced features like custom tags, callbacks and syntax highlighting.
15
32
 
16
33
  ## Developing & Testing
17
34
 
@@ -14,6 +14,13 @@ require "markabb/classes/syntax_highlighter"
14
14
  # Highlighters
15
15
  require "markabb/highlighters/coderay"
16
16
  require "markabb/highlighters/raw"
17
+ # Tags
18
+ require "markabb/tags/formatting"
19
+ require "markabb/tags/image"
20
+ require "markabb/tags/link"
21
+ require "markabb/tags/list"
22
+ require "markabb/tags/nobbc"
23
+ require "markabb/tags/table"
17
24
 
18
25
  # Main Markabb Module, all code is a sub of this
19
26
  module Markabb
@@ -36,11 +43,3 @@ module Markabb
36
43
  module Highlighters
37
44
  end
38
45
  end
39
-
40
- # Tags
41
- require "markabb/tags/formatting"
42
- require "markabb/tags/image"
43
- require "markabb/tags/link"
44
- require "markabb/tags/list"
45
- require "markabb/tags/nobbc"
46
- require "markabb/tags/table"
@@ -50,7 +50,7 @@ module Markabb
50
50
  end
51
51
 
52
52
  def disable_html
53
- @output = @output.gsub("<","&lt;").gsub(">","&gt;")
53
+ @output = @output.gsub("<","&lt;").gsub(">","&gt;").gsub(/"/, "&quot;")
54
54
  end
55
55
 
56
56
  def add_line_breaks
@@ -13,4 +13,4 @@ list_callback = Markabb::Callback.new(Proc.new { |s|
13
13
  Markabb.register_tag :un_ordered, Markabb::Tag.new('ul', '<ul>\1</ul>'), :lists
14
14
  Markabb.register_tag :ordered, Markabb::Tag.new('ol', '<ol>\1</ol>'), :lists
15
15
  Markabb.register_tag :list_item, Markabb::Tag.new('li', '<li>\1</li>'), :lists
16
- Markabb.register_tag :smart_list, Markabb::Tag.new(/\[list\](.*?)\[\/list\]/, list_callback), :lists
16
+ Markabb.register_tag :smart_list, Markabb::Tag.new('list', list_callback), :lists
@@ -1,4 +1,4 @@
1
1
  module Markabb
2
2
  # Markabbs Version Number
3
- VERSION = "1.0.0"
3
+ VERSION = "1.0.1"
4
4
  end
@@ -17,4 +17,9 @@ describe "Link Tags" do
17
17
  default_config
18
18
  Markabb.parse("[url=http://www.example.com]Example[/url]").should eq('<a href="http://www.example.com" target="_BLANK">Example</a>')
19
19
  end
20
+
21
+ it "should prevent javascript injection" do
22
+ default_config
23
+ Markabb.parse('[url=" onclick="foo]Injected[/url]').should_not eq "<a href=\"\" onclick=\"foo\" target=\"_BLANK\">Injected</a>"
24
+ end
20
25
  end
metadata CHANGED
@@ -1,68 +1,71 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: markabb
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 1
7
- - 0
8
- - 0
9
- version: 1.0.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Adam "Arcath" Laycock
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2012-07-12 00:00:00 +01:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2013-02-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: rspec
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- segments:
28
- - 0
29
- version: "0"
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
30
22
  type: :development
31
- version_requirements: *id001
32
- - !ruby/object:Gem::Dependency
33
- name: yard
34
23
  prerelease: false
35
- requirement: &id002 !ruby/object:Gem::Requirement
36
- requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- segments:
40
- - 0
41
- version: "0"
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: yard
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
42
38
  type: :development
43
- version_requirements: *id002
44
- - !ruby/object:Gem::Dependency
45
- name: coderay
46
39
  prerelease: false
47
- requirement: &id003 !ruby/object:Gem::Requirement
48
- requirements:
49
- - - ">="
50
- - !ruby/object:Gem::Version
51
- segments:
52
- - 0
53
- version: "0"
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: coderay
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
54
  type: :runtime
55
- version_requirements: *id003
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
56
62
  description: Provides BBCode for Ruby and Rails
57
- email:
63
+ email:
58
64
  - gems@arcath.net
59
65
  executables: []
60
-
61
66
  extensions: []
62
-
63
67
  extra_rdoc_files: []
64
-
65
- files:
68
+ files:
66
69
  - .gitignore
67
70
  - .travis.yml
68
71
  - Gemfile
@@ -102,37 +105,31 @@ files:
102
105
  - spec/tags/link_spec.rb
103
106
  - spec/tags/list_spec.rb
104
107
  - spec/tags/table_spec.rb
105
- has_rdoc: true
106
108
  homepage: http://markabb.arcath.net
107
109
  licenses: []
108
-
109
110
  post_install_message:
110
111
  rdoc_options: []
111
-
112
- require_paths:
112
+ require_paths:
113
113
  - lib
114
- required_ruby_version: !ruby/object:Gem::Requirement
115
- requirements:
116
- - - ">="
117
- - !ruby/object:Gem::Version
118
- segments:
119
- - 0
120
- version: "0"
121
- required_rubygems_version: !ruby/object:Gem::Requirement
122
- requirements:
123
- - - ">="
124
- - !ruby/object:Gem::Version
125
- segments:
126
- - 0
127
- version: "0"
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ none: false
116
+ requirements:
117
+ - - ! '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
128
126
  requirements: []
129
-
130
127
  rubyforge_project:
131
- rubygems_version: 1.3.6
128
+ rubygems_version: 1.8.23
132
129
  signing_key:
133
130
  specification_version: 3
134
131
  summary: Provides BBCode for Ruby and Rails
135
- test_files:
132
+ test_files:
136
133
  - spec/highlighters/coderay_spec.rb
137
134
  - spec/highlighters/raw_spec.rb
138
135
  - spec/macros/formatting_macros.rb
@@ -148,3 +145,4 @@ test_files:
148
145
  - spec/tags/link_spec.rb
149
146
  - spec/tags/list_spec.rb
150
147
  - spec/tags/table_spec.rb
148
+ has_rdoc: