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.
-
#toc ⇒ Object
See here for ToC parameters confluence.atlassian.com/display/CONF55/Table+of+Contents+Macro.
Constructor Details
#initialize(config) ⇒ Reader
Returns a new instance of Reader.
5 6 7 8 9 10 11 |
# File 'lib/sync_readme/reader.rb', line 5 def initialize(config) @file_contents = File.read(config.filename) @notice = config.notice @toc = config.toc @strip_title = config.strip_title? @highlighter = config.syntax_highlighting? ? 'coderay' : nil end |
Instance Method Details
#html ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/sync_readme/reader.rb', line 48 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 = [] value << "<p>#{@notice}</p>" if @notice value << toc if @toc value << Kramdown::Document.new(markdown, ).to_html value.join("\n") end |
#toc ⇒ Object
See here for ToC parameters confluence.atlassian.com/display/CONF55/Table+of+Contents+Macro
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/sync_readme/reader.rb', line 15 def toc return '' unless @toc @toc = {} unless @toc.is_a?(Hash) params = { 'printable' => true, 'style' => 'circle', 'maxLevel' => 2, 'indent' => '5px', 'minLevel' => 2, 'exclude' => '[1/2]', 'outline' => true, 'type' => 'list', 'include' => '.*', 'class' => 'sync_readme_toc' }.merge(@toc) return " <ac:structured-macro ac:name=\"toc\">\n <ac:parameter ac:name=\"printable\">\#{params['printable']}</ac:parameter>\n <ac:parameter ac:name=\"style\">\#{params['style']}</ac:parameter>\n <ac:parameter ac:name=\"maxLevel\">\#{params['maxLevel']}</ac:parameter>\n <ac:parameter ac:name=\"indent\">\#{params['indent']}</ac:parameter>\n <ac:parameter ac:name=\"minLevel\">\#{params['minLevel']}</ac:parameter>\n <ac:parameter ac:name=\"class\">\#{params['class']}</ac:parameter>\n <ac:parameter ac:name=\"exclude\">\#{params['exclude']}</ac:parameter>\n <ac:parameter ac:name=\"type\">\#{params['type']}</ac:parameter>\n <ac:parameter ac:name=\"outline\">\#{params['outline']}</ac:parameter>\n <ac:parameter ac:name=\"include\">\#{params['include']}</ac:parameter>\n </ac:structured-macro>\n TOC\nend\n" |