diff --git a/README.md b/README.md index 939d46d6..e9123d30 100644 --- a/README.md +++ b/README.md @@ -105,14 +105,25 @@ providing further niceties. #### Syntax Highlighter Plugin +The library comes with [a set of pre-existing themes](https://docs.rs/syntect/5.0.0/syntect/highlighting/struct.ThemeSet.html#implementations) for highlighting code: + +- `"base16-ocean.dark"` +- `"base16-eighties.dark"` +- `"base16-mocha.dark"` +- `"base16-ocean.light"` +- `"InspiredGitHub"` +- `"Solarized (dark)"` +- `"Solarized (light)"` + ````ruby code = <<~CODE ```ruby def hello - puts "hello" + puts "hello" end CODE +# pass in a theme name from a pre-existing set puts Commonmarker.to_html(code, plugins: { syntax_highlighter: { theme: "InspiredGitHub" } }) #
@@ -123,32 +134,42 @@ puts Commonmarker.to_html(code, plugins: { syntax_highlighter: { theme: "Inspire
#
````
-To disable this plugin, pass `nil`:
+By default, the plugin uses the `"base16-ocean.dark"` theme to syntax highlight code.
+
+To disable this plugin, set the value to `nil`:
```ruby
Commonmarker.to_html(code, plugins: { syntax_highlighter: nil })
-# or
-Commonmarker.to_html(code, plugins: { syntax_highlighter: { theme: nil } })
+
+# def hello
+# puts "hello"
+# end
+#
```
-You can also provide a `path` to a directory containing `.tmtheme` files to load:
+To output CSS classes instead of `style` attributes, set the `theme` key to `""`:
-```ruby
+````ruby
+code = <<~CODE
+ ```ruby
+ def hello
+ puts "hello"
+ end
+CODE
-Commonmarker.to_html(code, plugins: { syntax_highlighter: { theme: "Monokai", path: "./themes" } })
-```
+Commonmarker.to_html(code, plugins: { syntax_highlighter: { theme: "" } })
-##### Available themes
+# puts "hello"
+# end\n
+#
+````
-Here's [a list of themes available by default](https://docs.rs/syntect/5.0.0/syntect/highlighting/struct.ThemeSet.html#implementations):
+To use a custom theme, you can provide a `path` to a directory containing `.tmtheme` files to load:
-- `"base16-ocean.dark"`
-- `"base16-eighties.dark"`
-- `"base16-mocha.dark"`
-- `"base16-ocean.light"`
-- `"InspiredGitHub"`
-- `"Solarized (dark)"`
-- `"Solarized (light)"`
+```ruby
+
+Commonmarker.to_html(code, plugins: { syntax_highlighter: { theme: "Monokai", path: "./themes" } })
+```
## Output formats
@@ -198,3 +219,18 @@ Comparison:
commonmarker with to_html: 5.8 i/s - 3.84x (± 0.00) slower
kramdown: 0.3 i/s - 68.30x (± 0.00) slower
```
+
+```
+
+```
+
+````
+
+```
+
+```
+
+```
+
+```
+````