bb-ruby 1.2.2 → 1.3.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG +5 -0
- data/lib/bb-ruby.rb +12 -4
- data/lib/bb-ruby/version.rb +1 -1
- data/test/bb-ruby_test.rb +9 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e425b7b6390fbaa0035e4055b12a3b8321731152
|
4
|
+
data.tar.gz: f9872b3a94f7d1056b95a584a94bae4034ef6e88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d48ec523dd3bba11fb0b89e276d3bd6108fc564b5e61f39dacfb8585fde58cbee50dcacd507a2bd1f091e9e08c5a6dadcbf71b68a668fd84312d4c5eecc72ba0
|
7
|
+
data.tar.gz: ad743f27403f0b04a0623a1c677d6a5cc216f632b29c9abcdf14682b7837abc64bf318e6d4f73d5850e5d535514b547607b5aaf7c61e942c5a03538c8e2599e9
|
data/CHANGELOG
CHANGED
data/lib/bb-ruby.rb
CHANGED
@@ -40,7 +40,7 @@ module BBRuby
|
|
40
40
|
/\[ins(:.+)?\](.*?)\[\/ins\1?\]/mi,
|
41
41
|
'<ins>\2</ins>',
|
42
42
|
'Inserted Text',
|
43
|
-
'[ins]inserted text[/
|
43
|
+
'[ins]inserted text[/ins]',
|
44
44
|
:insert],
|
45
45
|
'Code' => [
|
46
46
|
/\[code(:.+)?\](.*?)\[\/code\1?\]/mi,
|
@@ -76,7 +76,7 @@ module BBRuby
|
|
76
76
|
/\[li\](.*?)\[\/li\]/mi,
|
77
77
|
'<li>\1</li>',
|
78
78
|
'List item',
|
79
|
-
'
|
79
|
+
'[li]list item[/li]',
|
80
80
|
:listitem],
|
81
81
|
'List Item (alternative)' => [
|
82
82
|
/\[\*(:[^\[]+)?\]([^(\[|\<)]+)/mi,
|
@@ -118,7 +118,7 @@ module BBRuby
|
|
118
118
|
/\[dd\](.*?)\[\/dd\]/mi,
|
119
119
|
'<dd>\1</dd>',
|
120
120
|
'Definition definitions',
|
121
|
-
'[dd]my definition[/dd',
|
121
|
+
'[dd]my definition[/dd]',
|
122
122
|
:definition],
|
123
123
|
'Quote' => [
|
124
124
|
/\[quote(:.*)?=(?:")?(.*?)(?:")?\](.*?)\[\/quote\1?\]/mi,
|
@@ -315,6 +315,11 @@ module BBRuby
|
|
315
315
|
@@tags
|
316
316
|
end
|
317
317
|
|
318
|
+
# Checks if text contains any bb tag
|
319
|
+
def any_bb_tags?(text)
|
320
|
+
tag_list.map{|k,v| v[0]}.any?{|regex| text.match(regex) }
|
321
|
+
end
|
322
|
+
|
318
323
|
private
|
319
324
|
|
320
325
|
def process_tags(text, tags_alternative_definition={}, escape_html=true, method=:disable, *tags)
|
@@ -373,7 +378,6 @@ module BBRuby
|
|
373
378
|
|
374
379
|
end
|
375
380
|
|
376
|
-
|
377
381
|
class String
|
378
382
|
# Convert a string with BBCode markup into its corresponding HTML markup
|
379
383
|
#
|
@@ -435,4 +439,8 @@ class String
|
|
435
439
|
def bbcode_to_html_with_formatting!(tags_alternative_definition = {}, escape_html=true, method=:disable, *tags)
|
436
440
|
self.replace(BBRuby.to_html_with_formatting(self, tags_alternative_definition, escape_html, method, *tags))
|
437
441
|
end
|
442
|
+
|
443
|
+
def bbcode_formatted?
|
444
|
+
BBRuby.any_bb_tags?(self)
|
445
|
+
end
|
438
446
|
end
|
data/lib/bb-ruby/version.rb
CHANGED
data/test/bb-ruby_test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
#coding: utf-8
|
3
3
|
|
4
|
-
|
4
|
+
require_relative 'test_helper.rb'
|
5
5
|
|
6
6
|
class TestBBRuby < Test::Unit::TestCase
|
7
7
|
|
@@ -352,4 +352,12 @@ class TestBBRuby < Test::Unit::TestCase
|
|
352
352
|
def test_center_with_url
|
353
353
|
assert_equal '<div style="text-align: center;">hello <a href="http://www.test.com">www.test.com</a></div>', '[center]hello www.test.com[/center]'.bbcode_to_html
|
354
354
|
end
|
355
|
+
|
356
|
+
def test_any_tag_inclusion_from_examples
|
357
|
+
examples = BBRuby.tag_list.map{|k,v| v[3]}
|
358
|
+
examples.each do |example|
|
359
|
+
assert_equal true, example.bbcode_formatted?
|
360
|
+
end
|
361
|
+
assert_equal false, "There is no bb tags in this sentence!".bbcode_formatted?
|
362
|
+
end
|
355
363
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bb-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Craig P. Jolicoeur
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|