Skip to content

Commit

Permalink
Merge pull request #159 from mojavelinux/issue-158
Browse files Browse the repository at this point in the history
resolves #158 preprocess theme data to properly support hex colors
  • Loading branch information
mojavelinux committed May 27, 2015
2 parents f503edb + 79cbab1 commit 46d443f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/asciidoctor-pdf/theme_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class ThemeLoader
DataDir = ::File.expand_path ::File.join(::File.dirname(__FILE__), '..', '..', 'data')
ThemesDir = ::File.join DataDir, 'themes'
FontsDir = ::File.join DataDir, 'fonts'
HexColorValueRx = /_color: (?<quote>"|'|)#?(?<value>[A-Za-z0-9]{3,6})\k<quote>$/

def self.resolve_theme_file theme_name = nil, theme_path = nil
theme_name ||= 'default'
Expand All @@ -31,7 +32,8 @@ def self.load_theme theme_name = nil, theme_path = nil
end

def self.load_file filename
self.new.load (::SafeYAML.load_file filename)
data = ::IO.read(filename).each_line.map {|l| l.sub(HexColorValueRx, '_color: \'\k<value>\'') }.join
self.new.load(::SafeYAML.load(data))
end

def load hash
Expand Down Expand Up @@ -112,7 +114,6 @@ def evaluate_math expr
def to_hex value
str = value.to_s
return str if str == 'transparent'
str = str[1..-1] if str.start_with? '#'
hex = case str.size
when 6
str
Expand Down

0 comments on commit 46d443f

Please # to comment.