Class: Asciidoctor::Stylesheets

Inherits:
Object
  • Object
show all
Defined in:
lib/asciidoctor/stylesheets.rb

Overview

QUESTION create method for user stylesheet?

Constant Summary collapse

DEFAULT_STYLESHEET_NAME =
'asciidoctor.css'
STYLESHEETS_DIR =
::File.join DATA_DIR, 'stylesheets'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.instanceObject



13
14
15
# File 'lib/asciidoctor/stylesheets.rb', line 13

def self.instance
  @__instance__
end

Instance Method Details

#coderay_stylesheet_dataObject

Read the contents of the default CodeRay stylesheet

returns the [String] CodeRay stylesheet data



48
49
50
# File 'lib/asciidoctor/stylesheets.rb', line 48

def coderay_stylesheet_data
  (SyntaxHighlighter.for 'coderay').read_stylesheet
end

#coderay_stylesheet_nameObject



41
42
43
# File 'lib/asciidoctor/stylesheets.rb', line 41

def coderay_stylesheet_name
  (SyntaxHighlighter.for 'coderay').stylesheet_basename
end

#embed_coderay_stylesheetString

Deprecated.

Do not use this in new code, and replace it when updating old code.

Generate code to embed the CodeRay stylesheet

Returns:

  • (String)

    Returns the String CodeRay stylesheet data wrapped in a <style> tag



55
56
57
58
59
# File 'lib/asciidoctor/stylesheets.rb', line 55

def embed_coderay_stylesheet
  %(<style>
#{coderay_stylesheet_data}
</style>)
end

#embed_primary_stylesheetString

Deprecated.

Do not use this in new code, and replace it when updating old code.

Generate code to embed the primary stylesheet

Returns:

  • (String)

    Returns the String primary stylesheet data wrapped in a <style> tag



31
32
33
34
35
# File 'lib/asciidoctor/stylesheets.rb', line 31

def embed_primary_stylesheet
  %(<style>
#{primary_stylesheet_data}
</style>)
end

#embed_pygments_stylesheet(style = nil) ⇒ String

Deprecated.

Do not use this in new code, and replace it when updating old code.

Generate code to embed the Pygments stylesheet

Returns:

  • (String)

    Returns the String Pygments stylesheet data for the specified style wrapped in a <style> tag



79
80
81
82
83
# File 'lib/asciidoctor/stylesheets.rb', line 79

def embed_pygments_stylesheet style = nil
  %(<style>
#{pygments_stylesheet_data style}
</style>)
end

#primary_stylesheet_dataObject

Read the contents of the default Asciidoctor stylesheet

returns the [String] Asciidoctor stylesheet data



24
25
26
# File 'lib/asciidoctor/stylesheets.rb', line 24

def primary_stylesheet_data
  @primary_stylesheet_data ||= (::File.read (::File.join STYLESHEETS_DIR, 'asciidoctor-default.css'), mode: FILE_READ_MODE).rstrip
end

#primary_stylesheet_nameObject



17
18
19
# File 'lib/asciidoctor/stylesheets.rb', line 17

def primary_stylesheet_name
  DEFAULT_STYLESHEET_NAME
end

#pygments_stylesheet_data(style = nil) ⇒ Object

Generate the Pygments stylesheet with the specified style.

returns the [String] Pygments stylesheet data



72
73
74
# File 'lib/asciidoctor/stylesheets.rb', line 72

def pygments_stylesheet_data style = nil
  (SyntaxHighlighter.for 'pygments').read_stylesheet style
end

#pygments_stylesheet_name(style = nil) ⇒ Object



65
66
67
# File 'lib/asciidoctor/stylesheets.rb', line 65

def pygments_stylesheet_name style = nil
  (SyntaxHighlighter.for 'pygments').stylesheet_basename style
end

#write_coderay_stylesheet(target_dir = '.') ⇒ Object



61
62
63
# File 'lib/asciidoctor/stylesheets.rb', line 61

def write_coderay_stylesheet target_dir = '.'
  ::File.write (::File.join target_dir, coderay_stylesheet_name), coderay_stylesheet_data, mode: FILE_WRITE_MODE
end

#write_primary_stylesheet(target_dir = '.') ⇒ Object



37
38
39
# File 'lib/asciidoctor/stylesheets.rb', line 37

def write_primary_stylesheet target_dir = '.'
  ::File.write (::File.join target_dir, primary_stylesheet_name), primary_stylesheet_data, mode: FILE_WRITE_MODE
end

#write_pygments_stylesheet(target_dir = '.', style = nil) ⇒ Object



85
86
87
# File 'lib/asciidoctor/stylesheets.rb', line 85

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