Allow different casings to be specified for syntax highlighting (#6354)
This commit is contained in:
parent
6795be006d
commit
2b31a9b9ee
2 changed files with 24 additions and 0 deletions
|
|
@ -5,6 +5,13 @@ module Redcarpet
|
|||
class HTMLRouge < HTML
|
||||
include Rouge::Plugins::Redcarpet
|
||||
|
||||
# Rouge requires the hint language to be lower case, by overriding this
|
||||
# method we can allow the hint language to be specified with other casings
|
||||
# eg. `Ada` instead of `ada`
|
||||
def block_code(code, language)
|
||||
super(code, language.to_s.downcase)
|
||||
end
|
||||
|
||||
def link(link, _title, content)
|
||||
# Probably not the best fix but it does it's job of preventing
|
||||
# a nested links.
|
||||
|
|
|
|||
|
|
@ -314,4 +314,21 @@ RSpec.describe MarkdownParser, type: :labor do
|
|||
expect(generate_and_parse_markdown(code_block)).to include("word_<em>italic</em>_")
|
||||
end
|
||||
end
|
||||
|
||||
context "when adding syntax highlighting" do
|
||||
it "defaults to plaintext" do
|
||||
code_block = "```\ntext\n````"
|
||||
expect(generate_and_parse_markdown(code_block)).to include("highlight plaintext")
|
||||
end
|
||||
|
||||
it "adds correct syntax highlighting to codeblocks when the hint is not lowercase" do
|
||||
code_block = "```Ada\nwith Ada.Directories;\n````"
|
||||
expect(generate_and_parse_markdown(code_block)).to include("highlight ada")
|
||||
end
|
||||
|
||||
it "adds correct syntax highlighting to codeblocks when the hint is lowercase" do
|
||||
code_block = "```ada\nwith Ada.Directories;\n````"
|
||||
expect(generate_and_parse_markdown(code_block)).to include("highlight ada")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue