DEV Community

Felippe Regazio
Felippe Regazio

Posted on

7

I Created a pure Unicode Code Highlighter :P

The tool is called "Unilight". It is a simple parser and module that modifies unicode variation of string parts.

So you can highlight anywhere that doesn't accept rich editing, just have a pure string that accepts unicode variations. Works for almost any lang, take a look, this is a simple and pure STRING haha:

.......
// π•‹π•™π•šπ•€ π•šπ•€ π•’π•Ÿ π•–π•©π•’π•žπ•‘π•π•–

π—³π˜‚π—»π—°π˜π—Άπ—Όπ—» example() {
π—°π—Όπ—»π˜€π˜ a = "fizz";
π—°π—Όπ—»π˜€π˜ b = "buzz";
π—Ώπ—²π˜π˜‚π—Ώπ—» a+b;
}
.......

You can highlight your code here:
https://felippe-regazio.github.io/unilight/

Source code and documentation here:
https://github.com/felippe-regazio/unilight

Warning:

This is a toy project made for aesthetic reasons only (just wanted to code). I made it because I wanted to study a few things about parsers and do something with it. However, there are important weaknesses of this technique:

  1. Systems that do not support unicode will not display the text

  2. Since unicode variations are hidden characters, the string will always be longer than it looks

  3. Interpreters will not run the code because they don't know these chars, it will have to be sanitized

The tool is more useful for aesthetic reasons in fact, you can highlight simple snippets on a tweet, for example. I think the most interesting thing here is: The source code and the relationships between it (if you're a beginner/intermediate it might be a good thing to see given its simplicity), and the parser (if you're more advanced in js, good luck with that).

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (1)

Collapse
 
cicirello profile image
Vincent A. Cicirello β€’

Very cool idea. Thanks for posting about it.

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post