Class: Asciidoctor::Stylesheets
- Inherits:
-
Object
- Object
- Asciidoctor::Stylesheets
- 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
-
#coderay_stylesheet_data ⇒ Object
Read the contents of the default CodeRay stylesheet.
- #coderay_stylesheet_name ⇒ Object
-
#embed_coderay_stylesheet ⇒ String
deprecated
Deprecated.
Do not use this in new code, and replace it when updating old code.
-
#embed_primary_stylesheet ⇒ String
deprecated
Deprecated.
Do not use this in new code, and replace it when updating old code.
-
#embed_pygments_stylesheet(style = nil) ⇒ String
deprecated
Deprecated.
Do not use this in new code, and replace it when updating old code.
-
#primary_stylesheet_data ⇒ Object
Read the contents of the default Asciidoctor stylesheet.
- #primary_stylesheet_name ⇒ Object
-
#pygments_stylesheet_data(style = nil) ⇒ Object
Generate the Pygments stylesheet with the specified style.
- #pygments_stylesheet_name(style = nil) ⇒ Object
- #write_coderay_stylesheet(target_dir = '.') ⇒ Object
- #write_primary_stylesheet(target_dir = '.') ⇒ Object
- #write_pygments_stylesheet(target_dir = '.', style = nil) ⇒ Object
Class Method Details
.instance ⇒ Object
14 15 16 |
# File 'lib/asciidoctor/stylesheets.rb', line 14 def self.instance @__instance__ end |
Instance Method Details
#coderay_stylesheet_data ⇒ Object
Read the contents of the default CodeRay stylesheet
returns the [String] CodeRay stylesheet data
49 50 51 |
# File 'lib/asciidoctor/stylesheets.rb', line 49 def coderay_stylesheet_data (SyntaxHighlighter.for 'coderay').read_stylesheet end |
#coderay_stylesheet_name ⇒ Object
42 43 44 |
# File 'lib/asciidoctor/stylesheets.rb', line 42 def coderay_stylesheet_name (SyntaxHighlighter.for 'coderay').stylesheet_basename end |
#embed_coderay_stylesheet ⇒ String
Do not use this in new code, and replace it when updating old code.
Generate code to embed the CodeRay stylesheet
56 57 58 59 60 |
# File 'lib/asciidoctor/stylesheets.rb', line 56 def %(<style> #{coderay_stylesheet_data} </style>) end |
#embed_primary_stylesheet ⇒ String
Do not use this in new code, and replace it when updating old code.
Generate code to embed the primary stylesheet
32 33 34 35 36 |
# File 'lib/asciidoctor/stylesheets.rb', line 32 def %(<style> #{primary_stylesheet_data} </style>) end |
#embed_pygments_stylesheet(style = nil) ⇒ String
Do not use this in new code, and replace it when updating old code.
Generate code to embed the Pygments stylesheet
80 81 82 83 84 |
# File 'lib/asciidoctor/stylesheets.rb', line 80 def style = nil %(<style> #{pygments_stylesheet_data style} </style>) end |
#primary_stylesheet_data ⇒ Object
Read the contents of the default Asciidoctor stylesheet
returns the [String] Asciidoctor stylesheet data
25 26 27 |
# File 'lib/asciidoctor/stylesheets.rb', line 25 def primary_stylesheet_data @primary_stylesheet_data ||= (::File.read (::File.join STYLESHEETS_DIR, 'asciidoctor-default.css'), mode: FILE_READ_MODE).rstrip end |
#primary_stylesheet_name ⇒ Object
18 19 20 |
# File 'lib/asciidoctor/stylesheets.rb', line 18 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
73 74 75 |
# File 'lib/asciidoctor/stylesheets.rb', line 73 def pygments_stylesheet_data style = nil (SyntaxHighlighter.for 'pygments').read_stylesheet style end |
#pygments_stylesheet_name(style = nil) ⇒ Object
66 67 68 |
# File 'lib/asciidoctor/stylesheets.rb', line 66 def pygments_stylesheet_name style = nil (SyntaxHighlighter.for 'pygments').stylesheet_basename style end |
#write_coderay_stylesheet(target_dir = '.') ⇒ Object
62 63 64 |
# File 'lib/asciidoctor/stylesheets.rb', line 62 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
38 39 40 |
# File 'lib/asciidoctor/stylesheets.rb', line 38 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
86 87 88 |
# File 'lib/asciidoctor/stylesheets.rb', line 86 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 |