md_to_bbcode 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/md_to_bbcode.rb +6 -8
- data/lib/md_to_bbcode/version.rb +1 -1
- data/spec/api_spec.rb +13 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3879a85ee622be55cd4e43e0a882b2330478a552f0e5c239ade8fbf3bace621a
|
4
|
+
data.tar.gz: 5e5b9dfe539a0e38f6a1a70ea1cde9a4980a0292d24927d40c4ab2d2116ee24b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f732c4557d7ddc4b3d3662290ceb531f36ef50a8c18c20d7bdcee81d2313d7f2dd1d8bb5e8df2bbd4f079a3016c5d43b5fa72165b9f259c7db207dfba16e7a87
|
7
|
+
data.tar.gz: 4330680e4ab619d63b7c6b9698cf4ddee3d8e66f8466b60a8b559016b41447f7a58f69e77f917bad0e48bcc22f1221d28d1db0ee350b07449042670df9830174
|
data/lib/md_to_bbcode.rb
CHANGED
@@ -62,14 +62,12 @@ module MdToBbcode
|
|
62
62
|
else
|
63
63
|
field.gsub!(/\*(\S.*?)\*/, '[i]\1[/i]')
|
64
64
|
end
|
65
|
-
if field =~
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
in_italic_text = true
|
72
|
-
end
|
65
|
+
if in_italic_text && field =~ /.*\S\*.*/
|
66
|
+
field.gsub!(/(.*\S)\*(.*)/, '\1[/i]\2')
|
67
|
+
in_italic_text = false
|
68
|
+
elsif !in_italic_text && field =~ /.*\*\S.*/
|
69
|
+
field.gsub!(/(.*)\*(\S.*)/, '\1[i]\2')
|
70
|
+
in_italic_text = true
|
73
71
|
end
|
74
72
|
field
|
75
73
|
end
|
data/lib/md_to_bbcode/version.rb
CHANGED
data/spec/api_spec.rb
CHANGED
@@ -24,6 +24,19 @@ describe MdToBbcode do
|
|
24
24
|
expect('*Italic text*'.md_to_bbcode).to eq '[i]Italic text[/i]'
|
25
25
|
end
|
26
26
|
|
27
|
+
it 'converts italic text after a list' do
|
28
|
+
md = <<~EOS
|
29
|
+
* List item
|
30
|
+
*Italic text*
|
31
|
+
EOS
|
32
|
+
expect(md.md_to_bbcode).to eq(<<~EOS)
|
33
|
+
[list]
|
34
|
+
[*]List item
|
35
|
+
[/list]
|
36
|
+
[i]Italic text[/i]
|
37
|
+
EOS
|
38
|
+
end
|
39
|
+
|
27
40
|
it 'converts italic and bold mixed text' do
|
28
41
|
expect('*Italic and **bold** text* and then **bold and *italic* text**'.md_to_bbcode).to eq '[i]Italic and [b]bold[/b] text[/i] and then [b]bold and [i]italic[/i] text[/b]'
|
29
42
|
end
|