Closed k-poole closed 5 years ago
I'm the one who reported this over email. I played around with this example and discovered something: only code surrounded by braces is highlighted. So if you surround the whole example with {...}
, then syntax highlighting works throughout.
I don't think that it should require the braces. I think a common use-case of this tool (tohtml) is syntax highlighting snippets, not complete code blocks.
please attach this example
Here ya go @ctapmex ... wait, that did the same thing again. I have no idea what you mean by attaching the example then!
Also @sharpedavid this isn't specifically tohtml, this is just part of the library that the code uses :)
I bet he means text instead of image. I won’t be able to post that example until tomorrow, but here’s a simpler example:
With Java syntax highlighting, System.out.println(“Hello world!”);
does not highlight, but {System.out.println(“Hello world!”);}
does.
(Posting on mobile.)
Ah yep nice one!
@ctapmex does that help?
Cheers guys.
where do you check ? colorer.exe , far, Eclipse ? if Eclipse - I do not know how to help you. I do not know how to build a plugin for Eclipse
@ctapmex any implementation of java.hrc will have this issue. I have confirmed this by replacing it with another HRC file, and the issue goes away. Something in java.hrc is causing it to stop processing the code without curly brackets.
You can test it on https://tohtml.com by selecting 'Java' (instead of autodetect) and pasting some code in.
hrc is just the rules. It needs a rule handler (colorer binary, farcolorer, eclipse colorer, etc) . The handler can fail . What handler is used on this site, I do not know. This is not "our" site. take FarManager https://farmanager.com/download.php?l=en and check file in far text editor (F4).
@ctapmex Yeah I figured as much. I don't know much about how it all works, but I inherited tohtml.com when Oleg could no longer run it. It uses colorer binary I believe, but regardless of that, I confirmed the problem seemingly in the java.hrc file by replacing its contents with another HRC file and just changing "type name=".
I just did a quick test with Far and reproduced the issue. As shown:
Note the obvious issue with "user" being highlighted when the entire snippet is within {}, but not when outside.
Cheers -KP
ok. can you send this file? or I will have to type it manually for tests ;)
@ctapmex it was just some random code:
boolean userHeaderFound = false;
for (SoapHeader soapHeader : soapHeaders) {
if (soapHeader.getName().getLocalPart().equals("user")) {
assertFalse("Multiple user headers found.", userHeaderFound);
userHeaderFound = true;
String nodeValue = ((SOAPElement) soapHeader.getObject()).getFirstChild().getNodeValue();
assertEquals("BESTSystem", nodeValue);
}
}
assertTrue("No user header found.", userHeaderFound);
List<String> userHeaderValues = new ArrayList<>();
for (SoapHeader soapHeader : soapHeaders) {
if (soapHeader.getName().getLocalPart().equals("user")) {
userHeaderValues.add(((SOAPElement) soapHeader.getObject()).getFirstChild().getNodeValue());
}
}
assertEquals(1, userHeaderValues.size());
assertEquals("BESTSystem", userHeaderValues.get(0));
List<SoapHeader> userHeader = soapHeaders.stream()
.filter(header -> header.getName().getLocalPart().equals("user"))
.collect(Collectors.toList());
assertEquals(1, userHeader.size());
String nodeValue = ((Element) userHeader.get(0).getObject()).getFirstChild().getNodeValue();
assertEquals("BESTSystem", nodeValue);
well, I understood what was the matter. I will try to explain through 'google translate'. Colorer doesn't just color the text by seeing keywords and symbols. Coloring goes according to context. If the file has incorrect language syntax, then the coloring will not be correct. The test case contains the contents of the function. A function must begin with a name and {.
Ah okay.
@sharpedavid thoughts? I am no Java expert sorry, so did not even consider this partial syntax issue.
I did a test with https://www.cs.utexas.edu/~scottm/cs307/javacode/codeSamples/PrimeEx.java and it appears to highlight fine.
@ctapmex While that makes sense, the vbasic.hrc file does not seem to work this way, and still highlights type descriptors such as String, and quoted text such as "user".
Thanks
as far I remember vbasic, this is the correct syntax for it
Hi everyone, thanks for spending time on this. This all sounds fine to me. It sounds like the library is working as intended.
Really the only reason I reported this is because it appeared to work for half of the sample, but not for the other half. This made me think there was a defect, but I understand now it's working as intended.
Again, thanks for your support, everyone. I recommend closing this ticket.
Confirmed an issue with java.hrc by replacing with vbasic.hrc and the issue went away.
Test on tohtml.com eg: