https://github.com/binkaps/parsely
Versatile tool designed to enhance text parsing and masking capabilities within your Flutter applications.
https://github.com/binkaps/parsely
dart flutter linkify parsely
Last synced: 3 months ago
JSON representation
Versatile tool designed to enhance text parsing and masking capabilities within your Flutter applications.
- Host: GitHub
- URL: https://github.com/binkaps/parsely
- Owner: binkapS
- License: mit
- Created: 2024-03-29T15:58:49.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-18T01:39:34.000Z (7 months ago)
- Last Synced: 2025-03-16T16:58:21.972Z (4 months ago)
- Topics: dart, flutter, linkify, parsely
- Language: Dart
- Homepage: https://binkap.com
- Size: 37.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Parsely
**Parsely** is a powerful tool for text parsing and masking in your Flutter applications. It allows you to extract various entities such as links, email addresses, @mentions, hashtags, and phone numbers from text. Additionally, Parsely offers customizable masking functionality to obscure sensitive information while keeping it in the desired format and ensuring it's still clickable.
## Key Features
- **Entity Parsing**: Effortlessly parse links, email addresses, @mentions, hashtags, and phone numbers embedded within text strings.
- **Customizable Masks**: Define custom masks to obscure sensitive information like email addresses or phone numbers while retaining their format.
- **Clickable Entities**: Automatically convert parsed entities (links, emails, phone numbers, etc.) into clickable elements that users can interact with.
- **Flexible Integration**: Easily integrate the parsing and masking functionality into your Flutter applications with minimal setup.
- **Performance Optimized**: Designed to handle large volumes of text efficiently while ensuring smooth user experience.
- **Cross-Platform Support**: Fully compatible with all platforms supported by Flutter, including iOS, Android, Web, and Desktop.## Use Cases
- **Social Media Apps**: Enhance engagement by making @mentions and hashtags clickable in posts or comments.
- **Messaging Platforms**: Improve UX by automatically parsing and masking phone numbers and email addresses in conversations.
- **E-commerce Apps**: Protect user privacy by masking sensitive details (like emails or phone numbers) while allowing clickable product links.
- **Content Sharing Apps**: Simplify content sharing by parsing and masking URLs within descriptions or captions.## Installation
To use **Parsely** in your Flutter project, add the following dependency to your `pubspec.yaml`:
```yaml
dependencies:
binkap_parsely:
```- **Alternatively, run this command in your terminal:**
#
```bash
flutter pub add binkap_parsely
```## Usage
To use this package, add `binkap_parsely` as a [dependency in your pubspec.yaml file](https://pub.dev/packages/binkap_parsely/).
to `/example` folder.
```dart
import 'package:binkap_parsely/binkap_parsely.dart';Parsely(
text:
'Visit me at https://binkap.com, or you could send me an email at [email protected]. Supposedly you prefer calls? Reach me at +2348068989116 or simply use #binkap on Twitter.',
textAlign: TextAlign.center,
options: ParselyOptions( // Optional configuration
parseMentionTag: true, // Default: true
humanize: true, // Default: true
parsePhone: true, // Default: true
parseHashTag: true, // Default: true
parseEmail: true, // Default: true
parseLink: true, // Default: true
),
mask: ParselyMask( // Optional masking configuration
matches: [
'+2348068989116', // Match specific values for masking
],
masks: [
'My Contact', // Mask text
],
),
style: const TextStyle( // Styling for unmatched text
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold,
fontFamily: 'DancingScript',
),
parsedStyle: const TextStyle( // Styling for matched text
color: Color.fromARGB(255, 33, 243, 86),
fontSize: 20,
fontWeight: FontWeight.bold,
fontFamily: 'DancingScript',
),
onTap: (element) { // Callback for matched element clicks
switch (element.type) {
case ParselyType.link:
print('Clicked link: ${element.parsed}');
break;
case ParselyType.email:
print('Clicked email: ${element.parsed}');
break;
case ParselyType.phone:
print('Clicked phone number: ${element.parsed}');
break;
case ParselyType.hashTag:
print('Clicked hashtag: ${element.parsed}');
break;
case ParselyType.mentionTag:
print('Clicked @mention: ${element.parsed}');
break;
default:
print('Unknown element clicked');
}
},
);
```## Dictionary
## Parameters
### ParselyElement
This class represents the parsed element. It contains two properties:
| Parameter | Type | Description |
|-----------|---------------|-----------------------------------------------------------|
| `type` | `ParselyType` | The type of the parsed entity (link, email, phone, etc.) |
| `parsed` | `String` | The parsed text that was identified (e.g., URL, email, etc.)|### ParselyOptions
Options to control how Parsely parses the text. These are all optional and come with default values.
| Parameter | Type | Description | Default |
|------------------|----------|-------------------------------------------------------|---------|
| `parseMentionTag` | `bool` | Enable parsing of @mentions | `true` |
| `humanize` | `bool` | Whether to humanize the parsed text (e.g., formatting) | `true` |
| `parsePhone` | `bool` | Enable parsing of phone numbers | `true` |
| `parseHashTag` | `bool` | Enable parsing of hashtags | `true` |
| `parseEmail` | `bool` | Enable parsing of email addresses | `true` |
| `parseLink` | `bool` | Enable parsing of URLs | `true` |### ParselyMask
Allows you to define specific masks for parsed entities. The `matches` parameter defines which entities are to be masked, and the `masks` parameter defines the text that will replace the matched text.
| Parameter | Type | Description |
|-----------|-----------------|-----------------------------------------------------------|
| `matches` | `List` | A list of strings that should be masked. |
| `masks` | `List` | A list of masks that replace the matched text. |## Additional Information
- **Performance Optimized**: Parsely has been engineered to handle large blocks of text efficiently, ensuring smooth interactions even with extensive data inputs.
- **Cross-platform Compatibility**: Works seamlessly across all platforms supported by Flutter, including Android, iOS, Web, and Desktop.## Contributions
Feel free to contribute to Parsely! Whether it’s fixing bugs, suggesting improvements, or adding new features, your contributions are welcome. Please refer to the [contributing guide](/CONTRIBUTING.md) for more information.
## License
This package is licensed under the [MIT LICENSE](/LICENSE).