Skip to content

Commit

Permalink
Merge pull request #218 from DannyBen/patch-2
Browse files Browse the repository at this point in the history
Clarify syntax highlighter plugin usage in README
  • Loading branch information
gjtorikian committed Jan 17, 2023
2 parents 38a4405 + 480c8b9 commit 4663102
Showing 1 changed file with 30 additions and 17 deletions.
47 changes: 30 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,33 +100,46 @@ For more information on these options, see [the comrak documentation](https://gi
### Plugins

In addition to the possibilities provided by generic CommonMark rendering, Commonmarker also supports plugins as a means of
providing further niceties. For example:
providing further niceties.

code = <<~CODE
```ruby
def hello
puts "hello"
end
#### Syntax Highlighter Plugin

CODE

Commonmarker.to_html(code, plugins: { syntax_highlighter: { theme: "Inspired GitHub" } })

# <pre style="background-color:#ffffff;" lang="ruby"><code>
# <span style="font-weight:bold;color:#a71d5d;">def </span><span style="font-weight:bold;color:#795da3;">hello
# </span><span style="color:#323232;"> </span><span style="color:#62a35c;">puts </span><span style="color:#183691;">&quot;hello&quot;
# </span><span style="font-weight:bold;color:#a71d5d;">end
# </span>
# </code></pre>
```ruby
code = <<~CODE
```ruby
def hello
puts "hello"
end
CODE

puts Commonmarker.to_html(code, plugins: { syntax_highlighter: { theme: "InspiredGitHub" } })

# <pre style="background-color:#ffffff;" lang="ruby"><code>
# <span style="font-weight:bold;color:#a71d5d;">def </span><span style="font-weight:bold;color:#795da3;">hello
# </span><span style="color:#62a35c;">puts </span><span style="color:#183691;">&quot;hello&quot;
# </span><span style="font-weight:bold;color:#a71d5d;">end
# </span>
# </code></pre>
```

You can disable plugins just the same as with options, by passing `nil`:
To disable this plugin, pass `nil`:

```ruby
Commonmarker.to_html(code, plugins: { syntax_highlighter: nil })
# or
Commonmarker.to_html(code, plugins: { syntax_highlighter: { theme: nil } })
```

Available themes ([source](https://docs.rs/syntect/5.0.0/syntect/highlighting/struct.ThemeSet.html#implementations)):

- base16-ocean.dark
- base16-eighties.dark
- base16-mocha.dark
- base16-ocean.light
- InspiredGitHub
- Solarized (dark)
- Solarized (light)

## Output formats

Commonmarker can currently only generate output in one format: HTML.
Expand Down

0 comments on commit 4663102

Please sign in to comment.