Covert the language alias on code header

This commit is contained in:
Cotes Chung 2021-09-22 21:20:30 +08:00
parent 4ad0a76789
commit ed93fbdfde
3 changed files with 76 additions and 9 deletions

View file

@ -0,0 +1,72 @@
{% comment %}
Convert the alias of the syntax language to the official name
See: <https://github.com/rouge-ruby/rouge/wiki/List-of-supported-languages-and-lexers>
{% endcomment %}
{% assign _lang = include.language | default: '' %}
{% case _lang %}
{% when 'actionscript', 'as', 'as3' %}
{{ 'ActionScript' }}
{% when 'applescript' %}
{{ 'AppleScript' }}
{% when 'brightscript', 'bs', 'brs' %}
{{ 'BrightScript' }}
{% when 'cfscript', 'cfc' %}
{{ 'CFScript' }}
{% when 'coffeescript', 'coffee', 'coffee-script' %}
{{ 'CoffeeScript' }}
{% when 'cs', 'csharp' %}
{{ 'C#' }}
{% when 'erl' %}
{{ 'Erlang' }}
{% when 'graphql' %}
{{ 'GraphQL' }}
{% when 'haskell', 'hs' %}
{{ 'Haskell' }}
{% when 'javascript', 'js' %}
{{ 'JavaScript' }}
{% when 'make', 'mf', 'gnumake', 'bsdmake' %}
{{ 'Makefile' }}
{% when 'md', 'mkd' %}
{{ 'Markdown' }}
{% when 'm' %}
{{ 'Matlab' }}
{% when 'objective_c', 'objc', 'obj-c', 'obj_c', 'objectivec' %}
{{ 'Objective-C' }}
{% when 'perl', 'pl' %}
{{ 'Perl' }}
{% when 'php','php3','php4','php5' %}
{{ 'PHP' }}
{% when 'plaintext', 'text' %}
{{ 'Text' }}
{% when 'py' %}
{{ 'Python' }}
{% when 'rb' %}
{{ 'Ruby' }}
{% when 'rs','no_run','ignore','should_panic' %}
{{ 'Rust' }}
{% when 'bash', 'zsh', 'ksh', 'sh' %}
{{ 'Shell' }}
{% when 'st', 'squeak' %}
{{ 'Smalltalk' }}
{% when 'tex'%}
{{ 'TeX' }}
{% when 'latex' %}
{{ 'LaTex' }}
{% when 'ts', 'typescript' %}
{{ 'TypeScript' }}
{% when 'vb', 'visualbasic' %}
{{ 'Visual Basic' }}
{% when 'vue', 'vuejs' %}
{{ 'Vue.js' }}
{% when 'yml' %}
{{ 'YAML' }}
{% when 'css', 'html', 'scss', 'ssh', 'toml', 'xml', 'yaml' %}
{{ _lang | upcase }}
{% else %}
{{ _lang | capitalize }}
{% endcase %}

View file

@ -121,7 +121,8 @@
{% assign _text = _left | split: 'file="' | last | split: '"' | first %} {% assign _text = _left | split: 'file="' | last | split: '"' | first %}
{% assign _label_icon = 'far fa-file' %} {% assign _label_icon = 'far fa-file' %}
{% else %} {% else %}
{% assign _text = _left | split: 'language-' | last | split: ' ' | first %} {% assign _lang = _left | split: 'language-' | last | split: ' ' | first %}
{% capture _text %}{% include language-alias.html language=_lang %}{% endcapture %}
{% assign _label_icon = 'fas fa-code small' %} {% assign _label_icon = 'fas fa-code small' %}
{% endif %} {% endif %}

View file

@ -172,7 +172,7 @@ div {
align-items: center; align-items: center;
line-height: 1.85rem; line-height: 1.85rem;
// the label // the label block
span { span {
color: var(--lang-badge-color); color: var(--lang-badge-color);
padding-left: 0.6rem; padding-left: 0.6rem;
@ -183,13 +183,7 @@ div {
margin-left: 0.3rem; margin-left: 0.3rem;
font-weight: 600; font-weight: 600;
// language }
@at-root .highlighter-rouge:not([file]) #{&} {
font-size: 0.75rem;
text-transform: uppercase;
}
} // :after
@at-root [file] #{&} > i { // center the file icon @at-root [file] #{&} > i { // center the file icon
position: relative; position: relative;