Coder Social home page Coder Social logo

asjqkkkk / markdown_widget Goto Github PK

View Code? Open in Web Editor NEW
311.0 8.0 87.0 59.91 MB

📖Rendering markdown by flutter!Welcome for pr and issue.

License: MIT License

Dart 73.58% Kotlin 0.06% Swift 0.82% Objective-C 0.02% HTML 2.38% CMake 10.08% C++ 11.81% C 1.01% Shell 0.24%
markdown flutter flutterweb video html dart

markdown_widget's Introduction

Language:简体中文 | English

screen

📖markdown_widget

Coverage Status pub package demo

A simple and easy-to-use markdown rendering component.

  • Supports TOC (Table of Contents) function for quick location through Headings
  • Supports code highlighting
  • Supports all platforms

🚀Usage

Before starting, you can try out the online demo by clicking demo

import 'package:flutter/material.dart';
import 'package:markdown_widget/markdown_widget.dart';

class MarkdownPage extends StatelessWidget {
  final String data;

  MarkdownPage(this.data);

  @override
  Widget build(BuildContext context) => Scaffold(body: buildMarkdown());

  Widget buildMarkdown() => MarkdownWidget(data: data);
}

If you want to use your own Column or other list widget, you can use MarkdownGenerator

  Widget buildMarkdown() =>
      Column(children: MarkdownGenerator().buildWidgets(data));

Or use MarkdownBlock

  Widget buildMarkdown() =>
      SingleChildScrollView(child: MarkdownBlock(data: data));

🌠Night mode

markdown_widget supports night mode by default. Simply use a different MarkdownConfig to enable it.

  Widget buildMarkdown(BuildContext context) {
    final isDark = Theme.of(context).brightness == Brightness.dark;
    final config = isDark
        ? MarkdownConfig.darkConfig
        : MarkdownConfig.defaultConfig;
    final codeWrapper = (child, text, language) =>
        CodeWrapperWidget(child, text, language);
    return MarkdownWidget(
        data: data,
        config: config.copy(configs: [
        isDark
        ? PreConfig.darkConfig.copy(wrapper: codeWrapper)
        : PreConfig().copy(wrapper: codeWrapper)
    ]));
  }
Default mode Night mode

🔗Link

You can customize the style and click events of links, like this

  Widget buildMarkdown() => MarkdownWidget(
      data: data,
      config: MarkdownConfig(configs: [
        LinkConfig(
          style: TextStyle(
            color: Colors.red,
            decoration: TextDecoration.underline,
          ),
          onTap: (url) {
            ///TODO:on tap
          },
        )
      ]));

📜TOC (Table of Contents) feature

Using the TOC is very simple

  final tocController = TocController();

  Widget buildTocWidget() => TocWidget(controller: tocController);

  Widget buildMarkdown() => MarkdownWidget(data: data, tocController: tocController);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: Row(
          children: <Widget>[
            Expanded(child: buildTocWidget()),
            Expanded(child: buildMarkdown(), flex: 3)
          ],
        ));
  }

🎈Highlighting code

Highlighting code supports multiple themes.

import 'package:flutter_highlight/themes/a11y-light.dart';

  Widget buildMarkdown() => MarkdownWidget(
      data: data,
      config: MarkdownConfig(configs: [
        PreConfig(theme: a11yLightTheme),
      ]));

🧬Select All and Copy

Cross-platform support for Select All and Copy function.

image

🌐Html tag

As the current package only implements the conversion of Markdown tags, it does not support the conversion of HTML tags by default. However, this functionality can be supported through extension. You can refer to the usage in html_support.dart for more details.

Here is the online HTML demo showcase

🧮Latex support

The example also includes simple support for LaTeX, which can be implemented by referring to the implementation in latex.dart

Here is the online latex demo showcase

🍑Custom tag implementation

By passing a SpanNodeGeneratorWithTag to MarkdownGeneratorConfig, you can add new tags and the corresponding SpanNodes for those tags. You can also use existing tags to override the corresponding SpanNodes.

You can also customize the parsing rules for Markdown strings using InlineSyntax and BlockSyntax, and generate new tags.

You can refer to this issue to learn how to implement a custom tag.

If you have any good ideas or suggestions, or have any issues using this package, please feel free to open a pull request or issue.

