Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

175
Views
How to make a syntax highlighter that highlights symbols

I wanted to make a syntax highlighter that highlights symbols. Look at the example:

function hello(){
  return "hello";
}

I want to highlight all the symbols:

{([</!&|\>])};.,:=+*-@$~_^?%'"

And I made a little one that highlighted strings. When I wanted to make one that highlights symbols I got confused. Now I want to know What topics should I learn to make it? Any example, github repo, tutorial, topic or ...? EDIT: I found the way to do that but I still have problem. My code is the following:

function syntaxue(){
  var codes = document.getElementsByClassName("syntaxue");
  for (var i=0; i < codes.length; i++){
    var data = codes[i].innerHTML;
    data = data.replace(/([^\w\s])/g, '<span class="sym">$1</span>');
    data = data.replace(/([\d])/g, '<span class="num">$1</span>');
    codes[i].innerHTML = data;
  }
}

When I want to highlight strings, the code becomes sth else.(Sorry I'm not English) And I was testing HTML markup I saw this:

&lt;html&gt;

Instead of this:

<html>

And the &; symbols were highlighted not their results. Can anyone help me?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!