Sha256: 650e191864a03d1a0289d446929d17f1bff94528ba17649dfda8f0d69d003861

Contents?: true

Size: 1.71 KB

Versions: 4

Compression:

Stored size: 1.71 KB

Contents

require_relative '../include_use_case'

class IncludeHighlightedCode < IncludeUseCase

  def self.build

    use_case_name = File.basename(__FILE__, '.rb')
    use_case = self.new(use_case_name)

    use_case.write_includer_file

    includee_file_name = 'hello.rb'

    use_case.files_to_write.store(
        includee_file_name,
        <<EOT
class HelloWorld
   def initialize(name)
      @name = name.capitalize
   end
   def sayHi
      puts "Hello #{@name}!"
   end
end
EOT
    )

    use_case.files_to_write.store(
        INCLUDER_FILE_NAME,
        <<EOT
This file includes the code as highlighted code.

@[ruby](#{includee_file_name})

EOT
    )

    use_case.files_to_write.store(
        TEMPLATE_FILE_NAME,
        <<EOT
### Include Highlighted Code

Use file inclusion to include text as highlighted code.

#### File to Be Included

Here's a file containing Ruby code to be included:

@[markdown](#{includee_file_name})

#### Includer File

Here's a template file that includes it:

@[markdown](#{INCLUDER_FILE_NAME})

The treatment token ```ruby``` specifies that the included text is to be highlighted as Ruby code.

The treatment token can be any Ace mode mentioned in [GitHub Languages](https://github.com/github/linguist/blob/master/lib/linguist/languages.yml).  The file lists about 100 Ace modes, covering just about every language and format.

@[:markdown](../interface.md)

#### File with Inclusion

Here's the finished file with the included highlighted code:

@[:pre](#{INCLUDED_FILE_NAME})

And here's the finished markdown, as rendered on this page:

---

@[:markdown](#{INCLUDED_FILE_NAME})

---
EOT
    )

    use_case.build

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
markdown_helper-2.0.0 markdown/use_cases/include_files/include_highlighted_code/include_highlighted_code.rb
markdown_helper-1.9.9 markdown/use_cases/include_files/include_highlighted_code/include_highlighted_code.rb
markdown_helper-1.9.5 markdown/use_cases/include_files/include_highlighted_code/include_highlighted_code.rb
markdown_helper-1.9.0 markdown/use_cases/include/include_highlighted_code/include_highlighted_code.rb