Giter Site home page Giter Site logo

jckodel / markdown_viewer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tagnote-app/markdown_viewer

0.0 0.0 0.0 2.72 MB

A Markdown viewer widget for Flutter. It renders Markdown string to rich text output.

License: BSD 3-Clause "New" or "Revised" License

Shell 0.08% C++ 15.74% C 1.07% Objective-C 0.03% Kotlin 0.11% Dart 67.05% Swift 0.87% HTML 1.39% CMake 13.67%

markdown_viewer's Introduction

Flutter CI

Markdown Viewer

A Markdown viewer widget for Flutter. It renders Markdown string to rich text output.

example

Check the source code of this screenshot here

Usage

MarkdownViewer(
  'Hello **Markdown**!',
  enableTaskList: true,
  enableSuperscript: false,
  enableSubscript: false,
  enableFootnote: false,
  enableImageSize: false,
  enableKbd: false,
  syntaxExtensions: const [],
  elementBuilders: const [],
);

How to create a syntax extension

class ExampleSyntax extends MdInlineSyntax {
  ExampleSyntax() : super(RegExp(r'#[^#]+?(?=\s+|$)'));

  @override
  MdInlineObject? parse(MdInlineParser parser, Match match) {
    final markers = [parser.consume()];
    final content = parser.consumeBy(match[0]!.length - 1);

    return MdInlineElement(
      'example',
      markers: markers,
      children: content.map((e) => MdText.fromSpan(e)).toList(),
    );
  }
}

How to create a element builder

class ExampleBuilder extends MarkdownElementBuilder {
  ExampleBuilder()
      : super(
          textStyle: const TextStyle(
            color: Colors.green,
            decoration: TextDecoration.underline,
          ),
        );

  @override
  bool isBlock(element) => false;

  @override
  List<String> matchTypes = <String>['example'];
}

markdown_viewer's People

Contributors

chenzhiguang avatar jckodel avatar

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.