0xc3u/Indiko.Maui.Controls.Markdown

Suggestions

hansmbakker opened this issue · 2 comments

Hi,
some quick suggestions to make code cleaner:

  • the Validations class is only used to check for Base64 validity which dotnet has a builtin function for. You could change

    if (Validations.IsValidBase64String(imageUrl))
    {
    byte[] imageBytes = Convert.FromBase64String(imageUrl);
    imageSource = ImageSource.FromStream(() => new MemoryStream(imageBytes));
    }

    to

    if (System.Buffers.Text.Base64.IsValid(imageUrl))
    {
        byte[] imageBytes = Convert.FromBase64String(imageUrl);
        imageSource = ImageSource.FromStream(() => new MemoryStream(imageBytes));
    }

    and remove the Validations class.

  • the InvertedBooleanConverter is included in the MAUI community toolkit - you could replace it with that

  • there is a lot of manual Markdown parsing in the control - another possibility is to replace your parsing code by implementing a Markdig renderer and thereby focus more on the control code generation part

Hi Hans,

Thank you for your suggestions. We will double-check them and keep you posted.

  • In the new version (1.0.8) we use now "System.Buffers.Text.Base64.IsValid" Thanks for suggestion.
  • The Converter is totally removed, because there was no need for it.
  • For the moment we stick to our own parsing, maybe later we will move to the markdig parsing.