Skip to content

Commit

Permalink
Add property 'aliasTitles' to components.js
Browse files Browse the repository at this point in the history
This is necessary, because a language that has a lot of aliases
like markup (HTML, SVG, XML, MathML), is only added to the
languageMap once as "Markup". So any plugin that depends on the
languageMap is limited by that.

This patch allows the definition of additional titles for
languages, depending on the alias that is used.
  • Loading branch information
zeitgeist87 committed Feb 17, 2016
1 parent e29cbe1 commit 54400fb
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 11 deletions.
1 change: 1 addition & 0 deletions components.js
Expand Up @@ -44,6 +44,7 @@ var components = {
},
"markup": {
"title": "Markup",
"aliasTitles": { "html": "HTML", "xml": "XML", "svg": "SVG", "mathml": "MathML" },
"option": "default"
},
"css": {
Expand Down
4 changes: 4 additions & 0 deletions gulpfile.js
Expand Up @@ -70,6 +70,10 @@ gulp.task('languages-plugins', function (cb) {
languagesMap[p] = title;
}

for (var name in data.languages[p].aliasTitles) {
languagesMap[name] = data.languages[p].aliasTitles[name];
}

if(data.languages[p].require) {
dependenciesMap[p] = data.languages[p].require;
}
Expand Down
9 changes: 5 additions & 4 deletions plugins/file-highlight/prism-file-highlight.js
Expand Up @@ -7,13 +7,14 @@

var Extensions = {
'js': 'javascript',
'html': 'markup',
'svg': 'markup',
'xml': 'markup',
'py': 'python',
'rb': 'ruby',
'ps1': 'powershell',
'psm1': 'powershell'
'psm1': 'powershell',
'sh': 'bash',
'bat': 'batch',
'h': 'c',
'tex': 'latex'
};

if(Array.prototype.forEach) { // Check to prevent error in IE8
Expand Down
2 changes: 1 addition & 1 deletion plugins/file-highlight/prism-file-highlight.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/show-language/prism-show-language.js
Expand Up @@ -5,7 +5,7 @@ if (typeof self === 'undefined' || !self.Prism || !self.document) {
}

// The languages map is built automatically with gulp
var Languages = /*languages_placeholder[*/{"css":"CSS","clike":"C-like","javascript":"JavaScript","abap":"ABAP","actionscript":"ActionScript","apacheconf":"Apache Configuration","apl":"APL","applescript":"AppleScript","asciidoc":"AsciiDoc","aspnet":"ASP.NET (C#)","autoit":"AutoIt","autohotkey":"AutoHotkey","basic":"BASIC","csharp":"C#","cpp":"C++","coffeescript":"CoffeeScript","css-extras":"CSS Extras","fsharp":"F#","glsl":"GLSL","http":"HTTP","inform7":"Inform 7","json":"JSON","latex":"LaTeX","lolcode":"LOLCODE","matlab":"MATLAB","mel":"MEL","nasm":"NASM","nginx":"nginx","nsis":"NSIS","objectivec":"Objective-C","ocaml":"OCaml","parigp":"PARI/GP","php":"PHP","php-extras":"PHP Extras","powershell":"PowerShell","jsx":"React JSX","rest":"reST (reStructuredText)","sas":"SAS","sass":"Sass (Sass)","scss":"Sass (Scss)","sql":"SQL","typescript":"TypeScript","vhdl":"VHDL","vim":"vim","wiki":"Wiki markup","yaml":"YAML"}/*]*/;
var Languages = /*languages_placeholder[*/{"html":"HTML","xml":"XML","svg":"SVG","mathml":"MathML","css":"CSS","clike":"C-like","javascript":"JavaScript","abap":"ABAP","actionscript":"ActionScript","apacheconf":"Apache Configuration","apl":"APL","applescript":"AppleScript","asciidoc":"AsciiDoc","aspnet":"ASP.NET (C#)","autoit":"AutoIt","autohotkey":"AutoHotkey","basic":"BASIC","csharp":"C#","cpp":"C++","coffeescript":"CoffeeScript","css-extras":"CSS Extras","fsharp":"F#","glsl":"GLSL","http":"HTTP","inform7":"Inform 7","json":"JSON","latex":"LaTeX","lolcode":"LOLCODE","matlab":"MATLAB","mel":"MEL","nasm":"NASM","nginx":"nginx","nsis":"NSIS","objectivec":"Objective-C","ocaml":"OCaml","parigp":"PARI/GP","php":"PHP","php-extras":"PHP Extras","powershell":"PowerShell","jsx":"React JSX","rest":"reST (reStructuredText)","sas":"SAS","sass":"Sass (Sass)","scss":"Sass (Scss)","sql":"SQL","typescript":"TypeScript","vhdl":"VHDL","vim":"vim","wiki":"Wiki markup","yaml":"YAML"}/*]*/;
Prism.hooks.add('before-highlight', function(env) {
var pre = env.element.parentNode;
if (!pre || !/pre/i.test(pre.nodeName)) {
Expand Down
2 changes: 1 addition & 1 deletion plugins/show-language/prism-show-language.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions prism.js
Expand Up @@ -655,13 +655,14 @@ Prism.languages.js = Prism.languages.javascript;

var Extensions = {
'js': 'javascript',
'html': 'markup',
'svg': 'markup',
'xml': 'markup',
'py': 'python',
'rb': 'ruby',
'ps1': 'powershell',
'psm1': 'powershell'
'psm1': 'powershell',
'sh': 'bash',
'bat': 'batch',
'h': 'c',
'tex': 'latex'
};

if(Array.prototype.forEach) { // Check to prevent error in IE8
Expand Down

0 comments on commit 54400fb

Please sign in to comment.