1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Add back support for other syntax highlighting

We recently switched to use Rouge for syntax highlighting in the guides,
but in doing so we dropped support for highlighting the following
syntaxes, which are used in the guides:

apache
diff
json
markdown
nginx
scss
xml

There was also css and the "javascript" alias, but @eugeneius already
addressed these two.

They syntaxes were all being converted to "plaintext". This change allows
all the lexers mentioned above as well as any other lexers available
through Rouge.

We have deliberately decided to not support passing rougue custom lexer
options from the code fences. Instead any lexer options that are needed
can be set by adding an entry to the lexer_language case statement. This
should lead to more consistency in formatting and gives us more control
over what Rogue options are allowed.
This commit is contained in:
Gerard (Gerry) Caulfield 2020-07-22 01:11:01 +02:00
parent e2cc2d1dfc
commit 17a4ec1c28

View file

@ -68,14 +68,14 @@ module RailsGuides
def lexer_language(code_type)
case code_type
when "css", "js", "html", "ruby", "sql", "yaml"
code_type
when "erb", "html+erb"
when "html+erb"
"erb"
when "bash"
"console"
else
when nil
"plaintext"
else
::Rouge::Lexer.find(language) ? code_type : "plaintext"
end
end