Sha256: 53d04f2dbea6646037ec39031ee9eccea933138ee0ede1391dc4d5603bcbf485

Contents?: true

Size: 1.4 KB

Versions: 7

Compression:

Stored size: 1.4 KB

Contents

### Include Text As Comment

Use file inclusion to include text (or even code) as a comment.

#### File to Be Included

Here's a file containing code to be included:

```hello.rb```:
```markdown
class HelloWorld
   def initialize(name)
      @name = name.capitalize
   end
   def sayHi
      puts "Hello !"
   end
end
```

#### Includer File

Here's a template file that includes it:

```includer.md```:
```markdown
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.

#### Include Via <code>markdown_helper</code>
<details>
<summary>CLI</summary>

```sh
markdown_helper include --pristine includer.md included.md
```

(Option ```--pristine``` suppresses comment insertion.)
</details>
<details>
<summary>API</summary>

```include.rb```:
```ruby
require 'markdown_helper'

# Option :pristine suppresses comment insertion.
markdown_helper = MarkdownHelper.new(:pristine => true)
markdown_helper.include('includer.md', 'included.md')
```

</details>

#### File with Inclusion

Here's the finished file with the included comment:

```included.md```:
```markdown
This file includes the code as a comment.

<!--class HelloWorld
   def initialize(name)
      @name = name.capitalize
   end
   def sayHi
      puts "Hello !"
   end
end
-->
```

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
markdown_helper-2.5.4 markdown/use_cases/include/include_text_as_comment/use_case.md
markdown_helper-2.5.3 markdown/use_cases/include/include_text_as_comment/use_case.md
markdown_helper-2.5.2 markdown/use_cases/include/include_text_as_comment/use_case.md
markdown_helper-2.5.1 markdown/use_cases/include/include_text_as_comment/use_case.md
markdown_helper-2.5.0 markdown/use_cases/include/include_text_as_comment/use_case.md
markdown_helper-2.4.0 markdown/use_cases/include/include_text_as_comment/use_case.md
markdown_helper-2.3.0 markdown/use_cases/include_files/include_text_as_comment/use_case.md