Use file inclusion to include text (or even code) as a comment.
Here's a file containing code to be included:
hello.rb
:
class HelloWorld
def initialize(name)
@name = name.capitalize
end
def sayHi
puts "Hello !"
end
end
Here's a template file that includes it:
includer.md
:
This file includes the code as a comment.
@[:comment](hello.rb)
The treatment token :comment
specifies that the included text is to be treated as a comment.
CLI
markdown_helper include --pristine includer.md included.md
(Option --pristine
suppresses comment insertion.)
API
include.rb
:
require 'markdown_helper'
# Option :pristine suppresses comment insertion.
markdown_helper = MarkdownHelper.new(:pristine => true)
markdown_helper.include('includer.md', 'included.md')
Here's the finished file with the included comment:
included.md
:
This file includes the code as a comment.
<!--class HelloWorld
def initialize(name)
@name = name.capitalize
end
def sayHi
puts "Hello !"
end
end
-->