🧾Appendix

Here are the other libraries used in markdown_widget

Packages Descriptions
markdown Parsing markdown data
flutter_highlight Code highlighting
highlight Code highlighting
url_launcher Opening links
visibility_detector Listening for visibility of a widget;
scroll_to_index Enabling ListView to jump to an index.

markdown_widget's People

Contributors

adnanalshami avatar asjqkkkk avatar boyan01 avatar jorangetree avatar liudonghua123 avatar lx200916 avatar maksimka101 avatar perongh avatar techno-disaster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

markdown_widget's Issues

MarkdownWidget not working with json

Describe the bug
It seems to be returning null

To Reproduce
Steps to reproduce the behavior:

MarkdownWidget(
    shrinkWrap: true,
    data: dataJson.toString(),
    styleConfig: StyleConfig(
         preConfig: PreConfig(
             language: 'json',
             theme: theme.a11yLightTheme
         )
     ),
),
Future<dynamic> loadData(String path) async {
    String data = await DefaultAssetBundle.of(context).loadString(path);
    final jsonResult = json.decode(data);
    print(jsonResult);
    return jsonResult;
  }
  1. loadData returns the json to a string format

Expected behavior
To have the code inside a container like this:

Annotation 2020-08-30 151610

but get this:

Annotation 2020-08-30 151635

Environment(please complete the following information):

    • Flutter version 1.21.0-9.2.pre at C:\Users\Mike\flutter
    • Framework revision 81a45ec2e5 (3 days ago), 2020-08-27 14:14:33 -0700
    • Engine revision 20a9531835
    • Dart version 2.10.0 (build 2.10.0-7.3.beta)

 
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at C:\Users\Mike\AppData\Local\Android\sdk
    • Platform android-29, build-tools 29.0.2
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 3.5)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 42.1.1
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)

[√] VS Code (version 1.48.2)
    • VS Code at C:\Users\Mike\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.13.2

