Skip to content

Commit dc1185c

Browse files
authored
Merge pull request #39 from foresightmobile/feature/increse-pub-score
Feature/increse pub score
2 parents 32e5dd5 + 18b2547 commit dc1185c

File tree

9 files changed

+163
-11
lines changed

9 files changed

+163
-11
lines changed

.pubignore

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,29 @@
1-
example/
1+
# Example build artifacts
2+
example/build/
3+
example/.dart_tool/
4+
example/.idea/
5+
6+
# Android
7+
example/android/.gradle/
8+
example/android/captures/
9+
example/android/gradlew
10+
example/android/gradlew.bat
11+
example/android/local.properties
12+
example/android/key.properties
13+
example/android/**/GeneratedPluginRegistrant.java
14+
15+
# iOS
16+
example/ios/**/DerivedData/
17+
example/ios/**/Pods/
18+
example/ios/**/.symlinks/
19+
example/ios/**/xcuserdata/
20+
example/ios/**/.generated/
21+
example/ios/Flutter/App.framework
22+
example/ios/Flutter/Flutter.framework
23+
example/ios/Flutter/Flutter.podspec
24+
example/ios/Flutter/Generated.xcconfig
25+
example/ios/Flutter/app.flx
26+
example/ios/Flutter/app.zip
27+
example/ios/Flutter/flutter_assets/
28+
example/ios/Flutter/flutter_export_environment.sh
29+
example/ios/Runner/GeneratedPluginRegistrant.*

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## 1.0.7
2+
3+
* Improved pub.dev score by making example app source code available in published package
4+
* Updated `.pubignore` to only exclude build artifacts and generated files instead of entire example directory
5+
* Fixed linter warnings by removing unnecessary null default values in `MarkdownStyleSheet`
6+
* Added `CLAUDE.md` documentation for AI-assisted development
7+
* Enhanced README with package history and link to LaTeX support package
8+
* Standardized formatter configuration across project
9+
110
## 1.0.6
211

312
* Fix cursor behavior when using custom builder for anchor tags. The code now only manages `_linkHandlers` when there is no custom builder for anchor tags, preventing conflicts between the default link recognizer and custom builder widgets.

