highlightjs / highlight.js

JavaScript syntax highlighter with language auto-detection and zero dependencies.
https://highlightjs.org/
BSD 3-Clause "New" or "Revised" License
23.54k stars 3.58k forks source link

(Dart) Highlight colors for Class and Constructor Calls #4091

Open Husseink-hagag opened 1 month ago

Husseink-hagag commented 1 month ago

Describe the issue

The current output lacks color for class names and constructor calls so most lines are displayed in the same color, which significantly impacts readability and makes it challenging to distinguish between different code components. In contrast

Which language seems to have the issue?

Dart (the issue is impacting Flutter)

Are you using highlight or highlightAuto?

highlight

...

Sample Code to Reproduce


import 'package:flutter/material.dart';

void main() {
  runApp(MaterialApp(
    home: Scaffold (
      appBar: AppBar(
        title: const Text('Scaffold Example'),
      ),
      body: const Center(
        child: Text('Hello, World!'),
      ),
      drawer: Drawer(
        child: ListView(
          children: const <Widget>[
            ListTile(title: Text('Home')),
            ListTile(title: Text('Profile')),
          ],
        ),
      ),
      bottomNavigationBar: BottomNavigationBar(
        items: const [
          BottomNavigationBarItem(icon: Icon(Icons.home), label: 'Home'),
          BottomNavigationBarItem(icon: Icon(Icons.search), label: 'Search'),
        ],
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {},
        child: Icon(Icons.add),
      ),
    ),
  ));
}

Expected behavior Highlight colors for Class and Constructor Calls

Additional context

Here are two images: (1) - displaying the current output from the Highlight library , where all elements appear in the same color, making it difficult to read. (2) - a different library, which shows custom colors for classes and constructors. Both images feature code written in Dart for Flutter.

highlight

other

joshgoebel commented 1 month ago

I don't see a lot of "patterns" to go off of here (to find a specific constructor, etc), but it'd probably be easy to improve "attribute" (or attr, I always forget) like child: and if CamelCaseClasses is syntax or idiomatic Dart then we could probably just have a general rule for those - regardless of where they are in the grammar.

Are you interesting in working on a PR for this?