Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Language display in the Show Language plugin #671

Closed
uranusjr opened this issue Aug 16, 2015 · 8 comments
Closed

Language display in the Show Language plugin #671

uranusjr opened this issue Aug 16, 2015 · 8 comments

Comments

@uranusjr
Copy link
Contributor

Currently only C++ and C# are processed, while all other languages are displayed just as in the class name, e.g. Python is “python”, and F# is “fsharp”.

Ideally this should show the “real” language name, not the identifier used by Prism. The simple way is to update Languages, but that information is already in components.js, and it would obvious be a maintenance pain in the future to keep it updated. Any idea how this can be done more easily?

@Golmote
Copy link
Contributor

Golmote commented Aug 16, 2015

Could we update it automatically through a gulp task? Say, we insert a placeholder in the plugin's code, for example:

var Languages = {
    /* [languages_placeholder] */
};

and we just replace it with the actual mapping, computed from the components.js file?

@uranusjr
Copy link
Contributor Author

I’m not very familiar with the workflow, but it sounds like a good idea. Will this apply only to the minified version?

@nauzilus
Copy link
Contributor

I think both the dev and minified version should have the mapping code injected so they're functionally the same.

One concern with just injecting via a gulp task is it would mean all languages are included in this plugin, even if you've only configured Prism with a couple of languages. So perhaps this should be incorporated into download.js so only what's needed can be included.

Thoughts?

@Golmote
Copy link
Contributor

Golmote commented Aug 17, 2015

Incorporating it only in the Download page would prevent users from using the source files directly (that is, prism-core + any plugins + any components)...

Furthermore, it is a really specific edge case. I don't really like the idea of inserting specific code everywhere to handle it. :(

@nauzilus
Copy link
Contributor

Hrm that's a good point. download.js should really just be for ease of bundling together, not generating code on the fly.

Having a closer look, there are only 14 languages with titles different to their internal names (ignoring case, e.g. powershell doesn't need to be mapped to PowerShell), so that's not going to add much to the file size.

Gulp task should work fine, ideally I'd like both the dev and minified versions to include the mapping though. Time to learn more about gulp 😃

@uranusjr
Copy link
Contributor Author

I would argue powershell does need to be mapped to PowerShell though. Case is important, especially to most programmers. I think most languages with only the first letter capitalised can be omitted, i.e. python does not need to be mapped to Python (it can be converted automatically in the plugin), while javascript need to be mapped to JavaScript. But it might be better to just process the whole list in components.js anyway.

@nauzilus
Copy link
Contributor

Wow that's great! Thanks @Golmote, that would have taken me a long time to figure out 👍

@Golmote
Copy link
Contributor

Golmote commented Aug 18, 2015

No problem! 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants