GithubHelp home page GithubHelp logo

tianking / any_syntax_highlighter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ssrajputtheboss/any_syntax_highlighter

0.0 0.0 0.0 191 KB

any_syntax_highlighter a flutter package for syntax highlighting

Home Page: https://pub.dev/packages/any_syntax_highlighter

License: MIT License

C++ 17.30% C 0.76% Objective-C 0.04% Kotlin 0.13% Dart 68.94% Swift 0.42% HTML 3.96% CMake 8.46%

any_syntax_highlighter's Introduction

any_syntax_highlighter

any_syntax_highlighter is a lightweight 'convention based' syntax highlighter which provides highlighting to input text code.

Features

  • add custom keywords or use default ones
  • convention based highlighting
    • identifiers starting with uppercase are considered as class/constructor
    • Class.abc => static variable
    • three types of comments are supported
      • single line comment staring with #
      • single line comment starting with //
      • multiline comment /*.....*/
    • identifier starting with _ => private
    • functions after . operator => method (highlighting for function and method are different)
  • Use google fonts! (Thanks to google_fonts library)

Note: boxDecoration has been changed to decoration since v0.0.12

Getting started

import package-

import 'package:any_syntax_highlighter/any_syntax_highlighter.dart';

github_web_theme default_theme_with_google_fonts

The above image contains McLaren font provided by google_fonts.

Usage

Basic usage

AnySyntaxHighlighter(
  '''Class Main{
  public static void main(String args[]){
    
  }
}'''
)

Usage with optional fields

AnySyntaxHighlighter(
          '#your code goes here',
          fontSize: 16,
          lineNumbers: false, // by default false
          theme: AnySyntaxHighlighterThemeCollection.githubWebTheme(), // you can create and pass custom theme using AnySyntaxHighlighterTheme class
          isSelectableText: true, // this creates a SelectableText.rich() widget, makes text selectable (by default false)
          useGoogleFont: 'Lato',
          copyIcon: const Icon(Icons.copy_rounded,color:Colors.black),// default is white colored icon
          hasCopyButton: true,// by default false
          /* other options are:- 
          padding,
          margin,
          textAlign,
          this.textDirection,
          softWrap,
          overflow,
          textScaleFactor,
          maxLines,
          locale,
          strutStyle,
          textWidthBasis,
          textHeightBehavior,
          overrideDecoration
          */
)

Using Google Fonts

You can add any of the google fonts available in google_fonts library. Just pass a string name of google font you want to use to useGoogleFont property

AnySyntaxHighlighter(
  '// google fonts usage demo',
  useGoogleFont: 'Lato'
)

Don't forget to add appropriate License for the font you are using for more details read google_fonts documentation.

packages,classes and their definition

package/classes definition
AnySyntaxHighlighter Widget that provides highlighting
AnySyntaxHighlighterBaseTheme super class of AnySyntaxHighlighterTheme no use case for user
AnySyntaxHighlighterTheme for making custom themes you can use this class and pass it to theme option of widget
AnySyntaxHighlighterThemeCollection collection of default themes provided by this package
RegexCollection collection of regular expression strings used to tokenize the input code, no or less use case for user
Token token class for internal usage only

Additional information

Open for contribution, specially if you can create themes using our web tool AnySyntaxHighlighterThemeLab For themes you need not necessarily need to raise an issue just build the theme, make sure you do these things:-

  • your made changes to any_syntax_highlighter_theme_collection.dart file only
  • you have dart formatted your code before making pull request

If you find any bug/suggestion feel free to raise an issue on github repository.

any_syntax_highlighter's People

Contributors

ssrajputtheboss avatar tianking avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.