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

Add Red language highlighting #988

Closed
wants to merge 23 commits into from
Closed

Conversation

Oldes
Copy link
Contributor

@Oldes Oldes commented Nov 20, 2015

Related: www.red-lang.org

@Oldes
Copy link
Contributor Author

Oldes commented Nov 20, 2015

Ok... to resolve detection conflict with Apache was quite easy, but what a hack, how I can resolve conflict with something like Inform 7 !? Please help!

@Oldes
Copy link
Contributor Author

Oldes commented Nov 20, 2015

Fine.. Red language does not allow comma after alpha chars, so this conflict is fixed too.. but how to solve conflict between vhdl and Inform7 now? Crazy.

@@ -37,6 +37,7 @@ function(hljs) {
},
{
className: 'section',
relevance: 8,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually try to avoid very precise relevance boosters. If this required, just use 10.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used 10 in the commit above, but than I had conflict with Gems.

@Oldes
Copy link
Contributor Author

Oldes commented Nov 20, 2015

Sorry for so many commits, I was not able to install the test suite locally because of some dependency reasons.

@isagalaev
Copy link
Member

Resolving detection conflicts is a sort of an art in itself :-) It's best done by creating more specific contexts, rather than fiddling with relevance values. You can leave it as is for now, I'll try to have a look some time next week.

The dependency problem may be due to the fact that we use node 4.x since recently.

@Sannis Sannis added this to the 9.0 milestone Nov 22, 2015
@Oldes
Copy link
Contributor Author

Oldes commented Nov 22, 2015

@isagalaev Sorry that I ask, it is my first time I use node.js, but trying to run the test locally and not to pollute it here with every little change, I have this error:

> highlight.js@8.9.1 test /Users/oldes/GIT/highlight.js
> mocha test/

module.js:339
    throw err;
    ^

Error: Cannot find module '../../build'
    at Function.Module._resolveFilename (module.js:337:15)
    at Function.Module._load (module.js:287:25)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/Users/oldes/GIT/highlight.js/test/api/ident.js:3:12)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Suite.<anonymous> (/Users/oldes/GIT/highlight.js/test/api/index.js:4:3)
    at context.describe.context.context (/Users/oldes/GIT/highlight.js/node_modules/mocha/lib/interfaces/bdd.js:47:10)
    at Object.<anonymous> (/Users/oldes/GIT/highlight.js/test/api/index.js:3:1)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/Users/oldes/GIT/highlight.js/test/index.js:5:1)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at /Users/oldes/GIT/highlight.js/node_modules/mocha/lib/mocha.js:216:27
    at Array.forEach (native)
    at Mocha.loadFiles (/Users/oldes/GIT/highlight.js/node_modules/mocha/lib/mocha.js:213:14)
    at Mocha.run (/Users/oldes/GIT/highlight.js/node_modules/mocha/lib/mocha.js:453:10)
    at Object.<anonymous> (/Users/oldes/GIT/highlight.js/node_modules/mocha/bin/_mocha:393:18)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Function.Module.runMain (module.js:467:10)
    at startup (node.js:136:18)
    at node.js:963:3
npm ERR! Test failed.  See above for more details.

I have Node v4.2.2 on MacOS. Any idea what is wrong? Also I had these warning on npm install

npm WARN unmet dependency /Users/oldes/GIT/highlight.js/node_modules/del/node_modules/globby requires glob@'^5.0.3' but will load
npm WARN unmet dependency /Users/oldes/GIT/highlight.js/node_modules/glob,
npm WARN unmet dependency which is version 6.0.1
npm WARN unmet dependency /Users/oldes/GIT/highlight.js/node_modules/del/node_modules/rimraf requires glob@'^5.0.14' but will load
npm WARN unmet dependency /Users/oldes/GIT/highlight.js/node_modules/glob,
npm WARN unmet dependency which is version 6.0.1

@Oldes
Copy link
Contributor Author

Oldes commented Nov 22, 2015

@isagalaev forget my building question above.. I found that I must do build for node, not just the default one for browser.. so now I can save some invalid commits as a part of language detection part:)

