From d20f8612ec1e751b08d1e27c2853581218f4012c Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Sun, 6 Aug 2023 19:48:49 -0400 Subject: [PATCH 1/2] update flutter_markdown excerpts --- packages/flutter_markdown/CHANGELOG.md | 3 ++- packages/flutter_markdown/README.md | 31 ++++++++++++++++-------- packages/flutter_markdown/pubspec.yaml | 2 +- script/configs/temp_exclude_excerpt.yaml | 1 - 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/packages/flutter_markdown/CHANGELOG.md b/packages/flutter_markdown/CHANGELOG.md index 9d9fe0bcec3c..1dd0a35459e5 100644 --- a/packages/flutter_markdown/CHANGELOG.md +++ b/packages/flutter_markdown/CHANGELOG.md @@ -1,6 +1,7 @@ -## NEXT +## 0.6.17+1 * Deletes deprecated splash screen meta-data element. +* Updates README to improve examples of using Markdown. ## 0.6.17 diff --git a/packages/flutter_markdown/README.md b/packages/flutter_markdown/README.md index 36c8f5a29be1..2be646a6a7b2 100644 --- a/packages/flutter_markdown/README.md +++ b/packages/flutter_markdown/README.md @@ -54,12 +54,18 @@ documents, respectively. GitHub Web adds header ID and emoji support. The Using the Markdown widget is simple, just pass in the source markdown as a string: - Markdown(data: markdownSource); + +```dart +const Markdown(data: markdownSource); +``` If you do not want the padding or scrolling behavior, use the MarkdownBody instead: - MarkdownBody(data: markdownSource); + +```dart +const MarkdownBody(data: markdownSource); +``` By default, Markdown uses the formatting from the current material design theme, but it's possible to create your own custom styling. Use the MarkdownStyle class @@ -79,12 +85,13 @@ formatted output of the Markdown widget. For example, in the following Markdown widget constructor, a text string with a smiley face emoji is passed in as the source Markdown data. + ```dart Markdown( - controller: controller, - selectable: true, - data: 'Insert emoji here😀 ', -) + controller: controller, + selectable: true, + data: 'Insert emoji here😀 ', +); ``` The resulting Markdown widget will contain a single line of text with the @@ -100,18 +107,22 @@ auto-links, and strike-through. To include the inline emoji tag syntax while maintaining the default GitHub flavored Markdown behavior, define an extension set that combines EmojiSyntax with ExtensionSet.gitHubFlavored. + ```dart import 'package:markdown/markdown.dart' as md; - -Markdown( +// ··· + Markdown( controller: controller, selectable: true, data: 'Insert emoji :smiley: here', extensionSet: md.ExtensionSet( md.ExtensionSet.gitHubFlavored.blockSyntaxes, - [md.EmojiSyntax(), ...md.ExtensionSet.gitHubFlavored.inlineSyntaxes], + [ + md.EmojiSyntax(), + ...md.ExtensionSet.gitHubFlavored.inlineSyntaxes + ], ), -) + ); ``` ## Image Support diff --git a/packages/flutter_markdown/pubspec.yaml b/packages/flutter_markdown/pubspec.yaml index e7485b032f27..7535e95c3671 100644 --- a/packages/flutter_markdown/pubspec.yaml +++ b/packages/flutter_markdown/pubspec.yaml @@ -4,7 +4,7 @@ description: A Markdown renderer for Flutter. Create rich text output, formatted with simple Markdown tags. repository: https://github.com/flutter/packages/tree/main/packages/flutter_markdown issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+flutter_markdown%22 -version: 0.6.17 +version: 0.6.17+1 environment: sdk: ">=3.0.0 <4.0.0" diff --git a/script/configs/temp_exclude_excerpt.yaml b/script/configs/temp_exclude_excerpt.yaml index 29f303881599..2bea7dcb7ddf 100644 --- a/script/configs/temp_exclude_excerpt.yaml +++ b/script/configs/temp_exclude_excerpt.yaml @@ -10,7 +10,6 @@ - espresso - extension_google_sign_in_as_googleapis_auth - flutter_image -- flutter_markdown - go_router_builder - google_sign_in/google_sign_in - image_picker_for_web From b2efbf26e297b8a3937d7f6d9fdd4c6f2bbc762e Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Sun, 6 Aug 2023 19:52:09 -0400 Subject: [PATCH 2/2] add excerpt file --- .../example/lib/readme_excerpts.dart | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 packages/flutter_markdown/example/lib/readme_excerpts.dart diff --git a/packages/flutter_markdown/example/lib/readme_excerpts.dart b/packages/flutter_markdown/example/lib/readme_excerpts.dart new file mode 100644 index 000000000000..e88a0fae84af --- /dev/null +++ b/packages/flutter_markdown/example/lib/readme_excerpts.dart @@ -0,0 +1,61 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/cupertino.dart'; +import 'package:flutter_markdown/flutter_markdown.dart'; + +// #docregion CreateMarkdownWithEmojiExtension +import 'package:markdown/markdown.dart' as md; +// #enddocregion CreateMarkdownWithEmojiExtension + +/// Create a simple `Markdown` wdget. +void createMarkdown() { + const String markdownSource = ''; + + // #docregion CreateMarkdown + const Markdown(data: markdownSource); + // #enddocregion CreateMarkdown +} + +/// Create a simple `MarkdownBody` widget. +void createMarkdownBody() { + const String markdownSource = ''; + + // #docregion CreateMarkdownBody + const MarkdownBody(data: markdownSource); + // #enddocregion CreateMarkdownBody +} + +/// Create a simple `Markdown` widget with an emoji. +void createMarkdownWithEmoji() { + final ScrollController controller = ScrollController(); + + // #docregion CreateMarkdownWithEmoji + Markdown( + controller: controller, + selectable: true, + data: 'Insert emoji here😀 ', + ); + // #enddocregion CreateMarkdownWithEmoji +} + +/// Create a simple `Markdown` widget with an emoji extension. +void createMarkdownWithEmojiExtension() { + final ScrollController controller = ScrollController(); + + // #docregion CreateMarkdownWithEmojiExtension + Markdown( + controller: controller, + selectable: true, + data: 'Insert emoji :smiley: here', + extensionSet: md.ExtensionSet( + md.ExtensionSet.gitHubFlavored.blockSyntaxes, + [ + md.EmojiSyntax(), + ...md.ExtensionSet.gitHubFlavored.inlineSyntaxes + ], + ), + ); + // #enddocregion CreateMarkdownWithEmojiExtension +}