highlight.js
highlight.js copied to clipboard
(Dart) Highlight colors for Class and Constructor Calls
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.
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?
@Husseink-hagag can you tell me a bit more about this issue, like if you tried to look into the repository or made any progress. Since I was reading the docs of this repo from past few days, I want to contribute to this issue, @joshgoebel can you please assign me this.
We don't have that many people vying to complete issues - if you want to work on it, just do it and submit a PR and we're happy to look at it.
So Dart's convention seems to be PascalCase, which is very similar as say Ruby, Wren, etc... so I think we could start by copying the CLASS_NAME_RE and CLASS_NAME_REFERENCE right out of Ruby and then see how that looks.
@reenakp2601 are you still working on this? If you're planning to submit a fix I'll leave it to you, otherwise I can take it over