any_syntax_highlighter 0.0.2 any_syntax_highlighter: ^0.0.2 copied to clipboard
any_syntax_highlighter is a "convention" based syntax highlighting tool.
any_syntax_highlighter #
any_syntax_highlighter is a 'convention based' syntax highlighter which provides highlighting to input text code.
Features #
- set of keywords of ~9 programming languages which are mostly used ( if needed will add more...)
- 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 now different)
Getting started #
import package-
import 'package:any_syntax_highlighter/any_syntax_highlighter.dart';
Usage #
Basic usage
AnySyntaxHighlighter(
'''Class Main{
public static void main(String args[]){
}
}'''
)
Usage with optional fields
AnySyntaxHighlighter(
'#your code goes here',
fontSize: 16,
lineNumbers: true, // by default false
theme: AnySyntaxHighlighterThemeCollection.githubWebTheme, // you can create and pass custom theme using AnySyntaxHighlighterTheme class
isSelectable true, // this creates a SelectableText.rich() widget, makes text selectable (by default false)
padding = 2,
margin = 0,
/* other options are:-
textAlign,
this.textDirection,
softWrap,
overflow,
textScaleFactor,
maxLines,
locale,
strutStyle,
textWidthBasis,
textHeightBehavior,
*/
)
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 you can create beautiful themes using our web tool AnySyntaxHighlighterThemeLab For themes you need not necessarily need to raise an issue just build the theme, make sure you 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.