[√] Connected device (3 available)
    • Web Server (web) • web-server • web-javascript • Flutter Tools
    • Chrome (web)     • chrome     • web-javascript • Google Chrome 84.0.4147.135
    • Edge (web)       • edge       • web-javascript • Microsoft Edge 84.0.522.59```

**Platform**
Web

I am not sure if json is supported but just wanted to share my problem.

Slow and Lagging scrolling when used with ListView(MarkdownGenerator...)

I have a large text that works very well and fast with MarkdownWidget, but when I put it in MarkdownGenerator it starts lagging.
From:
MarkdownWidget(data: data);
To:
ListView(children: MarkdownGenerator(data: data).widgets);
So i need it for scrollable controller which is available only in ListView

把例子copy到项目里,报错

E/flutter ( 9129): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: Invalid argument(s): Illegal argument in isolate message : (object is a closure - Function 'buildMarkdownGenerator':.)
E/flutter ( 9129): #0 Isolate._spawnFunction (dart:isolate-patch/isolate_patch.dart:551:55)
E/flutter ( 9129): #1 Isolate.spawn (dart:isolate-patch/isolate_patch.dart:391:7)
E/flutter ( 9129): #2 compute (package:flutter/src/foundation/_isolates_io.dart:23:41)
E/flutter ( 9129): #3 _MarkdownWidgetState.initialState (package:markdown_widget/markdown_widget.dart:70:12)
E/flutter ( 9129): #4 _MarkdownWidgetState.initState (package:markdown_widget/markdown_widget.dart:56:5)
E/flutter ( 9129): #5 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4355:58)
E/flutter ( 9129): #6 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
E/flutter ( 9129): #7 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter ( 9129): #8 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter ( 9129): #9 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
E/flutter ( 9129): #10 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter ( 9129): #11 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter ( 9129): #12 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
E/flutter ( 9129): #13 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
E/flutter ( 9129): #14 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5)
E/flutter ( 9129): #15 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
E/flutter ( 9129): #16 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter ( 9129): #17 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter ( 9129): #18 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
E/flutter ( 9129): #19 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
E/flutter ( 9129): #20 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5)
E/flutter ( 9129): #21 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
E/flutter ( 9129): #22 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter ( 9129): #23 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter ( 9129): #24 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
E/flutter ( 9129): #25 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
E/flutter ( 9129): #26 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5)
E/flutter ( 9129): #27 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
E/flutter ( 9129): #28 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter ( 9129): #29 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter ( 9129): #30 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
E/flutter ( 9129): #31 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
E/flutter ( 9129): #32 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5)
E/flutter ( 9129): #33 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
E/flutter ( 9129): #34 ParentDataElement.mount (package:flutter/src/widgets/framework.dart:4617:11)
E/flutter ( 9129): #35 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter ( 9129): #36 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5551:32)
E/flutter ( 9129): #37 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter ( 9129): #38 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter ( 9129): #39 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
E/flutter ( 9129): #40 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
E/flutter ( 9129): #41 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5)
E/flutter ( 9129): #42 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4381:11)
E/flutter ( 9129): #43 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
E/flutter ( 9129): #44 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter ( 9129): #45 Element.updateChild (package:flutter/src/widgets/framework.dart:

Incorrect rendering in tables

Describe the bug
Look at this code:
image
What it looks like in GitHub the Markdown rendering:
image
And widget rendering:
image

So bug here:
image
The gap between '||' and 'b' has disappeared.

Platform
Does the problem appear on the Web or on the Mobile
I saw it on a web platform.

Sometimes the render doesn't work

Describe the bug
I don't know why, but sometimes it happens with the same data.

I am using this code:

SliverList(
                    delegate: SliverChildListDelegate(MarkdownGenerator(
                      data: snapshot.data,
                      childMargin:
                          EdgeInsets.symmetric(horizontal: 10.0, vertical: 5.0),
                    ).widgets),
                  ),

And this source data
https://app.coder-side.ru/assets/books/coder_book/php/base/50.md

Screenshots
If applicable, add screenshots to help explain your problem.
Screenshot_20200610-220622

Environment(please complete the following information):
Screenshot (11)

Platform
Does the problem appear on the Web or on the Mobile
This is mobile.
When I used the online demo everything was fine.

Additional context
This is rare, but it happens. And the source with which this happens is always the same. It doesn't happen that a file works and then it doesn't.

TocController get current position(pixels)

Is your feature request related to a problem? Please describe.
Yes. TocController supports the scrollTo and jumpTo methods. But it doesn't allow you to get the pixel value to use.

Describe the solution you'd like

 @override
  void initState() {
    _tocController = new TocController(
      initialScrollOffset:
          _position != widget.position ? 0.0 : widget.scrollPosition
    )..addListener(() {
        _scrollPosition = _tocController.position.pixels.roundToDouble();
      });
    super.initState();
  }

Persisting Checkbox State

I am creating a notes app and I want to persist the checkbox state.
Is is possible to modify the actual string to incorporate these changes.

LaTex Support

It would be cool if we could render LaTex expressions, I tried but didn't figure out how to make it using CustomWidget and flutter_svg

TOC text is clipped

Describe the bug
TOC text is clipped

To Reproduce
Steps to reproduce the behavior:

Expected behavior
Not be clipped

Screenshots
Screenshot 2020-11-05 at 15 19 51

Desktop - toc test is ok. But the Responsive Design thinks its mobile :) Different issue.
Screenshot 2020-11-05 at 15 28 58

Environment(please complete the following information):

flutter channel dev

Platform
Does the problem appear on the Web or on the Mobile
Web has the bug.
Mobile and Desktop does not.

Additional context
Add any other context about the problem here.

pConfig rendering error after changed TextStyle

Describe the bug
I used this:

pConfig: PConfig(
                                    textStyle: TextStyle(fontFamily: 'Verdana'),
                                    selectable: false,
                                    linkGesture: (linkChild, url) =>
                                        GestureDetector(
                                          child: linkChild,
                                          onTap: () => _launchURL(url),
                                        )),

Where did the white text come from?
Screenshot_20200610-174001

Full code of my Widget:

 SliverList(
                    delegate: SliverChildListDelegate(MarkdownGenerator(
                            data: snapshot.data,
                            childMargin: EdgeInsets.symmetric(
                                horizontal: 10.0, vertical: 5.0),
                            styleConfig: StyleConfig(
                                imgBuilder: (String url, attributes) {
                                  return Image.file(
                                      File('$_localPath/${widget.sName}/$url'));
                                },
                                markdownTheme: (Theme.of(context).brightness ==
                                        Brightness.dark)
                                    ? MarkdownTheme.darkTheme
                                    : MarkdownTheme.lightTheme,
                                pConfig: PConfig(
                                    textStyle: TextStyle(fontFamily: 'Verdana'),
                                    selectable: false,
                                    linkGesture: (linkChild, url) =>
                                        GestureDetector(
                                          child: linkChild,
                                          onTap: () => _launchURL(url),
                                        )),
                                tableConfig: TableConfig(
                                  wrapBuilder: (table) => SingleChildScrollView(
                                    scrollDirection: Axis.vertical,
                                    child: table,
                                  ),
                                  bodyChildWrapper: (child) => Padding(
                                    padding: EdgeInsets.all(8.0),
                                    child: child,
                                  ),
                                  headChildWrapper: (child) => Padding(
                                    padding: EdgeInsets.all(8.0),
                                    child: child,
                                  ),
                                  headerStyle:
                                      TextStyle(fontWeight: FontWeight.bold),
                                ),
                                olConfig: OlConfig(
                                    indexWidget: (int deep, int index) =>
                                        Text('${index + 1}.')),
                                preConfig: PreConfig(
                                    preWrapper: (preWidget, text) {
                                      return Stack(
                                        children: <Widget>[
                                          preWidget,
                                          Align(
                                            alignment: Alignment.topRight,
                                            child: IconButton(
                                                icon: Icon(Icons.content_copy),
                                                onPressed: () {
                                                  Clipboard.setData(
                                                      new ClipboardData(
                                                          text: text));
                                                  Scaffold.of(context)
                                                      .showSnackBar(SnackBar(
                                                          content: Text(
                                                              'Код скопирован')));
                                                }),
                                          )
                                        ],
                                      );
                                    },
                                    theme: (Theme.of(context).brightness ==
                                            Brightness.dark)
                                        ? theme.vs2015Theme
                                        : theme.doccoTheme)))
                        .widgets),
                  ),

Platform
Does the problem appear on the Web or on the Mobile
-Mobile

Add the ability to pass EdgeInset.zero to the inner ListViev.builder

    return widget.controller == null
        ? ListView.builder(
            padding: EdgeInsets.zero      <<<<<< HERE
            shrinkWrap: widget.shrinkWrap,
            physics: widget.physics,
            itemBuilder: (ctx, index) => widgets[index],
            itemCount: widgets.length,
          )
        : ScrollablePositionedList.builder(
            physics: widget.physics,
            itemCount: widgets.length,
            itemBuilder: (context, index) => widgets[index],
            itemScrollController: widget.controller.scrollController,
            itemPositionsListener: itemPositionsListener,
            initialScrollIndex: getInitialScrollIndex(),
          );
  }```

