-
Notifications
You must be signed in to change notification settings - Fork 143
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
Rename HighlightLines::highlight()
to highlight_line()
for clarity
#314
Comments
Thanks for reporting. If it were an issue with regex-fancy (or unsupported regex syntax), I'd expect to see some failures for the Python syntax tests, but there are none: If I understand correctly, Cobalt is using the assets bundled by default with syntect, right? So it is not like its using a syntax definition syntect doesn't support yet. I'll try to make some time to investigate further. |
interestingly, executing the cargo run --no-default-features --features default-fancy --example synhtml ./testdata/Packages/Python/syntax_test_python.py > synhtml_fancy.html
cargo run --no-default-features --features default-onig --example synhtml ./testdata/Packages/Python/syntax_test_python.py > synhtml_onig.html
cksum ./synhtml*.html
diff --report-identical-files ./synhtml_fancy.html ./synhtml_onig.html
Files ./synhtml_fancy.html and ./synhtml_onig.html are identical
The same with the test Python file you provided, and it looks correct: I agree from your scenario that if it works with onig, but not fancy-regex that it seems like a fancy-regex problem, but I'm confused why I'm not seeing the same thing with the |
Correct, we are using the default assets. Thanks for looking into this! |
I have tweaked the parser to debug print the "operations", pointed cobalt to my local syntect changes, built it and served it and saw that the whole code block string is being passed into a syntect method which expects a single line at a time - here is a snippet from the output:
Using Liquid templates instead of Markdown in the
So I hate to say it, but it looks like a bug in cobalt.rs and the way Markdown code blocks are passed into syntect... As for why does Onig give different output to fancy-regex - well, I guess fancy-regex just doesn't behave the same way in some situations, or Onig defaults to multiline regex mode and fancy-regex doesn't or something - I haven't looked into this further. |
Oh, that inconsistent implementation is weird. Sorry for wasting your time on a bug in my code. |
Hmm, I wonder if something should be changed about the API (on next major bump), like renaming If I'm reading zola right, it has the same problem
|
I was thinking something similar :) or to add a |
I agree
and the parameter name is I think that is clear enough to justify closing this issue to keep the issue inbox clean and organized :) |
I disagree. People are more likely to be building off of code samples rather than looking at rusdocs and will miss both what the function documentation says and what the parameter name is. As shown in this thread, at least two users of syntect got this wrong. A more specific function name would completely clear this up. As said, this doesn't need to be a breaking change. A new function can be introduced and the existing function deprecated. I feel like this is very similar, in spirit, to the "don't use bools" You can say that the documentation and parameter name are sufficient but over time many people have come to the conclusion to exercise caution in using |
HighlightLines::highlight()
to highlight_line()
for clarity
Ok, sure, let's reopen. |
To make it clear that the function takes one line at a time. This require a semver major bump, but we need to do that anyway due to the syntax lazy-loading changes. Fixes trishume#314
To make it clear that the function takes one line at a time. This require a semver major bump, but we need to do that anyway due to the syntax lazy-loading changes. Fixes trishume#314
With cobalt when I have the following code block
it gets highlighted as:

See cobalt-org/cobalt.rs#802
If I switch from
regex-fancy
toregex-onig
, it works.Unsure if this is a dupe of #287
The text was updated successfully, but these errors were encountered: