Class: SyncReadme::Reader
- Inherits:
-
Object
- Object
- SyncReadme::Reader
- Defined in:
- lib/sync_readme/reader.rb
Instance Method Summary collapse
- #html ⇒ Object
-
#initialize(config) ⇒ Reader
constructor
A new instance of Reader.
Constructor Details
#initialize(config) ⇒ Reader
Returns a new instance of Reader.
5 6 7 8 9 10 |
# File 'lib/sync_readme/reader.rb', line 5 def initialize(config) @file_contents = File.read(config.filename) @notice = config.notice @strip_title = config.strip_title? @highlighter = config.syntax_highlighting? ? 'coderay' : nil end |
Instance Method Details
#html ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/sync_readme/reader.rb', line 12 def html markdown = @file_contents markdown.sub!(/# .*\n/, '') if @strip_title = { input: 'GFM', syntax_highlighter: @highlighter, syntax_highlighter_opts: { css: 'style', line_numbers: 'table' } } value = Kramdown::Document.new(markdown, ).to_html value = "#{@notice}#{value}" if @notice value end |