ematsakov / highlight

Jquery Highlight Plugin allows syntax highlighting of source code snippets in an html page.
10 stars 2 forks source link

proposal: Split PHP side to seperate module #18

Open owenBeresford opened 1 year ago

owenBeresford commented 1 year ago

Hi , I have added patches to JS library a few times. I note that the PHP function names are 50% of the file. If you don't use PHP at all this is a waste of space.

Propose: split this into "highlight" and "highlight-php" versions in the repo.
I have no idea how much this library is used as its jQuery.

EDIT: group languages as (PHP, bash, SQL) and (HTML, CSS, JS) look at adding Python, Typescript, Golang etc

owenBeresford commented 1 year ago

I could offer another patch.

ematsakov commented 1 year ago

Hi, @owenBeresford

Thanks for participating in expanding this plugin. Sure, feel free to suggest pull request with additional PHP functions list.

Propose: split this into "highlight" and "highlight-php" versions in the repo. I have no idea how much this library is used as its jQuery.

Agree, makes sense to review plugin structure and separate "hightlight_php" logic into sub module. Maybe makes sense to separate all languages into sub modules and lazy load them only if necessary ( in case highlight block exists on the page for corresponding language ). I'm going to review this library soon and use it on my new site. Maybe I will get rid of JQuery and rewrite it with pure javascript to keep it as light as possible.

And yes, currently I do not use it a lot :)

Thanks for your interest!

owenBeresford commented 1 year ago

I think the choice of keeping jQuery or not is important. If you look at https://www.npmjs.com/package/jquery-highlight it has 9K downloads/week. BUT https://www.npmjs.com/package/highlight.js has >6,000,000 dl/week. I have used https://www.npmjs.com/package/prismjs which is >7,000,000 at work. I do not build brochure sites in wordpress, which is where most jQuery is used, I guess. A github issue isn't the best mechanism for user survey.

It is just time to replace the jQuery functions with plain JS, as many features have been added to the language since jQuery started. Im adverse to committing the time if there is no volume of interest from users.

My boring website is using your library, and will probably keep using it.

owenBeresford commented 1 year ago

oh the other suggested thing if doing major works is porting to TS.

ematsakov commented 1 year ago

Hi, @owenBeresford Not sure about TypeScript, but I'm definitely planning to migrate highlight plugin to native javascript with a lot of improvements in near future. And will use it on my personal site I just created - https://matsakov.com/ Prototype how it will look for PHP syntax highlighting you can see on homepage of my site. Color scheme is taken from Sublime 3.

Unfortunately, I only can work on this in my spare from work and family time... so not much :)

owenBeresford commented 1 year ago

For planning: https://lor.sh/@tennoseremel/110684294463710459

owenBeresford commented 1 year ago

I just sent you another fix from last year.

Todate I have :

because I was the audience who needed it.

Its more sensible to start with a fresh repo if you remove Jquery; but in that case one of the above things in NPM are a pre-packed solution. A second benefit to the NPM version is the test populations.

Does Sublime3 have handy syntax files of keywords? I only mentioned the editor in the previous commits to claim the list I added should be good quality. It is irrelevant otherwise.

ematsakov commented 1 year ago

Thanks for your pull request. Merged.

Yeah, I'll start new repo for 2nd version and get rid from JQuery for sure.

Its more sensible to start with a fresh repo if you remove Jquery; but in that case one of the above things in NPM is a pre-packed solution. A second benefit to the NPM version is the test populations.

Releasing on npmjs.com makes sense. But in this case it will better to implement package which will work both on client and server ( node ) side to be able to use in frameworks like NextJS which supports server side rendering. Not sure I have a lot of time for this now. And naming is open question. As package with the same name and functionality exists https://www.npmjs.com/package/highlight.js

Does Sublime3 have handy syntax files of keywords? I only mentioned the editor in the previous commits to claim the list I added should be good quality. Its irrelevant otherwise.

As I know, Sublime packages are in binary format. So not sure if they have all possible keywords or parse code according to some rules.

owenBeresford commented 11 months ago

This is still on my #TODOLIST however, if/when I do this:

owenBeresford commented 6 months ago

Some tech I have been waiting on:

... simple DOM

owenBeresford commented 2 months ago

I built a different solution, using highlight.js. I have dropped jQuery (250KB JS down to 9KB JS) ad am using new test frameworks and TS.

https://github.com/owenBeresford/extra-panda/