# MarkdownHelper
[![Gem Version](https://badge.fury.io/rb/markdown_helper.svg)](https://badge.fury.io/rb/markdown_helper)
## File Inclusion
This markdown helper enables file inclusion in GitHub markdown.
(Actually, this README file itself is built using file inclusion.)
Use the markdown helper to merge external files into a markdown (.md) file.
### Merged Text Formats
#### Highlighted Code Block
include.rb
```ruby
class RubyCode
def initialize
raise RuntimeError.new('I am only an example!')
end
end
```
#### Plain Code Block
include.rb
```
class RubyCode
def initialize
raise RuntimeError.new('I am only an example!')
end
end
```
[Note: In the gem documentation, RubyDoc.info chooses to highlight this code block regardless. Go figure.]
#### Verbatim
Verbatim text is included unadorned. Most often, verbatim text is markdown to be rendered as part of the markdown page.
### Usage
#### CLI
include.txt
```
Usage:
include template_file_path markdown_file_page
where
* template_file_path is the path to an existing file.
* markdown_file_path is the path to a file to be created.
Typically:
* Both file types are .md.
* The template file contains file inclusion pragmas. See README.md.
```
#### API
usage.rb
```ruby
require 'markdown_helper'
markdown_helper = MarkdownHelper.new
template_file_path = 'highlight_ruby_template.md'
markdown_file_path = 'highlighted_ruby.rb'
markdown_helper.include(template_file_path, markdown_file_path)
```
#### Include Pragmas
Specify each file inclusion via an *include pragma*, which has the form:
@[
*format*]\(
*relative_file_path*)
where:
* *format* (in square brackets) is one of the following:
* Highlighting mode such as [ruby]
, to include a highlighted code block. This can be any Ace mode mentioned in [GitHub Languages](https://github.com/github/linguist/blob/master/lib/linguist/languages.yml).
* [:code_block]
, to include a plain code block.
* [:verbatim]
, to include text verbatim (to be rendered as markdown).
* *relative_file_path* points to the file to be included.
##### Example Include Pragmas
include.md
```verbatim
@[ruby](my_ruby.rb)
@[:code_block](my_language.xyzzy)
@[:verbatim](my_markdown.md)
```