Skip to content

FIX: OCaml syntax highlighting - line directive#29

Open
cakedev0 wants to merge 9 commits intopatricoferris:mainfrom
cakedev0:fix/ocaml-syntax-highlighting
Open

FIX: OCaml syntax highlighting - line directive#29
cakedev0 wants to merge 9 commits intopatricoferris:mainfrom
cakedev0:fix/ocaml-syntax-highlighting

Conversation

@cakedev0
Copy link

@cakedev0 cakedev0 commented Dec 5, 2025

Fixes #23

Context: This issue is seriously damaging the readability of the manual. I was completely new to OCaml, and this generated a lot of perplexity, and it took me a while to understand it was a syntax highlighting bug. It was a fairly unpleasant first experience with the language.

How I did this PR: I iterated using Copilot. I vaguely understand the changes, and they feel right. I do understand the new test well, and it seems good.

Changes:

  • [Copilot did it] Fix the line directive pattern: Changed from ^[[:space:]]*(#)[[:space:]]*([[:digit:]]+) to ^[[:space:]]*(#)[[:space:]]*([[:digit:]]+)[[:space:]]+\". This ensures it only matches actual line directives (like # 123 "file.ml"), not REPL prompts with numbers (like # 50 * 50)
  • [I mostly did this] Add a test with some examples from the OCaml manual that would break before the fix and also a real line directive, to check this wasn't broken by the fix.

Copilot AI and others added 9 commits December 4, 2025 16:17
- Reorder pattern matching to check operators/literals before comments
- Fix floating point regex to properly match complete decimal numbers like 6.28

Co-authored-by: cakedev0 <25986961+cakedev0@users.noreply.github.com>
Co-authored-by: cakedev0 <25986961+cakedev0@users.noreply.github.com>
@cakedev0 cakedev0 changed the title Fix/ocaml syntax highlighting FIX: OCaml syntax highlighting - line directive Dec 5, 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.

Inconsistent Syntax Highlighting for Integers in OCaml Manual Code Examples

2 participants