Null Safety Support

Is your feature request related to a problem? Please describe.
Flutter 2 is here with full support/movement to Null Saftey. It would be great for this to be supported.

Items for long lists are not aligned.

Describe the bug
List comprised of more than 9 items are not aligned. The text for items from 10 and beyond is shifted. It would be better if all text have the same margins or an option to define it.
Problem should repeat for longer lists when the number of characters changes (100, 1000,...)

To Reproduce
Steps to reproduce the behavior:
Create any numbered list with more than 10 items.

Expected behavior
Text of all elements in list are aligned.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment(please complete the following information):
Flutter (Channel beta, v1.17.0, on Mac OS X 10.14.6 18G4032, locale en-PT)
• Flutter version 1.17.0 at /usr/local/Caskroom/flutter/latest/flutter
• Framework revision e6b34c2b5c (8 days ago), 2020-05-02 11:39:18 -0700
• Engine revision 540786dd51
• Dart version 2.8.1

Text alignment control

Is your feature request related to a problem? Please describe.
The text rendered is aligned to left only.

Describe the solution you'd like
It would be nice if we could justify, centralize and align it to right.

Describe alternatives you've considered
unfortunately there is no alternative right now.

Add onLinkLongPress option to PConfig

Within PConfig, in addition to onLinkTap would it possible to add an onLinkLongPress option?

My specific use case would be to have an option to share the link without opening it.

[Feature request] Editor mode?

Is your feature request related to a problem? Please describe.
I want to use a markdown editor, but most of them I found is based on webview. It's slow and heavy.

