mirror of
https://github.com/ralsina/tartrazine.git
synced 2024-09-20 07:21:22 +00:00
HTML formatter option: class_prefix
This commit is contained in:
parent
fd5af6ba3b
commit
4ced996f90
@ -26,7 +26,7 @@ module Tartrazine
|
|||||||
}]
|
}]
|
||||||
end
|
end
|
||||||
colorized = text.colorize
|
colorized = text.colorize
|
||||||
s.color.try { |c| colorized = colorized.fore(c.colorize) }
|
s.color.try { |col| colorized = colorized.fore(col.colorize) }
|
||||||
# Intentionally not setting background color
|
# Intentionally not setting background color
|
||||||
colorized.mode(:bold) if s.bold
|
colorized.mode(:bold) if s.bold
|
||||||
colorized.mode(:italic) if s.italic
|
colorized.mode(:italic) if s.italic
|
||||||
|
@ -5,8 +5,8 @@ module Tartrazine
|
|||||||
# Not all of these options are implemented
|
# Not all of these options are implemented
|
||||||
|
|
||||||
property? standalone : Bool = false
|
property? standalone : Bool = false
|
||||||
|
property class_prefix : String = ""
|
||||||
|
|
||||||
# property class_prefix : String = ""
|
|
||||||
# property with_classes : Bool = true
|
# property with_classes : Bool = true
|
||||||
# property tab_width = 8
|
# property tab_width = 8
|
||||||
# property surrounding_pre : Bool = true
|
# property surrounding_pre : Bool = true
|
||||||
@ -76,13 +76,13 @@ module Tartrazine
|
|||||||
|
|
||||||
# Given a token type, return the CSS class to use.
|
# Given a token type, return the CSS class to use.
|
||||||
def get_css_class(token, theme)
|
def get_css_class(token, theme)
|
||||||
return Abbreviations[token] if theme.styles.has_key?(token)
|
return class_prefix + Abbreviations[token] if theme.styles.has_key?(token)
|
||||||
|
|
||||||
# Themes don't contain information for each specific
|
# Themes don't contain information for each specific
|
||||||
# token type. However, they may contain information
|
# token type. However, they may contain information
|
||||||
# for a parent style. Worst case, we go to the root
|
# for a parent style. Worst case, we go to the root
|
||||||
# (Background) style.
|
# (Background) style.
|
||||||
Abbreviations[theme.style_parents(token).reverse.find { |parent|
|
class_prefix + Abbreviations[theme.style_parents(token).reverse.find { |parent|
|
||||||
theme.styles.has_key?(parent)
|
theme.styles.has_key?(parent)
|
||||||
}]
|
}]
|
||||||
end
|
end
|
||||||
|
@ -4,4 +4,5 @@ lexer = Tartrazine.lexer("crystal")
|
|||||||
theme = Tartrazine.theme(ARGV[1])
|
theme = Tartrazine.theme(ARGV[1])
|
||||||
formatter = Tartrazine::Html.new
|
formatter = Tartrazine::Html.new
|
||||||
formatter.standalone = true
|
formatter.standalone = true
|
||||||
|
formatter.class_prefix = "tartrazine-"
|
||||||
puts formatter.format(File.read(ARGV[0]), lexer, theme)
|
puts formatter.format(File.read(ARGV[0]), lexer, theme)
|
||||||
|
Loading…
Reference in New Issue
Block a user