ansispan 0.0.2 → 0.0.3
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/lib/ansispan.rb +14 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e055aa4ef747ae4516d9012a53b7cbf858a756f03b569dec8c8464a3d6c07468
|
4
|
+
data.tar.gz: ccb135e6640081d8d66297efb4aefc2465f13054d2e07d9fcf88d21c6786d6b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 866a67e0e0a990436f9acad587702d5642918e5413e837a7e1d3a58a2e35161c17c51107ca1a91b258139a01dd3f620e74a1fa08838d050aefc01c76e8162296
|
7
|
+
data.tar.gz: ad993a614bc5594ec3dc1c56a15e9746e88d4d02b2217991ed2ef2eb47a518fabbad129e5c71e6a1abce776e89ec6506d9eb73642251ee7c2f928fc5b3798dc6
|
data/lib/ansispan.rb
CHANGED
@@ -10,6 +10,13 @@ class Ansispan
|
|
10
10
|
'37': 'white'
|
11
11
|
}
|
12
12
|
|
13
|
+
@styles = {
|
14
|
+
'1': 'font-weight: bold;',
|
15
|
+
'3': 'font-style: italic;',
|
16
|
+
'4': 'text-decoration: underline;',
|
17
|
+
'9': 'text-decoration: line-through;',
|
18
|
+
}
|
19
|
+
|
13
20
|
def self.convert(str, escape_character: '\033')
|
14
21
|
escape_character = Regexp.escape(escape_character)
|
15
22
|
|
@@ -36,6 +43,13 @@ class Ansispan
|
|
36
43
|
str = str.gsub(/#{escape_character}\[1;#{ansi}m/, span)
|
37
44
|
end
|
38
45
|
|
46
|
+
# Text styles
|
47
|
+
@styles.keys.each do |ansi|
|
48
|
+
puts "\[1;#{ansi}m/"
|
49
|
+
span = '<span style="font-weight: bold;' + @styles[ansi] + '">'
|
50
|
+
str = str.gsub(/#{escape_character}\[1;#{ansi}m/, span)
|
51
|
+
end
|
52
|
+
|
39
53
|
# Underline colors
|
40
54
|
@foreground_colors.keys.each do |ansi|
|
41
55
|
span = '<span style="text-decoration: underline; color: ' + @foreground_colors[ansi] + '">'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ansispan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jelani Woods
|
@@ -36,7 +36,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
36
36
|
- !ruby/object:Gem::Version
|
37
37
|
version: '0'
|
38
38
|
requirements: []
|
39
|
-
rubygems_version: 3.
|
39
|
+
rubygems_version: 3.5.16
|
40
40
|
signing_key:
|
41
41
|
specification_version: 4
|
42
42
|
summary: Convert Terminal ansi colors to <span> tags with inline color styles.
|