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

Red language (www.red-lang.org) highlighting #988

Open
wants to merge 23 commits into
base: master
from

Conversation

Projects
None yet
4 participants
@Oldes
Copy link

commented Nov 20, 2015

No description provided.

@Oldes

This comment has been minimized.

Copy link
Author

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

This comment has been minimized.

Copy link
Author

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.

Oldes added some commits Nov 20, 2015

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

This comment has been minimized.

Copy link
@Sannis

Sannis Nov 20, 2015

Collaborator

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

This comment has been minimized.

Copy link
@Oldes

Oldes Nov 20, 2015

Author

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

/*
Language: Red language
Author: Oldes <oldes.huhuman@gmail.com>
Category: common, scripting

This comment has been minimized.

Copy link
@Sannis

Sannis Nov 20, 2015

Collaborator

Please remove common from here.

@Sannis Sannis added the new language label Nov 20, 2015

@Oldes

This comment has been minimized.

Copy link
Author

commented Nov 20, 2015

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

Oldes added some commits Nov 20, 2015

Oldes
Red language: adding propper CHAR and TAG type, modifying OPERATOR no…
…t to eat spaces in front of it (shame there is not a look-back chance)
Oldes
@isagalaev

This comment has been minimized.

Copy link
Member

commented Nov 20, 2015

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

This comment has been minimized.

Copy link
Author

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 added some commits Nov 22, 2015

Red language: adding some relevance settings to better discover Red i…
…nstead of Asciidoc in small code samples.
@Oldes

This comment has been minimized.

Copy link
Author

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:)

Oldes added some commits Nov 22, 2015

Red language: fine tuning relevance and illegals for more precise det…
…ection without conflicts in tests and adding description
@isagalaev

This comment has been minimized.

Copy link
Member

commented Nov 23, 2015

@Oldes

This comment has been minimized.

Copy link
Author

commented Nov 24, 2015

@isagalaev of course I was reading it, but there is no notice, that I must build the node version just before running the test. 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.

But I need more help with current version:

  1. what I should do to get for example remove-each recognized as a keyword?
  2. how it is possible that word each is highlighted as hljs-number?
  3. what I should change to correctly highlight foo'bar as a single word?

In Rebol/Red 'foo is called lit-word, but should not start in the middle of the word as I have it now. I suspect I have incorrect understanding of lexemes, probably. :-(

Thanks.

@isagalaev

This comment has been minimized.

Copy link
Member

commented Dec 1, 2015

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.

Noted. We should probably add a special error message for this case…

About lexemes… They only make sense in combination with keywords, as they're highlighted in a separate pass (by a historic accident). And for the most common case of single word lexemes the default is good enough. That's why very few languages actually use this attribute anywhere.

what I should do to get for example remove-each recognized as a keyword?

{
  lexemes: /\b[\w-]+\b/,
  keywords: 'remove-each ....'
}

how it is possible that word each is highlighted as hljs-number?

That's weird. No idea at the moment :-)

what I should change to correctly highlight foo'bar as a single word?

You can add apostrophe to the lexemes regex as well. Or, if it's not as keyword but a separate thing, define a new mode with an appropriate begin.

@isagalaev isagalaev removed this from the 9.0 milestone Dec 2, 2015

@Sannis Sannis added this to the 9.1 milestone Dec 2, 2015

@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 some commits Apr 20, 2017

Oldes
Red language: improved date detection, proper keywords detection and …
…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

This comment has been minimized.

Copy link

commented Apr 24, 2017

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

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

@isagalaev

This comment has been minimized.

Copy link
Member

commented May 31, 2017

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Author

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

This comment has been minimized.

Copy link
Member

commented Jun 8, 2017

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.