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

Unicode highlight in Coq (or other lang) #1312

Closed
Huxpro opened this issue Aug 22, 2019 · 9 comments · Fixed by #1319 or #1764
Closed

Unicode highlight in Coq (or other lang) #1312

Huxpro opened this issue Aug 22, 2019 · 9 comments · Fixed by #1319 or #1764
Labels
bugfix-request A request for a bugfix to be developed.

Comments

@Huxpro
Copy link

Huxpro commented Aug 22, 2019

Screen Shot 2019-08-22 at 3 37 38 PM

This issue is similar to #621 or #831 where the Unicodes are highlighted with a bold concrete background (I guess it's an error?).
It looks like #621 is fixed by manually accepting more alphabet symbols.
Could there be a unified fix for deemphasizing the lex errors on Unicode?

Noted that using Unicode here in Coq is actually syntactically invalid but yet a common way in writing (say the Software Foundation books). Trying to highlight Agda code (where Unicode is universally used) with Haskell will encounter a similar issue.

@Huxpro Huxpro added the bugfix-request A request for a bugfix to be developed. label Aug 22, 2019
@Huxpro Huxpro changed the title Unicode highlight in Coq Unicode highlight in Coq (or other lang) Aug 22, 2019
@pyrmont
Copy link
Contributor

pyrmont commented Aug 22, 2019

@Huxpro Yeah, a way to deemphasise errors is an interesting idea. The difficulty is how to do that? The simplest way I can think of would be to insert an additional class into the generated HTML that users could then use to affect the styling.

Oh, and could you copy and paste the example text you tried to lex? Sorry the dingus isn't accepting new saves at the moment :(

@Huxpro
Copy link
Author

Huxpro commented Aug 23, 2019

Thx @pyrmont. I guess brutely override .highlight .err as whatever in user-land could workaround but I agreed how to do it elegantly is tricky.

here is the code:

Theorem ev_plus4 : ∀n, even n → even (4 + n).
Proof.
  intros n H. simpl.
  apply ev_SS.
  apply ev_SS.
  apply H.
Qed.

@pyrmont
Copy link
Contributor

pyrmont commented Aug 23, 2019

@Huxpro I would also like to have a fix for the Coq lexer that allows the types of characters commonly used in the community.

The difficulty I'm having is finding a regular expression that doesn't match symbols that are used as punctuation or as operators (there are alternatives to this approach but this is my preferred solution). The ∀ character, for example, is part of the 'Math Symbol' general category but so is the + character.

Are there a common set of additional characters used that we want to (effectively) whitelist? Or do people use any old Unicode character they feel like?

@jneen
Copy link
Member

jneen commented Aug 23, 2019

you can actually put those characters literally in a regex, if they're common enough we may want to add them to haskell/coq.

@pyrmont
Copy link
Contributor

pyrmont commented Aug 23, 2019

@jneen Yeah, that's kind of where my mind was going too :)

@Huxpro
Copy link
Author

Huxpro commented Aug 25, 2019

@pyrmont Coq has some meta-programming power so it might be tricky to cover all cases... essentially, math symbols commonly used in logic and set theory are most used and might be sufficient:

A tentative list could be

  • def/implications
  • quantification
  • logical connectives /\ \/ ¬
  • top/bottom
  • proof/entail
  • set ...

A code example could be:

Theorem progress : ∀t T,
  empty ⊢ t ∈ T →
  value t ∨ ∃t', t --> t'.

I just realized Rouge used by Jekyll is version-frozen and my tentative uses were for Github Pages so my temporary workaround (in less) is:

.language-coq .highlight .err {
  &:extend(.highlight .k);
  background-color: transparent;
}

@tomtomjhj
Copy link

Some coq projects make heavy use of unicode indentifiers and notations and their highlighting is severely broken on gitlab. Example: https://gitlab.mpi-sws.org/iris/iris/-/blob/master/iris_heap_lang/adequacy.v
image

Github's highlighter seems to ignore everything it doesn't recognize, and I think that is much more readable in general.
image

@pyrmont pyrmont removed their assignment Jan 4, 2021
@pyrmont pyrmont reopened this Jan 4, 2021
@pyrmont
Copy link
Contributor

pyrmont commented Jan 4, 2021

@tomtomjhj I'm no longer maintaining Rouge but have reopened the issue.

@stale
Copy link

stale bot commented Jan 8, 2022

This issue has been automatically marked as stale because it has not had any activity for more than a year. It will be closed if no additional activity occurs within the next 14 days.
If you would like this issue to remain open, please reply and let us know if the issue is still reproducible.

@stale stale bot added the stale-issue There has been no activity for a year. label Jan 8, 2022
@stale stale bot closed this as completed Apr 16, 2022
@tancnle tancnle reopened this Apr 18, 2022
@stale stale bot removed the stale-issue There has been no activity for a year. label Apr 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix-request A request for a bugfix to be developed.
Projects
None yet
5 participants