Git Product home page Git Product logo

Comments (19)

rtfpessoa avatar rtfpessoa commented on May 24, 2024

Yup, that is quite bad.

I had one idea to try solving that problem.
It seems to improve overall highlight but still doesn't fix java comments.

The idea is to invoke highlight in the block and then inject the highlighted lines of the block in the HTML again.

How it is looking after the improvement:
image

I did one commit here: a482097

Edit: I think the main problem is that it puts the whole comment in a span and since I am splitting the comment by line it destroys the html.

I had a crazy idea for the hljs side and created an issue highlightjs/highlight.js#1167

from diff2html.

lantian avatar lantian commented on May 24, 2024

Haha, I have tried such thing (just same code as yours) yesterday, too! =). Yup, not closed span problem =). Nice try with highlightjs/highlight.js#1167, will hope that they offer something.

from diff2html.

rtfpessoa avatar rtfpessoa commented on May 24, 2024

Thanks to @isagalaev I was able to fix the highlight in affd71e .

Now highlight should be perfect except for cases where the diff
context is not enough to understand what is the code.

When highlight.js opens this part to the API I can remove the code.

from diff2html.

lantian avatar lantian commented on May 24, 2024

Wow! This is great! Thank you very much!

from diff2html.

lantian avatar lantian commented on May 24, 2024

Found new problem, now it looses "hljs" class and language class:
Was:
1

Now:
2

from diff2html.

lantian avatar lantian commented on May 24, 2024

Missing buildClassName function (from highlight API). But currently I don't where it must be. Will try to find correct place.

from diff2html.

rtfpessoa avatar rtfpessoa commented on May 24, 2024

@lantian should be fixed here 719b1cd

from diff2html.

lantian avatar lantian commented on May 24, 2024

Yes! Thanks!

from diff2html.

rtfpessoa avatar rtfpessoa commented on May 24, 2024

BTW, I also have another bug in mind. And I will try to fix it soon.

Basically we have two code snippets in each diff, the old and the new.
If we parse them together it might not make sense. I will fix this by having two states one for each part.
And this way it should be even more accurate.

from diff2html.

rtfpessoa avatar rtfpessoa commented on May 24, 2024

@lantian should be fixed here 73999bb

from diff2html.

lantian avatar lantian commented on May 24, 2024

Seems to be ok! Thank you!

from diff2html.

rtfpessoa avatar rtfpessoa commented on May 24, 2024

I will see if there are any more problems and will probably deploy this soon.

from diff2html.

lantian avatar lantian commented on May 24, 2024

👍

from diff2html.

isagalaev avatar isagalaev commented on May 24, 2024

If you guys don't mind me to weigh in, you probably don't need buldSpan() or any code from highlight.js itself to assign two classes on a container. "hljs" is a constant, and it looks like you know the language name anyway, since you call highlight() with it (and I'm not sure you even need the language in the class attribute).

All this of course is up to you, I'm just pointing out that assigning classes to an outside container is not tied to the highlighting process in any way.

from diff2html.

rtfpessoa avatar rtfpessoa commented on May 24, 2024

@lantian noticed that some colors where not being correctly set without the classes.

I am not sure if it was depending on hljs and the language or just hljs.

In my case I only know the one of the language alias, usually the extension.

@isagalaev do you think it might work only with hljs?

Edit: I checked the CSS and they seem language agnostic.
Edit2: After all I really have the language in the result. I will add it manually.

Thanks for pointing it 👍

from diff2html.

isagalaev avatar isagalaev commented on May 24, 2024

Edit: I checked the CSS and they seem language agnostic.

Yes, this was an express design goal for a big refactoring a while ago. Provided you're on version 9 or later.

do you think it might work only with hljs?

You shouldn't even need that. The only stuff that gets assigned to ".hljs" class itself is this:

.hljs {
  display: block;
  overflow-x: auto;
  padding: 0.5em;
  background: ... ; color: ... ;
}

And you have your own block formatting rules and base colors, I believe.

from diff2html.

rtfpessoa avatar rtfpessoa commented on May 24, 2024

@isagalaev actually it was @lantian not sure what were the custom theme/colors he was using.

fyi, this was released as version 2.0.0-rc.3.

from diff2html.

isagalaev avatar isagalaev commented on May 24, 2024

Cool! Always nice to see highlight.js being used in some interesting fashion :-)

from diff2html.

lantian avatar lantian commented on May 24, 2024

The theme was: "Sunburst-like style (c) Vasily Polovnyov [email protected]"
And exactly missing ".hljs" class was a problem - that class is defined in theme (with css color property) and wasn't provided by the script. From that point I have no any custom css related to highlight =), only for diff2html.

from diff2html.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.