@Sannis Sannis removed this from the 9.1 milestone Jan 6, 2016
@Sannis Sannis changed the title Red language (www.red-lang.org) highlighting. Red language (www.red-lang.org) highlighting Mar 28, 2016
Oldes added 2 commits April 20, 2017 21:19
…not ordinary words (some'thing) handling. Included category: functional

csp: increased relevance for single quota strings, so it takes precedence over Red language in autodetection
@mydigitalself
Copy link

Is there any update on this? Would love to support Red in Gitter.

https://gitter.im/gitterHQ/gitter?at=58f8f9cc8e4b63533de9d32b

@isagalaev
Copy link
Member

Tried to merge it today but there's quite a lot of little thing here and there that needed to be fixed for this definition to play well with each other. I understand it's been a while, so I have to ask if anyone (original author or not) is still interested in getting this done, I'd make a full review on it.

@ghost
Copy link

ghost commented Jun 4, 2017

Not the original author, but we all will be glad if you review it. And I am sure even @Oldes is interested in getting it done.

@isagalaev
Copy link
Member

isagalaev commented Jun 5, 2017

Cool! The best way to do it then is for someone to fork this branch and create a new PR with it so we could actually make changes. I'm not familiar with Red at all to do anything on my own :-)

@Oldes
Copy link
Contributor Author

Oldes commented Jun 5, 2017

Hi @isagalaev thank you for your interest.. I will make a new clean PR and will let you know here.

@isagalaev
Copy link
Member

@Oldes thanks! I looked through the history of this ticket and only now see that we actually tried to review it before :-)

If you're going to make a fresh one, pleasen ignore language detection problems on the first go and don't tune relevance. We'll deal with it after the code is in the correct shape.

@joshgoebel
Copy link
Member

I was mainly building the version for browser so I could see how it looks like, was not expecting, that for node I must build it again.

Yeah, this is annoying. But I don't hit it often enough to figure out how to best fix it. We could have separate build directories for each or always use the subfolders (like when you do a build all).

@joshgoebel
Copy link
Member

@Oldes

First of all, truly sorry for the long delay in processing this PR.

Thank you so much for desiring to contribute and writing a language grammar. Unfortunately, we currently are no longer accepting new languages into the core repository. The existing maintainers simply don't have time to maintain new languages (fixing bugs, dealing with issues, etc). We'd still love to host your language as a 3rd party module though - if you're willing to help maintain it.

It's easy to turn your language into a module that anyone who likes can easily integrate with Highlight.js using a single line of code:

<script src="/path/to/highlight.min.js"></script>
<!-- they'd simply add your language modules -->
<script src="/path/to/highlightjs-red-lang.js"></script> 
<script>hljs.initHighlightingOnLoad();</script>

It's also possible for users to rebuild the highlight.js library to include specific 3rd party modules, all in a single file (vs loading a bunch of 3rd party languages one at a time).

If you'd like to become the maintainer for this language then we're happy to create a new repository in the highlightjs organization and host the repository there. That assumes you'd be open to reviewing issues and fixing bugs as they arise. You're also welcome to host the repo yourself and we'll link to it from our README.

There isn't much in the way of how to docs on this yet, but there are sample repositories and it's honestly pretty easy. We're still fleshing out an official "spec" for 3rd party modules, but even after that's done it should require minimal changes from the examples we have already. IE, if you wanted to get started now there isn't any big reason to wait.

My own robots.txt grammar repository is a great, simple example:

https://github.com/highlightjs/highlightjs-robots-txt

If you have any questions feel free to ask.

@joshgoebel joshgoebel changed the title Red language (www.red-lang.org) highlighting Add Red language highlighting Dec 24, 2019
@joshgoebel
Copy link
Member

Closing for inactivity; (also finally cleaning all these old PRs out for the new year).

As mentioned above if you're interested in becoming the maintainer of a 3rd party module, please respond [whenever you find time] and we'd be happy to help you get started.

@joshgoebel joshgoebel closed this Jan 2, 2020
@Oldes
Copy link
Contributor Author

Oldes commented Nov 15, 2020

@joshgoebel Hi Josh... so I'm back again and ready to create a 3rd party module... what I should do? Should I host it under my account? Or you will set up a repo for me? I would really want to have colorizer for Red language (and Rebol) available under Gitter and this is the only path.

@joshgoebel
Copy link
Member

joshgoebel commented Nov 16, 2020

Does Gitter let you control the JS/HTML and inject your own code?

https://github.com/highlightjs/highlight.js/blob/master/extra/3RD_PARTY_QUICK_START.md

Should I host it under my account? Or you will set up a repo for me?

Your choice. We can make a repo here or you can have it under your own account.

@Oldes
Copy link
Contributor Author

Oldes commented Nov 16, 2020

No... I think that no one sane enough would allow JS injection... but Gitter is using Highlight.js, so the only way how to get our code colorized there is adding support for the language into oficial repository somehow.

I was reading the 3RD_PARTY_QUICK_START.md document, but it is not too clear to me...

  • if I will add syntax under my repo, how it can be found by anyone else than me? Like the Gitter, for example.
  • there is mention of src/languages/name.js, but the linked examples have the syntax only in src/
  • the document talks about putting the files under the extra/ folder, but the repository would be elsewhere... like the 2 examples from document.