CLAUDE.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
Flutter Markdown Plus is a Flutter package that renders Markdown text into Flutter widgets. It's built on top of the Dart `markdown` package and supports GitHub Flavored Markdown by default. The package provides both `Markdown` (with scrolling) and `MarkdownBody` widgets, along with extensive customization options for styling, image handling, and interactive elements.
8+
9+
## Development Commands
10+
11+
### Testing
12+
- Run all tests: `flutter test`
13+
- Run tests with coverage: `rm -rf coverage && flutter test`
14+
- Run all tests via test suite: `flutter test test/all.dart`
15+
- Run a single test file: `flutter test test/[test_name].dart`
16+
17+
### Code Quality
18+
- Format code: `dart format . -l 120` or `sh ./scripts/format.sh`
19+
- Format only staged files: `sh ./scripts/format.sh --only-staged`
20+
- Format with exit-on-change: `sh ./scripts/format.sh --set-exit-if-changed`
21+
- Analyze code: `flutter analyze --no-pub .`
22+
- Full validation: `./validate.sh` (runs clean, pub get, format, analyze, and test)
23+
24+
### Package Management
25+
- Get dependencies: `flutter pub get`
26+
- Clean build: `flutter clean`
27+
28+
### Example App
29+
- Run example app: `cd example && flutter run`
30+
- Demos are in `example/lib/demos/` showcasing various features
31+
- Shared widgets in `example/lib/shared/` include reusable demo components and sample custom syntax implementations
32+
33+
## Architecture
34+
35+
### Core Components
36+
37+
**Main Entry Point** (`lib/flutter_markdown_plus.dart`)
38+
- Exports the three main modules: builder, style_sheet, and widget
39+
40+
**Widget Layer** (`lib/src/widget.dart`)
41+
- `Markdown`: Scrollable markdown widget with padding
42+
- `MarkdownBody`: Non-scrollable markdown widget for embedding
43+
- `MarkdownRaw`: Base widget without Material Design theming
44+
- Callback typedefs for link taps, selection changes, and custom builders
45+
46+
**Builder Layer** (`lib/src/builder.dart`)
47+
- `MarkdownBuilder`: Converts markdown AST nodes to Flutter widgets
48+
- Handles all markdown elements: headers, paragraphs, lists, tables, images, etc.
49+
- Manages text styling, link handling, and custom element rendering
50+
- Block vs inline element handling with proper nesting
51+
52+
**Style Layer** (`lib/src/style_sheet.dart`)
53+
- `MarkdownStyleSheet`: Comprehensive theming system
54+
- Integrates with Material Design themes
55+
- Supports custom text styles, colors, decorations, and spacing
56+
57+
### Platform Abstractions
58+
- `_functions_io.dart`: IO platform implementations
59+
- `_functions_web.dart`: Web platform implementations
60+
- Conditional imports handle platform differences
61+
62+
### Extension Points
63+
64+
**Custom Builders**
65+
- `imageBuilder`: Custom image widget rendering
66+
- `checkboxBuilder`: Custom checkbox rendering
67+
- `bulletBuilder`: Custom bullet point rendering
68+
69+
**Syntax Extensions**
70+
- Supports markdown package's extension system
71+
- Default: GitHub Flavored Markdown
72+
- Can add emoji syntax, custom inline/block syntaxes
73+
74+
**Selection & Interaction**
75+
- Configurable text selection behavior
76+
- Link tap handling with custom callbacks
77+
- Integration with Flutter's SelectionArea
78+
79+
## Key Features
80+
81+
- **Markdown Parsing**: Built on `markdown` package AST
82+
- **Rich Styling**: Material Design integration with custom overrides
83+
- **Image Support**: Network, local, and asset images with `resource:` prefix
84+
- **Table Rendering**: Full table support with custom styling
85+
- **Interactive Elements**: Checkboxes, links with tap handlers
86+
- **Text Selection**: Configurable selection with callbacks
87+
- **Extensibility**: Plugin system for custom syntax and rendering
88+
89+
## Testing Strategy
90+
91+
Tests are comprehensive and organized by feature:
92+
- Individual element tests (headers, lists, images, etc.)
93+
- Style sheet testing
94+
- Selection and interaction testing
95+
- Platform compatibility testing
96+
- Mock-based image testing
97+
98+
The `test/all.dart` file runs the complete test suite.
99+
100+
## Code Style
101+
102+
- Line length: 120 characters (configured in `pubspec.yaml`)
103+
- Follows Flutter/Dart team's analysis_options.yaml with minor modifications
104+
- Public API documentation required (`public_member_api_docs`)
105+
- Strict type checking enabled
106+
- Uses `prefer_single_quotes` and other Flutter conventions

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# Flutter Markdown
22
[![pub package](https://img.shields.io/pub/v/flutter_markdown_plus.svg)](https://pub.dartlang.org/packages/flutter_markdown_plus)
33

4+
## About This Package
5+
6+
`flutter_markdown_plus` is the continuation of the original [`flutter_markdown`](https://pub.dev/packages/flutter_markdown) package that was developed and maintained by Google. As the original package has been discontinued, Foresight Mobile has taken over maintenance of this project to ensure continued support and development for the Flutter community.
7+
8+
For historical context, see the [original flutter_markdown package](https://pub.dev/packages/flutter_markdown).
9+
10+
**LaTeX Support:** For LaTeX rendering support, check out the [`flutter_markdown_plus_latex`](https://pub.dev/packages/flutter_markdown_plus_latex) package.
11+
412
A markdown renderer for Flutter. It supports the
513
[original format](https://daringfireball.net/projects/markdown/), but no inline
614
HTML.
@@ -164,3 +172,7 @@ Here are some additional Markdown syntax resources:
164172
- [CommonMark Markdown Reference](https://commonmark.org/help/)
165173
- [GitHub Guides - Mastering Markdown](https://guides.github.com/features/mastering-markdown/#GitHub-flavored-markdown)
166174
- [Download PDF cheatsheet version](https://guides.github.com/pdfs/markdown-cheatsheet-online.pdf)
175+
176+
## Maintainers
177+
178+
This package is proudly maintained by [Gareth Reese](https://github.com/gazreese) and [Marko Radisavljevic](https://github.com/Prototypev1) for [Foresight Mobile](https://foresightmobile.com/) ([GitHub](https://github.com/foresightmobile/))

analysis_options.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ analyzer:
2020
# Ignore generated files
2121
- '**/*.g.dart'
2222
- '**/*.mocks.dart' # Mockito @GenerateMocks
23+
24+
formatter:
25+
page_width: 120
2326

2427
linter:
2528
rules:

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ packages:
6868
path: ".."
6969
relative: true
7070
source: path
71-
version: "1.0.6"
71+
version: "1.0.7"
7272
flutter_test:
7373
dependency: "direct dev"
7474
description: flutter

lib/src/style_sheet.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,6 @@ class MarkdownStyleSheet {
143143
tableColumnWidth: const FlexColumnWidth(),
144144
tableCellsPadding: const EdgeInsets.fromLTRB(16, 8, 16, 8),
145145
tableCellsDecoration: const BoxDecoration(),
146-
tableHeadCellsPadding: null,
147-
tableHeadCellsDecoration: null,
148146
blockquotePadding: const EdgeInsets.all(8.0),
149147
blockquoteDecoration: BoxDecoration(
150148
color: Colors.blue.shade100,
@@ -320,8 +318,6 @@ class MarkdownStyleSheet {
320318
tableColumnWidth: const FlexColumnWidth(),
321319
tableCellsPadding: const EdgeInsets.fromLTRB(16, 8, 16, 8),
322320
tableCellsDecoration: const BoxDecoration(),
323-
tableHeadCellsPadding: null,
324-
tableHeadCellsDecoration: null,
325321
blockquotePadding: const EdgeInsets.all(8.0),
326322
blockquoteDecoration: BoxDecoration(
327323
color: Colors.blue.shade100,

pubspec.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: A Markdown renderer for Flutter. Create rich text output,
44
formatted with simple Markdown tags.
55
repository: https://github.com/foresightmobile/flutter_markdown_plus
66
issue_tracker: https://github.com/foresightmobile/flutter_markdown_plus/issues
7-
version: 1.0.6
7+
version: 1.0.7
88

99
environment:
1010
sdk: ^3.4.0
@@ -28,5 +28,5 @@ topics:
2828
- markdown
2929
- widgets
3030

31-
dartfmt:
32-
line_length: 120
31+
formatter:
32+
page_width: 120

test/table_test.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,6 @@ void defineTests() {
606606
const EdgeInsets cellPadding = EdgeInsets.all(12);
607607
final MarkdownStyleSheet style = MarkdownStyleSheet.fromTheme(theme).copyWith(
608608
tableCellsPadding: cellPadding,
609-
tableHeadCellsPadding: null,
610609
);
611610

612611
await tester.pumpWidget(boilerplate(MarkdownBody(data: data, styleSheet: style)));
@@ -657,7 +656,6 @@ void defineTests() {
657656
color: Colors.grey.shade100,
658657
);
659658
final MarkdownStyleSheet style = MarkdownStyleSheet.fromTheme(theme).copyWith(
660-
tableHeadCellsDecoration: null,
661659
tableCellsDecoration: bodyDecoration,
662660
);
663661

0 commit comments

Comments
 (0)