Autokaka / refined_markdown

A simple Markdown renderer that is written mostly in dart (grammar analysing and rendering part). Simple, quiet, fast, that is all refined markdown is intended to be.

Home Page:https://pub.dev/packages/refined_markdown

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Doesn't work as expected when text is from a dynamic source and not hardcoded string

edocabhi opened this issue · comments

commented

Sorry, I don't know what you mean. Do you mean that after changing the content of the "text" param in RefinedMarkdown widget, the widget won't change its state and reload as expected?
I tried to load the string from an asset file asynchronously, and it seems that it worked as expected. Here is my code:

class _MarkdownPageState extends State<MarkdownPage> {
  String text = "Loading asset string...";

  Future<void> loadDemo() async {
    String demoStr = await rootBundle.loadString('assets/demo.md');
    setState(() => text = demoStr);
  }

  @override
  void initState() {
    super.initState();
    loadDemo();
  }

  @override
  Widget build(BuildContext context) {
    CSS baseCSS = CSS();
    baseCSS.fontSize = 13;
    return Scaffold(
      appBar: AppBar(
        elevation: 0,
        title: Text('Markdown Test'),
      ),
      body: RefinedMarkdown(
        text: text,
        css: baseCSS,
      ),
    );
  }
}

And after setting state, the widget just shows the same result as the screenshot in demo:
image
Actually I cannot figure out exactly what problem you are facing. Please give me a more detailed description about this issue, test code would be best, thank you.
By the way, this widget don't support all markdown standards for now. I'll add those supports after this month since I'm going to take lots of exams this month and I have no time for this. If this problem occurs because of markdown standard, it would be fixed in the later version of refined_markdown. :)

I am trying to maintain multilingual markdown content in https://app.lokalise.com/ and later use it to render the content in the app.

Take the following example


Heading

Content

Heading2

Content2


For the above in markdown, I would write

## Heading

#### Content

## Heading2

#### Content2

This is a very simple content and when I hardcode the string to a variable and render it works. However, when I pull the markdown content from the lokalise platform weird \n characters start to appear in the render and the content is broken. I am using HTML render instead for now but would love to switch to this markdown plugin again.

Great job so far :) Good luck with your exams !!