Syntax highlighting for Dart and Flutter

Overview
Comments
  • List<String> will be trimed in <pre>

    List will be trimed in
    	                                    
    

    Hi,

    I had a same Java code wrapped with <pre> tag, like this:

    List<Integer> arr = new List<Integer>;
    

    when I display it in flutter with highlight, it will be trimed to:

    List arr = new List;
    

    Is there a method to resovle it? Thanks!

    opened by yeszao 2
  • Add method to get a `TextEditingController`

    Add method to get a `TextEditingController`

    Only a widget can be accessed for now. Access to a TextEditingController based class that style it's text could be added. It would allow any TextField to highlight syntax.

    opened by dutrieuc 1
  • Double quotes (

    Double quotes (") are not escaped

    As far as I understand, double quotes (") should be escaped with &quot; in the generated HTML. <, > and & are correctly escaped.

    import 'package:highlight/highlight.dart' show highlight;
    
    main() {
      var source = '''main() {
      print("Hello <> World!");
    }
    ''';
    
      var result = highlight.parse(source, language: 'dart');
      var html = result.toHtml();
      print(html); // HTML string
    }
    

    Actual output is:

    <span class="hljs-built_in">print</span>(<span class="hljs-string">"Hello &lt;&gt; World!"</span>);
    

    Expected output is:

    <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;Hello &lt;&gt; World!&quot;</span>);
    
    opened by deen4861 0
  • Automate porting from JavaScript

    Automate porting from JavaScript

    I understand that this is a port from https://highlightjs.org

    I guess the port was automated to some extent, because language files contain the comment:

    // GENERATED CODE - DO NOT MODIFY BY HAND
    

    This package now has quite a number of bugs that are not reproducible with the original Highlight.js, like

    • #36
    • #37

    Also I can see no progress on older issues.

    Can you please share the process of this porting so anyone can fast-forward the changes in Highlight.js? These then can be contributed here or implemented in a fork. This would solve most of the problems.

    Or share any hints if the port was manual.

    @pd4d10 @shreyas1599

    opened by alexeyinkin 0
  • Multiline string literal breaks java highlighting

    Multiline string literal breaks java highlighting

    For this input:

    class MyClass {
      private string str = "abc";
    }
    

    we get the correct result:

    image

    Make this string literal multiline:

    class MyClass {
      private string str = """
      abc
      """;
    }
    

    and nothing is parsed:

    image

    Note that language is also null although java is explicitly passed.

    This codepen shows that the original highlightjs can handle multiline string literals: https://codepen.io/alexey-inkin/pen/abYYVOj

    Code
    import 'package:highlight/highlight_core.dart';
    import 'package:highlight/languages/java.dart';
    
    void main() {
      highlight.registerLanguage('java', java);
    
      const text = '''
    class MyClass {
      private string str = "abc";
    }
    ''';
      final result = highlight.parse(text, language: 'java');
      print(result.nodes);
    
      const textMultiline = '''
    class MyClass {
      private string str = """
      abc
      """;
    }
    ''';
      final resultMultiline = highlight.parse(textMultiline, language: 'java');
      print(resultMultiline.nodes);
    }
    
    Output
    [Instance of 'Node', Instance of 'Node', Instance of 'Node', Instance of 'Node', Instance of 'Node', Instance of 'Node', Instance of 'Node']
    [Instance of 'Node']
    
    opened by alexeyinkin 0
  • Number sign (#) breaks java highlighting

    Number sign (#) breaks java highlighting

    For this input:

    class MyClass {
    }
    

    we get the correct result:

    image

    Add a number sign:

    class MyClass {
    }#
    

    and nothing is parsed:

    image

    Note that language is also null although java is explicitly passed.

    Code
    import 'package:highlight/highlight_core.dart';
    import 'package:highlight/languages/java.dart';
    
    void main() {
      highlight.registerLanguage('java', java);
    
      const text = '''
    class MyClass {
    }
    ''';
      final result = highlight.parse(text, language: 'java');
      print(result.nodes);
    
      const textNumber = '''
    class MyClass {
    }#
    ''';
      final resultNumber = highlight.parse(textNumber, language: 'java');
      print(resultNumber.nodes);
    }
    
    Output
    [Instance of 'Node', Instance of 'Node', Instance of 'Node']
    [Instance of 'Node']
    
    opened by alexeyinkin 0
Owner
GitTouch
An open-source app for GitHub, GitLab, Bitbucket, Gitea, and Gitee(码云), built with Flutter
GitTouch
Dart JS interop for Mermaid - The Javascript tool that makes use of a markdown based syntax to render customizable diagrams, charts and visualizations.

Mermaid (Dart) Dart JS interop for Mermaid - Javascript library that makes use of a markdown based syntax to render customizable diagrams, charts and

Tim Maffett 3 Dec 12, 2022
An intuitive Token Parser that includes grammar definition, tokenization, parsing, syntax error and debugging. Implementation based on Lexical Analysis for Dart.

Token Parser An intuitive Token Parser that includes syntax/grammar definition, tokenization and parsing. Implementation based on Lexical Analysis. Re

JUST A SNIPER ツ 2 Dec 15, 2022
Simple Flutter text highlighting at the character-level.

substring_highlight Highlight Flutter text at the character-level. Designed for case-insensitive search-term highlighting, a single search term sub-st

Peter Alvin 39 Nov 16, 2022
Mysql.dart - MySQL client for Dart written in Dart

Native MySQL client written in Dart for Dart See example directory for examples

null 48 Dec 29, 2022
Flutter Navigation - all types of navigation in flutter run main.tabBar.dart to see tabBar, and run main.dart to see the otheres

pop_up_bar A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if th

Michael Odumosu 0 Jan 1, 2022
Flutter Dart-Projesi - Meditation app developed using Flutter and Dart

Müzik Çalar Meditasyon Uygulaması Medi Flutter ve Dart ile programlanmış bir med

null 2 Jan 29, 2022
A Dart client for the NATS messaging system. Design to use with Dart and Flutter.

Dart-NATS A Dart client for the NATS messaging system. Design to use with Dart and flutter. Flutter Web Support by WebSocket client.connect(Uri.parse(

Chart Chongcharoen 32 Nov 18, 2022
Flying Fish is full-stack Dart framework - a semi-opinionated framework for building applications exclusively using Dart and Flutter

Flying Fish is full-stack Dart framework - a semi-opinionated framework for building applications exclusively using Dart and Flutter.

Flutter Fish 3 Dec 27, 2022
This is a dart package that converts words to numbers. It can be used in Flutter and normal Dart programs

Wordstonumbers.dart Wordstonumbers.dart is a simple dart package that converts a string of simple worded numbers into digits (e.g one hundred -> 100).

Michael Essiet 3 Oct 17, 2022
I start to learn dart-flutter. And also this project was basics of Dart

learning_dart A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if

Natiq Haciyev 3 Dec 14, 2022
A Dart/Flutter package to perform network calls. It uses Isolates to perform network calls on Dart VM environments and WebWorkers on Web.

ArDriveHTTP ArDriveHTTP is a package to perform network calls for ArDrive Web. It uses Isolates to perform network calls on Dart VM environments and W

AR.IO 2 Dec 15, 2022
Socketio dart server and client - Full Socket.io implementation using Dart Lang

Getting Started Step 1: Run dart_server.dart Step 2: Android Emulator has proble

Trần Thiên Trọng 1 Jan 23, 2022
Dart web3 - A dart library that connects and interacts with the Ethereum blockchain

dart_web3 A dart library that connects and interact with the Ethereum blockchain

p2bh 9 Sep 13, 2022
Simple Dart package with build-in code generation. It simplifies and speedup creation of cache mechanism for dart classes.

Simple Dart package with build-in code generation. It simplifies and speedup creation of cache mechanism for dart classes.

iteo 37 Jan 2, 2023
GitHub Action that uses the Dart Package Analyzer to compute the Pub score of Dart/Flutter packages

Dart/Flutter package analyzer This action uses the pana (Package ANAlysis) package to compute the score that your Dart or Flutter package will have on

Axel Ogereau-Peltier 45 Dec 29, 2022
🎬 A movie catalog app for both Android & IOS ~ Flutter.io project in Dart | Dart, Bloc, Movies

Movie Catalog App ?? Browse through movies from the YIFY api Getting Started For help getting started with Flutter, view our online documentation. Tod

Jonas De Vrient 49 Nov 21, 2022
Docker images for the Dart programming language (https://dart.dev)

dart-docker This is the Git repo of the Docker "Official Images" for the Dart programming language. See the Docker Hub page for a full description on

Dart 49 Dec 14, 2022
A most easily usable Duolingo API wrapper in Dart. Duolingo4D is an open-sourced Dart library.

A most easily usable Duolingo API wrapper in Dart! 1. About Duolingo4D Duolingo4D is an open-sourced Dart library. With Duolingo4D, you can easily int

Kato Shinya 18 Oct 17, 2022