Skip to content

Commit

Permalink
Use a more relaxed language pattern in code highlight regex
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatanklosko committed Feb 21, 2025
1 parent 140066e commit 8c25ad0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/nimble_publisher.ex
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ defmodule NimblePublisher do
and the second should contain the code to be highlighted. The default
regex to match with generated HTML documents is:
~r/<pre><code(?:\s+class="(\w*)")?>([^<]*)<\/code><\/pre>/
~r/<pre><code(?:\s+class="([^"\s]*)")?>([^<]*)<\/code><\/pre>/
"""
defdelegate highlight(html, options \\ []), to: NimblePublisher.Highlighter

Expand Down
2 changes: 1 addition & 1 deletion lib/nimble_publisher/highlighter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule NimblePublisher.Highlighter do
Highlights all code block in an already generated HTML document.
"""

@default_regex ~r/<pre><code(?:\s+class="(\w*)")?>([^<]*)<\/code><\/pre>/
@default_regex ~r/<pre><code(?:\s+class="([^"\s]*)")?>([^<]*)<\/code><\/pre>/

def highlight(html, options \\ []) do
regex = Keyword.get(options, :regex, @default_regex)
Expand Down

0 comments on commit 8c25ad0

Please sign in to comment.