# File lib/asciidoctor/stylesheets.rb, line 23 def primary_stylesheet_data @primary_stylesheet_data ||= (::File.read (::File.join STYLESHEETS_DIR, 'asciidoctor-default.css'), mode: FILE_READ_MODE).rstrip end
class Asciidoctor::Stylesheets
A utility class for working with the built-in stylesheets.
Constants
- DEFAULT_STYLESHEET_NAME
- STYLESHEETS_DIR
Public Class Methods
# File lib/asciidoctor/stylesheets.rb, line 12 def self.instance @__instance__ end
Public Instance Methods
Public: Read the contents of the default CodeRay stylesheet
returns the [String] CodeRay stylesheet data
# File lib/asciidoctor/stylesheets.rb, line 47 def coderay_stylesheet_data (SyntaxHighlighter.for 'coderay').read_stylesheet end
# File lib/asciidoctor/stylesheets.rb, line 40 def coderay_stylesheet_name (SyntaxHighlighter.for 'coderay').stylesheet_basename end
Deprecated: Generate code to embed the CodeRay stylesheet
Returns the [String] CodeRay stylesheet data wrapped in a <style> tag
# File lib/asciidoctor/stylesheets.rb, line 54 def embed_coderay_stylesheet %(<style> #{coderay_stylesheet_data} </style>) end
Deprecated: Generate code to embed the primary stylesheet
Returns the [String] primary stylesheet data wrapped in a <style> tag
# File lib/asciidoctor/stylesheets.rb, line 30 def embed_primary_stylesheet %(<style> #{primary_stylesheet_data} </style>) end
Deprecated: Generate code to embed the Pygments stylesheet
Returns the [String] Pygments stylesheet data for the specified style wrapped in a <style> tag
# File lib/asciidoctor/stylesheets.rb, line 78 def embed_pygments_stylesheet style = nil %(<style> #{pygments_stylesheet_data style} </style>) end
Public: Read the contents of the default Asciidoctor stylesheet
returns the [String] Asciidoctor stylesheet data
# File lib/asciidoctor/stylesheets.rb, line 16 def primary_stylesheet_name DEFAULT_STYLESHEET_NAME end
Public: Generate the Pygments stylesheet with the specified style.
returns the [String] Pygments stylesheet data
# File lib/asciidoctor/stylesheets.rb, line 71 def pygments_stylesheet_data style = nil (SyntaxHighlighter.for 'pygments').read_stylesheet style end
# File lib/asciidoctor/stylesheets.rb, line 64 def pygments_stylesheet_name style = nil (SyntaxHighlighter.for 'pygments').stylesheet_basename style end
# File lib/asciidoctor/stylesheets.rb, line 60 def write_coderay_stylesheet target_dir = '.' ::File.write (::File.join target_dir, coderay_stylesheet_name), coderay_stylesheet_data, mode: FILE_WRITE_MODE end
# File lib/asciidoctor/stylesheets.rb, line 36 def write_primary_stylesheet target_dir = '.' ::File.write (::File.join target_dir, primary_stylesheet_name), primary_stylesheet_data, mode: FILE_WRITE_MODE end
# File lib/asciidoctor/stylesheets.rb, line 84 def write_pygments_stylesheet target_dir = '.', style = nil ::File.write (::File.join target_dir, (pygments_stylesheet_name style)), (pygments_stylesheet_data style), mode: FILE_WRITE_MODE end