Describe the solution you'd like
Provide readonly or editable attributes for configuration.

use proper github action for deploy to github pages

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

The current github action does not support all forms of auth and secrets
It also does not support branches.

Describe the solution you'd like
A clear and concise description of what you want to happen.

this github action supports the authentication aspects plus many other things needed. Its used heavily.
https://github.com/peaceiris/actions-gh-pages

here is the specific yaml for flutter web: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-flutter-web

here is a blog about using it for flutter projects: https://poetryincode.dev/multi-environment-flutter-deployments-using-github-pages

Describe alternatives you've considered

The one i linked to is really well used.

Additional context
Add any other context or screenshots about the feature request here.

Monospace font missing from output

Describe the bug
Code blocks and inline pre blocks are not presented with a monospace font.

To Reproduce
Steps to reproduce the behavior:

  1. Run online demo

Expected behavior
Code example should be color highlighted using a monospace font.
Inline blocks should be using a monospace font.

Environment(please complete the following information):
Using Chrome with web example
Also, tried building Flutter App for iOS 14 with same results.

Platform
Chrome, iOS

Allow to define the starting index of a numbered list

Is your feature request related to a problem? Please describe.
Currently a numbered list starts with 0 and I cannot figure out a way to change it.

Describe the solution you'd like
I would like it to start with 1. However imagine a list with a text in between and the the continuation of the list, perhaps one want to start the list with a different index. It would be nice to be able to control the starting index.

Describe alternatives you've considered
Only hardcoding and the list.

List incorrect rendering - the distance between the elements

Describe the bug
I use this data:

1. **App Name** - This is the name of the app.
2. **Organization identifier** - This is the unique name used together with the app name to uniquely identify your app on the Google Play Store.
3. **Target platforms** - This is the platforms on which the app can run, its always advisable to choose the version of the Android that can support at least 90% of the devices in the wild. 
4. **Theme** - The default theme that will be applied to the entire app. This can be changed and configured later.

And this code:

MarkdownWidget(
                loadingWidget: LinearProgressIndicator(),
                data: snapshot.data,
                controller: _tocController,
                childMargin: EdgeInsets.all(10.0),
                styleConfig: StyleConfig(
                  imgBuilder: (String url, attributes) {
                    return Image.asset('books/${widget.sName}/$url');
                  },
                  markdownTheme:
                      (Theme.of(context).brightness == Brightness.dark)
                          ? MarkdownTheme.darkTheme
                          : MarkdownTheme.lightTheme,
                  pConfig: PConfig(
                    selectable: true,
                    linkGesture: (linkChild, url) {
                      return GestureDetector(
                        child: linkChild,
                        onTap: () => _launchURL(url),
                      );
                    },
                  ),
                  preConfig: PreConfig(
                      theme: (Theme.of(context).brightness == Brightness.dark)
                          ? theme.vs2015Theme
                          : theme.doccoTheme,
                      preWrapper: (preWidget, text) {
                        return Stack(
                          children: <Widget>[
                            preWidget,
                            Align(
                              alignment: Alignment.topRight,
                              child: IconButton(
                                  icon: Icon(Icons.content_copy),
                                  onPressed: () {
                                    Clipboard.setData(
                                        new ClipboardData(text: text));
                                    Scaffold.of(context).showSnackBar(SnackBar(
                                        content: Text('Код скопирован')));
                                  }),
                            )
                          ],
                        );
                      }),
                ),
              );

Look at this picture:
Screenshot (8)

The distance between elements is not expanded by default.

Add custom tag support?

I find this lib missing custom tag support, for example, I would like to add <avatar size="12" name="tom" /> and then render a customized avatar.

For supporting custom tag, we can do a lot of things.

TextStyle influence other parts of the page.

I write some code like this

          /// introduce
          Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: MarkdownGenerator(
              data: description,
              styleConfig: StyleConfig(
                markdownTheme: MarkdownTheme.darkTheme,
                pConfig: PConfig(
                  selectable: false,
                  textStyle: TextStyle(color: Colors.white70, fontSize: 16),
                ),
                titleConfig: TitleConfig(
                  commonStyle: TextStyle(
                    color: Colors.white,
                    fontSize: 18,
                    fontWeight: FontWeight.normal,
                  ),
                  showDivider: false,
                ),
              ),
            ).widgets,
          ),

          /// related course
          Container(alignment: Alignment.centerLeft, child: Text('开设课程')),
          SizedBox(height: commonMargin),

