epuber 0.10.1 → 0.10.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/Gemfile +1 -1
- data/lib/epuber/compiler/file_types/css_file.rb +21 -22
- data/lib/epuber/epubcheck.rb +28 -20
- data/lib/epuber/server.rb +1 -1
- data/lib/epuber/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c22c5e5a5820ba5dd1090ddc015276e877b4aa535d3b0cdd83c526a6604aa5b
|
4
|
+
data.tar.gz: c8ac2c195d24bfb1971656d64777b1849b1371d59506559942c00ac826b58963
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5bbc9209f434dd869bbc6ca75ebaf0eca0945597665e6d1fb984cdf3e11193e3b59ee284c89c5eb46abc3fc3932b7168282dc73340e72afc2419422d8da9918
|
7
|
+
data.tar.gz: bb1fe4b5fbad4f79d69b1f357ca58c58aaa7abd504b8c9fec96dd7b6105060a3ef53a93db579b0ef6ddb1565433c1d8f30dc8afbd484817dd92839aafb88109f
|
data/Gemfile
CHANGED
@@ -22,7 +22,7 @@ module Epuber
|
|
22
22
|
'src' => :font,
|
23
23
|
}.freeze
|
24
24
|
|
25
|
-
URL_REGEXP = /url\((
|
25
|
+
URL_REGEXP = /url\((.+?)\)/.freeze
|
26
26
|
|
27
27
|
# @param [Compiler::CompilationContext] compilation_context
|
28
28
|
#
|
@@ -55,30 +55,29 @@ module Epuber
|
|
55
55
|
# @type [CssParser::RuleSet::Declarations]
|
56
56
|
declarations = rule_set.instance_eval { @declarations }
|
57
57
|
declarations.each do |property, decl_value|
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
decl_value.to_s.scan(URL_REGEXP) do
|
59
|
+
url_function = Regexp.last_match(0)
|
60
|
+
path = Regexp.last_match(1)
|
61
|
+
if path.start_with?('"') && path.end_with?('"')
|
62
|
+
path = path[1..-2]
|
63
|
+
quote = '"'
|
64
|
+
end
|
65
|
+
if path.start_with?("'") && path.end_with?("'")
|
66
|
+
path = path[1..-2]
|
67
|
+
quote = "'"
|
68
|
+
end
|
61
69
|
|
62
|
-
|
63
|
-
if path.start_with?('"') && path.end_with?('"')
|
64
|
-
path = path[1..-2]
|
65
|
-
quote = '"'
|
66
|
-
end
|
67
|
-
if path.start_with?("'") && path.end_with?("'")
|
68
|
-
path = path[1..-2]
|
69
|
-
quote = "'"
|
70
|
-
end
|
70
|
+
next if path.start_with?('data:') || path.start_with?('http://') || path.start_with?('https://')
|
71
71
|
|
72
|
-
|
72
|
+
resource_group = DECLARATION_TO_FILE_GROUP_MAP[property]
|
73
|
+
new_url = SourceFile.resolve_relative_file(destination_path,
|
74
|
+
path,
|
75
|
+
compilation_context.file_resolver,
|
76
|
+
group: resource_group,
|
77
|
+
location: self)
|
73
78
|
|
74
|
-
|
75
|
-
|
76
|
-
path,
|
77
|
-
compilation_context.file_resolver,
|
78
|
-
group: resource_group,
|
79
|
-
location: self)
|
80
|
-
|
81
|
-
content = content.gsub(value, "url(#{quote}#{new_url}#{quote})") if new_url
|
79
|
+
content = content.gsub(url_function, "url(#{quote}#{new_url}#{quote})") if new_url
|
80
|
+
end
|
82
81
|
end
|
83
82
|
end
|
84
83
|
end
|
data/lib/epuber/epubcheck.rb
CHANGED
@@ -36,25 +36,6 @@ module Epuber
|
|
36
36
|
def error?
|
37
37
|
level == :error || level == :fatal
|
38
38
|
end
|
39
|
-
|
40
|
-
def self.from_json(json)
|
41
|
-
json_location = json['locations'].first
|
42
|
-
|
43
|
-
location = if json_location
|
44
|
-
Epuber::Location.new(
|
45
|
-
path: json_location['path'],
|
46
|
-
lineno: json_location['line'],
|
47
|
-
column: json_location['column'],
|
48
|
-
)
|
49
|
-
end
|
50
|
-
|
51
|
-
new(
|
52
|
-
level: json['severity'].downcase.to_sym,
|
53
|
-
code: json['ID'],
|
54
|
-
message: json['message'],
|
55
|
-
location: location,
|
56
|
-
)
|
57
|
-
end
|
58
39
|
end
|
59
40
|
|
60
41
|
class << self
|
@@ -76,14 +57,41 @@ module Epuber
|
|
76
57
|
report
|
77
58
|
end
|
78
59
|
|
60
|
+
# Parse json from epubcheck
|
61
|
+
#
|
79
62
|
# @param [String] string json string
|
80
63
|
# @return [Report]
|
81
64
|
#
|
82
65
|
def _parse_json(string)
|
83
66
|
json = JSON.parse(string)
|
84
67
|
messages = json['messages']
|
68
|
+
problems = messages
|
69
|
+
.map { |msg| _parse_locations(msg) }
|
70
|
+
.flatten
|
71
|
+
|
72
|
+
Report.new(problems: problems)
|
73
|
+
end
|
85
74
|
|
86
|
-
|
75
|
+
# Parse all problems from single message
|
76
|
+
#
|
77
|
+
# @param [Hash] json
|
78
|
+
# @return [Array<Problem>]
|
79
|
+
#
|
80
|
+
def _parse_locations(json)
|
81
|
+
json['locations'].map do |json_location|
|
82
|
+
location = Epuber::Location.new(
|
83
|
+
path: json_location['path'],
|
84
|
+
lineno: json_location['line'],
|
85
|
+
column: json_location['column'],
|
86
|
+
)
|
87
|
+
|
88
|
+
Problem.new(
|
89
|
+
level: json['severity'].downcase.to_sym,
|
90
|
+
code: json['ID'],
|
91
|
+
message: json['message'],
|
92
|
+
location: location,
|
93
|
+
)
|
94
|
+
end
|
87
95
|
end
|
88
96
|
end
|
89
97
|
end
|
data/lib/epuber/server.rb
CHANGED
data/lib/epuber/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: epuber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roman Kříž
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -597,7 +597,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
597
597
|
- !ruby/object:Gem::Version
|
598
598
|
version: '0'
|
599
599
|
requirements: []
|
600
|
-
rubygems_version: 3.5.
|
600
|
+
rubygems_version: 3.5.18
|
601
601
|
signing_key:
|
602
602
|
specification_version: 4
|
603
603
|
summary: Epuber is simple tool to compile and pack source files into EPUB format.
|