Skip to content

fix(ex) #4238 and add test #4241

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

Merged
merged 4 commits into from
Apr 23, 2025

Conversation

codingthat
Copy link
Contributor

Adds support for the ?' char literal and the missing defguardp keyword.

Resolves #4238 — see more detail there.

Changes

  • Adds a simple regex just for one char literal, ?', that otherwise breaks formatting significantly by turning on comment mode.
  • Adds support for the defguardp keyword, which happened to be missing.
  • Adds a line that covers both of these to the detector sample for Elixir.

Checklist

  • Added markup tests
  • Updated the changelog at CHANGES.md

Copy link

Build Size Report

Changes to minified artifacts in /build, after gzip compression.

3 files changed

Total change +28 B

View Changes
file base pr diff
es/languages/elixir.min.js 1.15 KB 1.16 KB +13 B
highlight.min.js 8.23 KB 8.23 KB +1 B
languages/elixir.min.js 1.15 KB 1.17 KB +14 B

@@ -0,0 +1,2 @@
defguardp apostrophe?(c) when c == ?'
defguardp upper?(c) when (c >= ?A and c <= ?Z)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are ?A and ?Z then? Are they not also char literals?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are, but char literals can be any character. To keep the change small and the matching efficient, I just targeted the most problematic case (at least for now). If you want to leave them absolutely consistent with other char literals, disabling highlighting ?' (I guess with className: null?) could also work.

Copy link

Build Size Report

Changes to minified artifacts in /build, after gzip compression.

2 files changed

Total change +27 B

View Changes
file base pr diff
es/languages/elixir.min.js 1.15 KB 1.16 KB +13 B
languages/elixir.min.js 1.15 KB 1.17 KB +14 B

Copy link

Build Size Report

Changes to minified artifacts in /build, after gzip compression.

5 files changed

Total change +31 B

View Changes
file base pr diff
es/core.min.js 8.19 KB 8.19 KB +1 B
es/highlight.min.js 8.19 KB 8.19 KB +1 B
es/languages/elixir.min.js 1.15 KB 1.16 KB +13 B
highlight.min.js 8.23 KB 8.23 KB +2 B
languages/elixir.min.js 1.15 KB 1.17 KB +14 B

Copy link

Build Size Report

Changes to minified artifacts in /build, after gzip compression.

2 files changed

Total change +33 B

View Changes
file base pr diff
es/languages/elixir.min.js 1.15 KB 1.16 KB +16 B
languages/elixir.min.js 1.15 KB 1.17 KB +17 B

@joshgoebel joshgoebel merged commit 9a70b83 into highlightjs:main Apr 23, 2025
19 checks passed
@codingthat codingthat deleted the elixir-char-literal-support branch April 24, 2025 08:22
@iHiD
Copy link

iHiD commented Apr 24, 2025

@joshgoebel Any idea when you'll cut a release on this? I'd like to get an updated version on Exercism at some point. No pressure though if it's not a good time etc!

ewwwin pushed a commit to ewwwin/highlight.js that referenced this pull request Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(Elixir) Apostrophe code point character literal syntax (?') comments out the rest of the code
3 participants