If it's not possible to use 3rd_party module by 4th_party user (Gitter), than it does not make much sense... because to build version for my personal purposes, I can easily put the files under normal structure, how I was doing it 5 years ago :-/

@joshgoebel
Copy link
Member

joshgoebel commented Nov 16, 2020

No... I think that no one sane enough would allow JS injection...

Many hosted services do. If they allowed you to add your own HTML/CSS/theme then you can typically add JS just be adding script tags, etc... this is a common way to customize many sites. I just learned the other day you can add 3rd party languages to Discourse via this type of functionality.

Gitter is using Highlight.js, so the only way how to get our code colorized there is adding support for the language into oficial repository somehow.

This indicates is a pretty large misunderstanding. The way to get your code colorized on Gitter is to get Gitter to care about your language, period. If they don't, you won't. If they do, you might. Getting your language into our core library alone means nothing. Gitter seems to use only ~70 languages or so... we support 190... Very often services that use our library (Gitter, Discord, StackOverflow, etc) purposely only use a fraction of the languages (for various reasons). Just getting your favorite language added upstream does not magically make it work anywhere that uses Highlight.js.

Highlight.js (at it's core) is just a highlighting engine - that comes bundled with 190 languages you can potentially use. It's possible to use it and use only a single grammar - just because someone is using Highlight.js doesn't mean they highlight every single language that we provide with the core library.

if I will add syntax under my repo, how it can be found by anyone else than me? Like the Gitter, for example.

We'd add it to the official list of supported languages - so anyone looking would know it exists. They'd have to decide to install support for it - just like they do with their existing 70 languages out of a much larger # of possible languages they could support.

there is mention of src/languages/name.js, but the linked examples have the syntax only in src/

It can be made to work different ways. src/languages is more preferred.

the document talks about putting the files under the extra/ folder, but the repository would be elsewhere... like the 2 examples from document.

To build along side the core library you would checkout your repository into the extras folder. That allows the existing build scripts to magically build your grammar along side (or into) the main library.

If it's not possible to use 3rd_party module by 4th_party user (Gitter), than it does not make much sense...

Anyone who chooses can use 3rd party modules. We make that easy to do, but services have to decide which languages to support. This is true whether the language is 1st or 3rd party. Typically getting large services to add language support for languages that aren't super popular is an uphill battle though.

because to build version for my personal purposes, I can easily put the files under normal structure, how I was doing it 5 years ago :-/

Yes, but if you care about anyone in the broader community (of millions of users) being able to easily use your grammar then you'd really want to publish it as a 3rd party module - so that they could drop it into their projects with only a single line of code.

@Oldes
Copy link
Contributor Author

Oldes commented Nov 16, 2020

I'm not expecting the support to appear somewhere automatically.. I was asking on Gitter chat about it: https://gitter.im/gitter/gitter?at=5fb16c92f2fd4f60fc7637de

@Oldes
Copy link
Contributor Author

Oldes commented Nov 16, 2020

I just simply does not understand why you decided to go this strange 3rd party way... why you just don't allow to build specific set of languages on demand and have these languages in the main repo... I simply don't understand how is this more user friendly?

@joshgoebel
Copy link
Member

joshgoebel commented Nov 16, 2020

Context:
#2149

No one ever said it’s more user-friendly. It takes a lot of time and effort to support and maintain or add languages to the core library. It’s time that the current maintainers simply don’t have. We are barely keeping up with existing and popular languages as it is.

So we made it possible and easy for anyone who wants to create third-party grammar modules that anyone can use with about one line of code.

@joshgoebel
Copy link
Member

If you’re serious about Gitter I’d suggest making a third-party grammar and then making a pull request against the Gitter markdown stuff to use that grammar and see where that gets you.

@Oldes
Copy link
Contributor Author

Oldes commented Nov 16, 2020

I will, but I still don't understand, what are we second-class language users supposed to do to have it registered in h.js :-/
To add a link to my new repo here?

@joshgoebel
Copy link
Member

@Oldes
Copy link
Contributor Author

Oldes commented Nov 16, 2020

Ok... that makes sense.. it should be mentioned here: https://github.com/highlightjs/highlight.js/blob/master/extra/3RD_PARTY_QUICK_START.md

So I will make a self hosted repo and than submit PR to add a link into the list.

@joshgoebel
Copy link
Member

it should be mentioned here:

PR welcome.

@Oldes
Copy link
Contributor Author

Oldes commented Nov 16, 2020

@Oldes
Copy link
Contributor Author

Oldes commented Nov 16, 2020

I also created a simple github pages with Rebol and Red colorized code examples.

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.

None yet

5 participants