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

Autoloader: Added support for aliases #1829

Merged

Conversation

RunDevelopment
Copy link
Member

This PR adds alias support to the Autoloader plugin.

The bug that the dependencies of forced-loaded languages in data-dependencies were not loaded is also fixed.
I.e. <code class="language-pug" data-dependencies="less!"> the dependencies of less were not loaded.


This resolves #1827.

@falsandtru
Copy link

Can you expose lang_aliases to enable custom aliases?

@RunDevelopment
Copy link
Member Author

Before thinking about custom aliases, are 'normal' aliases not enough?
For what purpose do you need them?

@falsandtru
Copy link

I want to define the hs alias for haskell. Looks like I have to register that alias to lang_aliases.

@RunDevelopment
Copy link
Member Author

hs is the file extension of Haskell files, right? Then making hs an alias for haskell is an easy solution to your problem.
Also, there are others who might also want this alias, so making this part of Prism is probably a better idea than introducing custom aliases.

If there are any other aliases you want, feel free to request them, I'll add them.

If you want to add them yourself:

  1. Add a line Prism.language.myNewAlias = Prism.languages.mylanguage; to the prism-mylanguage.js file in the components/ directory.
  2. Open components.json and add an alias property to the entry languages.mylanguage and set its value to the added alias. E.g. "alias": "myNewAlias " or "alias": ["firstAlias", "myNewAlias "].
  3. Run the npx gulp command after installing all npm dependencies.
  4. Commit and make a PR (without package-lock.json)!

@falsandtru
Copy link

I see, could you add hs alias with #1830? Since hs alias is adopted with GitHub it can be considered a common alias.

@RunDevelopment
Copy link
Member Author

I'll make a new PR (#1831).

@falsandtru
Copy link

Thanks!

@mAAdhaTTah
Copy link
Member

We'll also want to update the gulp annotations PR, which may be worth revisiting now.

@RunDevelopment RunDevelopment merged commit 52889b5 into PrismJS:master Mar 24, 2019
@RunDevelopment RunDevelopment deleted the autoloader-alias-support branch March 24, 2019 17:52
@RunDevelopment
Copy link
Member Author

I closed #1535 because I want to get rid of partly generate files in the end.
My goal is to implement #1539 (or similar) so that we generate files that these plugins then require. This will also get rid of the annoying merge conflicts I get almost every time in prism-autoloader.js and prism-show-language.js.

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

Successfully merging this pull request may close these issues.

Can't load language plugins via aliases even when they are officially provided
3 participants