Then the page is all of troubled style.

I use the latest 1.1.3 version, and the other page is ok.

image

image

Table contains irregular row lengths

Caught by this md file:
12.markdown.txt

Log:

Launching lib\main.dart on SM A605FN in debug mode...
√ Built build\app\outputs\apk\debug\app-debug.apk.
D/FlutterActivity(13380): Using the launch theme as normal theme.
D/FlutterActivityAndFragmentDelegate(13380): Setting up FlutterEngine.
D/FlutterActivityAndFragmentDelegate(13380): No preferred FlutterEngine was provided. Creating a new FlutterEngine for this FlutterFragment.

�[38;5;248m════════ Exception caught by widgets library ═══════════════════════════════════�[39;49m
�[38;5;244mThe following assertion was thrown building FutureBuilder<String>(dirty, dependencies: [_InheritedTheme, _LocalizationsScope-[GlobalKey#b3b0e]], state: _FutureBuilderState<String>#faa7d):�[39;49m
Table contains irregular row lengths.

�[38;5;244mEvery TableRow in a Table must have the same number of children, so that every cell is filled. Otherwise, the table will contain holes.�[39;49m
�[38;5;244mThe relevant error-causing widget was�[39;49m
    �[38;5;248mFutureBuilder<String>�[39;49m
�[38;5;244mWhen the exception was thrown, this was the stack�[39;49m
�[38;5;244m#0      new Table.<anonymous closure>�[39;49m
�[38;5;244m#1      new Table�[39;49m
�[38;5;248m#2      MTable.getTableWidget�[39;49m
�[38;5;248m#3      MarkdownHelper.getTableWidget�[39;49m
�[38;5;248m#4      MarkdownGenerator._generatorWidget�[39;49m
�[38;5;244m...�[39;49m
�[38;5;248m════════════════════════════════════════════════════════════════════════════════�[39;49m
I/flutter (13380): cpp

�[38;5;248m════════ Exception caught by widgets library ═══════════════════════════════════�[39;49m
Table contains irregular row lengths.
�[38;5;244mThe relevant error-causing widget was�[39;49m
    �[38;5;248mFutureBuilder<String>�[39;49m
�[38;5;248m════════════════════════════════════════════════════════════════════════════════�[39;49m

Full log :
log.txt

My code:

MarkdownGenerator(
                            data: snapshot.data,
                            childMargin: EdgeInsets.only(left: 10, right: 10, top: 5, bottom: 5),
                            styleConfig: StyleConfig(
                               markdownTheme: (Theme.of(context).brightness == Brightness.dark) ? MarkdownTheme.darkTheme : MarkdownTheme.lightTheme,
                                preConfig: PreConfig(
                                    language: widget.sName,
                                    theme: (Theme.of(context).brightness == Brightness.dark) ? theme.vs2015Theme : theme.doccoTheme)))
                        .widgets

Markdown 3.0.0

Describe the bug
Incompatible with Markdown 3.0.0. Can't be used if flutter_markdown 0.5.0 is used as well.

Because markdown_widget >=1.2.4 depends on markdown ^2.1.8 and flutter_markdown 0.5.0 depends on markdown ^3.0.0, markdown_widget >=1.2.4 is incompatible with flutter_markdown 0.5.0.

And because no versions of flutter_markdown match >0.5.0 <0.6.0, markdown_widget >=1.2.4 is incompatible with flutter_markdown ^0.5.0.

on Desktop does not render images or video due to no network connectivity. Easy to fix by adding these to mac and ios plist for debug and release

Describe the bug
A clear and concise description of what the bug is.

On Desktop the images and video wont render because the rights are not enabled.

Expected behavior

Renders images and video.

This fix

You need to add:

<key>com.apple.security.network.client</key>
<true/>

to
macos/Runner/DebugProfile.entitlements
and
macos/Runner/Release.entitlements

Its documented here: https://flutter.dev/desktop#entitlements-and-the-app-sandbox

Screenshots

Screenshot 2021-04-19 at 11 25 43

Environment(please complete the following information):
Please use flutter doctor -v to show your flutter enviroment

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, 2.2.0-10.1.pre, on macOS 11.2.3 20D91 darwin-x64, locale en-DE)
[✗] Android toolchain - develop for Android devices
✗ Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.dev/docs/get-started/install/macos#android-setup for
detailed instructions).
If the Android SDK has been installed to a custom location, please use
flutter config --android-sdk to update to that location.

[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[!] Android Studio (not installed)
[✓] VS Code (version 1.55.2)
[✓] Connected device (2 available)

Platform
desktop mac.

Environment
mac

Documentation

It would be cool to see documentation on all the features of this plugin.

Selectable text not working

When I dig into the code, it seems like the text is set to be selectable by default, however, the generated code is just RichText widget and not a SelectableText.rich widget.

Can we get proper support for selectable text, and as a bonus, if we can pass in toolbarOptions that would be even better.

List incorrect rendering - count

Describe the bug
I use this data:

1. **App Name** - This is the name of the app.
2. **Organization identifier** - This is the unique name used together with the app name to uniquely identify your app on the Google Play Store.
3. **Target platforms** - This is the platforms on which the app can run, its always advisable to choose the version of the Android that can support at least 90% of the devices in the wild. 
4. **Theme** - The default theme that will be applied to the entire app. This can be changed and configured later.

What should it look like:
image
Widget:
image
The error is that the invoice starts from zero.

off-line ability to show images

Great package, I am using it for Markdown text held in firebase storage and then downloaded locally to a Hive database, and it is working just fine.
The Markdown has both text and images (i.e. a http address). What happens when the app has no internet connection - will the images still be shown?
Or should I loop through the Markdown text, find the links download as files and change the link in the markdown entry?

Really hoping this has already been done!

Improving table rendering

  1. If the table is wide add horizontal scrolling support.
    Screenshot_20200514-221350_GitHub
    Screenshot_20200514-221356_GitHub
    this.supportVerticalScrolling = true;
  2. Bold text in titles if it needed.
    image
  3. Column compression.
    image
    How it should be
    image

The getter 'selectable' was called on null.

I use some code like this

  @override
  Widget build(BuildContext context) {
    String data =
        '[Welcome for pull request](https://github.com/asjqkkkk/markdown_widget)😄\n\n';
    return Column(
      children: [
        ...MarkdownGenerator(
          data: data,
          // styleConfig: StyleConfig(
          //   ulConfig: UlConfig(
          //     dotWidget: (int deep, int index) => Icon(Icons.android),
          //   ),
          // ),
        ).widgets,
        constructTag('标签', ['吉他', '弹指', '唱奏', '大师'])
      ],
    );
  }

Then I got the following error

image

Syntax Highlighter add a parameter for all languages

Is your feature request related to a problem? Please describe.
Yes. I need to change the config for each language.

Describe the solution you'd like

 Widget buildMarkdown() => MarkdownWidget(
        data: data,
        styleConfig: StyleConfig(
          preConfig: PreConfig(
            language: 'all', //here
            theme: theme.a11yLightTheme
          )
        ),
      );

Additional context
You can reduce the support for highlighted words, but the main thing is that it affects most languages.

Add custom tag support?

I find this lib missing custom tag support, for example, I would like to add <avatar size="12" name="tom" /> and then render a customized avatar.

For supporting custom tag, we can do a lot of things.

Video cant be stopped

Describe the bug
The video cant be stopped when you click on it. Even though the pause icon appears on hover.

To Reproduce
Steps to reproduce the behavior:

Expected behavior
Should pause or stop.

Screenshots

Environment(please complete the following information):
flutter channel dev.

Platform
Does the problem appear on the Web or on the Mobile
Web

Additional context
Add any other context about the problem here.

Wrapped widget not resizing correctly when increasing textstyle fontSize.

Describe the bug
When using the example 'hightlight code' given in the ReadMe, increasing the fontSize property through the textStyle argument of preConfig cause the code being clipped after several lines.

To Reproduce
Steps to reproduce the behavior:

  1. Start form the example 'hightlight code'
  2. Set testStyleProperty as TextStyle(fontSize: 18)
  3. Write about ten lines of code
  4. Notice the outputed code in the widget is getting clipped at the bottom

Expected behavior
The outputed code should not be clipped

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.