Giter Site home page Giter Site logo

mdxaml's People

Contributors

akiotakahashi avatar boelew avatar cuiliang avatar derjuulsn avatar fjch1997 avatar gpailler avatar lucas404x avatar lukeomp avatar maxaquila avatar theunrepentantgeek avatar thoemmi avatar trigger-segfault avatar whistyun 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

mdxaml's Issues

MarkdownStyle is being overridden in constructor

There is MarkdownStyle property in MarkdownScrollViewer control.
It can be set directly, or via a style.
However, setting it via a style does not work, because its value is being overridden by Standard Markdown style:

        public MarkdownScrollViewer()
        {
            Engine = new Markdown();
            SetCurrentValue(MarkdownStyleNameProperty, nameof(MdStyle.Standard));
        }

The overriding is happening in MarkdownStyleNameProperty change handler (UpdateStyleName method):

owner.MarkdownStyle = (Style)prop.GetValue(null);

Please fix the issue.

Using mdXaml in VSIX extension

I've been trying to get it working for several days so not sure if this is possible. When running VS instance I get an error:
FileNotFoundException: Could not load file or assembly 'MdXaml, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
I am guessing one of the dependencies from nuget packages is not automatically installed in vsix folder, but I am struggling to find which ones.

What is the proper way to gain control over Markdown font size, codeblock style, etc?

Within this snippet of markdown for example,

<mdxam:MarkdownScrollViewer xml:space="preserve" 
                            x:Name="MarkdownPeer" Background="Transparent" 
                            VerticalScrollBarVisibility="Hidden"
                            Margin="16,37,0,0" 
                            Visibility="Hidden" 
                            Foreground="#FFF2EEE5" 
                            FontSize="18">
            null
</mdxam:MarkdownScrollViewer>

Programmatically adding markdown, e.g

TextRange rng = new TextRange(
    TextEntry.Document.ContentStart,
    TextEntry.Document.ContentEnd);
    
MarkdownScrollViewer.Markdown = rng.Text; 

Results in inconsistent Markdown. Here's a few things I noticed in my usage:

  1. Headers do not conform to the MarkdownScrollViewer's Foreground, thus remain black.
  2. Markdown does not conform to MarkdownScrollViewer's Font properties, most notably, font size.
  3. Codeblocks also negate MarkdownScrollViewer's properties, and remain independent.
  4. Lists seem to form a margin and end up being formatted ~50px to the right of where expected.

This could be a result of my (probably) improper usage. How should we go about controlling styling of the Markdown in further depth?

New Plugin: CheckBox

I created this new plugin to display checkboxes defined by [ ] and [x] in markdown

You may include this in the repo and release a nuget for it ;)

You may also update it to reflect your code style or add new features.

Sadly the plugin api doesn't provide the original index of the text span a parser is parsing. So I had to add a wild hack to be able to ensure the checkbox can update the markdown at the correct place

public class CheckboxPluginSetup : IPluginSetup
{
    public void Setup(MdXamlPlugins plugins) => plugins.Inline.Add(new CheckboxInlineParser());
}
public class CheckboxInlineParser : IInlineParser
{
    public CheckboxInlineParser()
    {
        this.FirstMatchPattern = new Regex(@"\[(?<value>[ |x])\]\s*(?<caption>[^\n|[]*)");
    }

    public Regex FirstMatchPattern { get; }

    public IEnumerable<Inline> Parse(string text, Match firstMatch, IMarkdown engine, out int parseTextBegin, out int parseTextEnd)
    {
        parseTextBegin = firstMatch.Index;
        parseTextEnd = firstMatch.Index + firstMatch.Length;

        CheckBox chk = new()
        {
            IsChecked = "x".Equals(firstMatch.Groups["value"].Value, StringComparison.InvariantCultureIgnoreCase),
        };
        chk.Checked += (sender, e) => this.ReflectChkChangeInMarkdown(sender as CheckBox, true, firstMatch.Value);
        chk.Unchecked += (sender, e) => this.ReflectChkChangeInMarkdown(sender as CheckBox, false, firstMatch.Value);
        chk.Loaded += (sender, e) => this.UpdateChkEnabled(sender as CheckBox, firstMatch.Value);

        if (firstMatch.Groups["caption"].Value is string caption && !string.IsNullOrEmpty(caption))
        {
            chk.Content = new FlowDocumentScrollViewer()
            {
                Document = engine.Transform(caption),
                HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden,
                VerticalScrollBarVisibility = ScrollBarVisibility.Hidden,
                Focusable = false
            };
        }

        StackPanel sp = new();
        sp.Children.Add(chk);

        return new Inline[] { new InlineUIContainer(sp) };
    }

    private void UpdateChkEnabled(CheckBox chk, string text)
    {
        if (this.FindParentMarkdownViewer(chk) is not MarkdownScrollViewer viewer)
        {
            chk.IsEnabled = false;
        }
        else
        {
            chk.IsEnabled = this.UniqueIndex(viewer.Markdown, text) >=0;
        }
    }

    private void ReflectChkChangeInMarkdown(DependencyObject chk, bool isChecked, string text)
    {
        if (this.FindParentMarkdownViewer(chk) is not MarkdownScrollViewer viewer)
        {
            return;
        }

        string markdown = viewer.Markdown;
        int startIndex = this.UniqueIndex(markdown, text);
        if (startIndex == -1)
        {
            // Not unique
            return;
        }

        StringBuilder sb = new(viewer.Markdown);
        sb[startIndex + 1] = isChecked ? 'x' : ' ';
        viewer.Markdown = sb.ToString();
    }

    private MarkdownScrollViewer FindParentMarkdownViewer(DependencyObject child)
    {
        var parent = VisualTreeHelper.GetParent(child);
        while (parent is not MarkdownScrollViewer and not null)
        {
            parent = VisualTreeHelper.GetParent(parent);
        }

        if (parent is not MarkdownScrollViewer viewer)
        {
            return null;
        }

        return viewer;
    }

    private int UniqueIndex(string markdown, string text)
    {
        int firstIndex = markdown.IndexOf(text);
        if (firstIndex == -1)
        {
            // Not found
            return -1;
        }

        int secondIndex = markdown.IndexOf(text, firstIndex + 1);
        if (secondIndex != -1)
        {
            // Second hit
            return -1;
        }

        return firstIndex;
    }
}

how to set Background and Foreground color ?

As soon I try to force Background and Foreground Color, the Style don't work anymore, no more heading, etc ...
Image always work fine.

What I can make wrong ?

           Markdown engine1 = new Markdown();
            Markdown engine2 = new Markdown();
            Markdown engine3 = new Markdown();


            string markdownTxt = System.IO.File.ReadAllText("example.md");
            FlowDocument document1 = engine1.Transform("# 1 Sasabune\n\n\n\n"+markdownTxt);
            FlowDocument document2 = engine2.Transform("# 2 SasabuneCompact\n\n\n\n" + markdownTxt);
            FlowDocument document3 = engine3.Transform("# 3 SasabuneStrandard\n\n\n\n" + markdownTxt);
            FlowDocument document4 = engine3.Transform("# 4 SasabuneStandard\n\n\n\n" + markdownTxt);

            document1.Background = new SolidColorBrush( Color.FromArgb(255, 0, 0, 0));
            document1.Foreground = new SolidColorBrush( Color.FromArgb(255, 255, 250, 250));
            document1.Style = MarkdownStyle.Sasabune;

            document2.Background = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
            document2.Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 250, 250));
            document2.Style = MarkdownStyle.SasabuneCompact;

            document3.Background = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
            document3.Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 250, 250));
            document3.Style = MarkdownStyle.SasabuneStandard;

            //document4.Background = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
            //document4.Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 250, 250));
            document4.Style = MarkdownStyle.SasabuneStandard;

            FDPageViewver.Document = document1;  // FD=FlowDocument
            FDReader.Document = document2;
            FDSV.Document = document3;  
            MSV.Document = document4;  // MSV=MarkdowScrollViewer

Is there a way to turn off specific list markers (question)

Thank you for such an awesome library.

Is there a way to turn off list markers without modifying the library?

For example I want

but not

A.
B.
C.

This may be an odd question, but not all Markdown to HTML converters recognize alphabetical and roman numeral lists. Even Github won't recognize it (as you can see the alphabetical list won't be indented in this example).

File not found

Hi! Please help me.

If insert [test](test) and clicked, catch exception file not found (System.ComponentModel.Win32Exception)

My xaml:

<Style TargetType="xaml:MarkdownScrollViewer" x:Key="MarkdownScrollViewerStyle">
    <Style.Setters>
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="VerticalAlignment" Value="Stretch" />
        <Setter Property="VerticalScrollBarVisibility" Value="Disabled" />
        <Setter Property="HorizontalScrollBarVisibility" Value="Auto" />
        <Setter Property="MarkdownStyle" Value="{x:Static xaml:MarkdownStyle.Standard}" />
    </Style.Setters>
</Style>

...

<xaml:MarkdownScrollViewer
    Style="{StaticResource MarkdownScrollViewerStyle}"
    Markdown="{Binding Text}"
    ClickAction="OpenBrowser" />

It's bad if user can crash the program in the user interface.

please, help me. How can I fix this?

Navigating to another markdown file, and anchors

Right now I have a singel markdown file, but it's getting large and I'd lke to break it up into smaller files and be able to navigate between them.

Suppose I have links to other markdown files relative to the current. I couldn't seem to find a way to implement navigation to other markdown files, and I suppose it makes senst that external navigation is not part of this library.

Right now, I have it binding to a model and the Markdown binding to CurrentPage.

            <mdXaml:MarkdownScrollViewer 
                x:Name="MarkdownScrollViewer"
                VerticalAlignment="Stretch"
                HorizontalAlignment="Stretch"
                Background="White"
                MarkdownStyle="{Binding Style}"
                Markdown="{Binding CurrentPage}">
            </mdXaml:MarkdownScrollViewer>

Then I load the text into CurrentPage.

            var path = "Help\\Index.md";

            var model = new HelpModel
            {
                CurrentPage = File.ReadAllText(path),
                CurrentPath = "Help",
                Style = CustomStyles.BetterGithub,
                Escape = new RelayCommand<object>(o => Close())
            };

            MarkdownScrollViewer.Engine = new Markdown()
            {
                HyperlinkCommand = new CustomLinkCommand(model),
            };

I have a CustomLinkCommand that takes the model, so I can load a new page when I intercept a relative link.

    public class CustomLinkCommand : ICommand
    {
        private readonly HelpModel _model;

        public event EventHandler CanExecuteChanged;

        public CustomLinkCommand(HelpModel model)
        {
            _model = model;
        }

        public bool CanExecute(object parameter) => true;

        public void Execute(object parameter)
        {
            var href = (string)parameter;


            try
            {
                if (href.StartsWith("https:"))
                {
                    Process.Start(new ProcessStartInfo(href)
                    {
                        UseShellExecute = true,
                        Verb = "open"
                    });
                }
                else
                {
                    href = href.Replace("%20", " ");
                    href = href.Replace("/", "\\");


                    var file = Path.GetFullPath(Path.Combine(_model.CurrentPath, href));
                    _model.CurrentPath = Path.GetFullPath(Path.GetDirectoryName(file));

                    if (File.Exists(file))
                    {
                        _model.CurrentPage = File.ReadAllText(file);
                    }
                }

            }
            catch
            {
                // error handle; notifications, path changes, etc. 
                // MessageBox.Show($"Failed to open {href}");
            }
        }
    }

This kind of works, but now I am unable to link to an anchor (e.g. #some-anchor), and obviously I can't link to an anchor in another markdown with ./Some%20Page.md#some-anchor .

If I could somehow let the viewer handle the link if I detect an anchor, it would be okay, which leaves the anchor in another markdown, maybe if you could expose some event that executes on load / render, and a command to navigate to an anchor programatically.

Or am I thinking about this wrong?

How to make links clickable?

Having the following markdown: [Google](https://google.com) ( => Google ), the link is properly styled, but doesn't show the hand icon and in general doesn't work. How one can make the links clickable?

Copying a text containing a Hyperlink to clipboard causes an unhandled exception

Hi,
the MarkdownScrollViewer has a small issue when using Hyperlinks and runs into an unhandled exception when involving the clipboard.

Steps to reproduce

  • Start the "WithFluentWPF sample app
  • On the rendered Markdown on the right side scroll down to "Link to Google"
  • Mark some text including the hyperlink
  • Push ctrl+c to copy it to clipboard

Actual Behavior

  • The copy action fails as it tries to serialize the nested OpenCommand class and runs into an unhandled exception: "Cannot serialize a non-public type 'MdXaml.MarkdownScrollViewer+OpenCommand'. "

Expected Behavior

  • No errors occur

Possible Fix

  • Moving the OpenCommand class outside of the nested structure to be a top level will prevent this error from happening

Spoilers support (details)

Hello again!

Is it possible to make spoilers? I tried this syntax, but it didn't work:

<details>
  <summary>Spoiler warning</summary>
  
  Spoiler text. 
  
</details>

It works here:

Spoiler warning

Spoiler text.

I tried with and without the MdXaml.Html plugin, and the result is the same.

Remote images mostly not showing

Hey first of all thanks for this great package!

Everything seems to be working nicely, including custom styling. The only issue I'm facing thus far:

Remote images are mostly not working, and there is no general rule what is working and what isn't.
For example this image always shows:

![image](https://getcontrail.com/images/icon-32px.png)

This one only showed up once, otherwise it's just an empty space:

![image](https://cdn.29palms.de/api/img/developer/f585a34c2b81b5b1bff1fcf51e4e151b.jpg)

The markdown is data bound to a property.
Is there a way to debug this?

Style definition in xaml

Hi, I have this error message as soon I try to add style code in xaml.
I use MS Visual studio 22, with WPF application .NET 6

I have this error, with the demo code for Style

Severity	Code	Description	Project	File	Line	Suppression State
Error	XLS0508	Text not allowed as content in a dictionary or an array property.	WpfAppMdDemo2	MainWindow.xaml	45	
Error	MC3088	Property elements cannot be in the middle of an element's content.  They must be before or after the content. 

        <mdxam:MarkdownScrollViewer
            Grid.Column="1" Grid.Row="0"
            xml:space="preserve"
            x:Name="MSV"
            >
            # Heading 1
           
            ## Heading 2
            
            content
    <mdxam:MarkdownScrollViewer.MarkdownStyle>
        <Style TargetType="FlowDocument">
            <Style.Resources>  (<======= here is ligne 45)
                <Style TargetType="Paragraph">
                    <Style.Triggers>
                        <Trigger Property="Tag" Value="Heading1">
                            <Setter Property="FontSize"   Value="42" />
                            <Setter Property="Foreground" Value="Red" />
                            <Setter Property="FontWeight" Value="Light" />
                        </Trigger>

                        <Trigger Property="Tag" Value="Heading2">
                            <Setter Property="FontSize"   Value="20" />
                            <Setter Property="Foreground" Value="Blue" />
                            <Setter Property="FontWeight" Value="Light" />
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </Style.Resources>
        </Style>
    </mdxam:MarkdownScrollViewer.MarkdownStyle>        </mdxam:MarkdownScrollViewer>
    </Grid>

Transform in list

Hello,

I tried to use your package MdXaml, but I have this error.
If my paragraph begin with "first, second third", the MdXaml control transform this in the OL list like this: "i. second third" ...

For whatever word follow by comma, I have a transformation into a list.

image question.

i want to know relative path connot read?
i use Typora can read the image ,but MDXmal get a error "file not found".
Is there any correct content that I missed?
Thanks

Many styles are not fully rendered

code

        var str = "C#(发音为 \"C sharp\")是一种现代、面向对象的编程语言,由微软公司开发并在2000年首次发布,作为.NET框架的一部分。C#设计旨在提高开发效率,兼具强大的类型系统和现代编程特性,适用于从网页应用到桌面软件,再到游戏开发和企业级解决方案的广泛领域。\n\n### C# 的核心特性与概念\n\n#### 基础概念\n1. **强类型语言** - C#要求变量在使用前声明其类型,减少类型错误。\n2. **面向对象编程 (OOP)** - 支持类、对象、继承、封装、多态等概念。\n3. **垃圾回收 (GC)** - 自动管理内存,减少程序员手动分配和释放内存的工作。\n\n#### 进阶特性\n1. **LINQ (Language Integrated Query)** - 语言集成查询,允许以SQL类似的方式操作内存中的数据。\n2. **异步编程** - 使用async/await关键字简化异步操作的编写。\n3. **Lambda 表达式** - 简洁地定义匿名函数。\n4. **属性 (Properties)** - 提供访问私有字段的公共接口,支持数据验证逻辑。\n5. **泛型** - 支持编写可重用的类型安全的集合和方法。\n\n### C# 发展历程简表\n\n| 版本 | 发布年份 | 主要特性 |\n| --- | --- | --- |\n| 1.0 | 2002 | 初始版本,伴随.NET Framework 1.0发布 |\n| 2.0 | 2005 | 泛型、匿名方法、迭代器 |\n| 3.0 | 2007 | LINQ、Lambda表达式、隐式类型局部变量 |\n| 4.0 | 2010 | 动态类型、命名实参、异步编程模型的初步形态 |\n| 5.0 | 2012 | async/await、Caller Info Attributes |\n| 6.0 | 2015 | Roslyn编译器、字符串插值、异常过滤器 |\n| 7.0 | 2017 | 出栈变量、模式匹配、元组 |\n| 8.0 | 2019 | 默认接口方法、范围索引、可空引用类型 |\n| 9.0 | 2020 | 拓展方法上的顶级语句、目标类型新语法 |\n\n### Hello World 示例代码\n\n```csharp\nusing System;\n\nclass HelloWorld\n{\n    static void Main()\n    {\n        Console.WriteLine(\"Hello, World!\");\n    }\n}\n```\n\n在这段代码中,`using System;` 引入了System命名空间,其中包含Console类,用于输出文本到控制台。`Main` 方法是程序的入口点,而 `Console.WriteLine(\"Hello, World!\");` 这行代码则打印出经典的“Hello, World!”问候语。";
        //var x = Markdig.Wpf.Markdown.ToFlowDocument(str);
        var engine = new Markdown().Transform(str);

        RichTextBox.Document = engine;

Problem description

For example: font title size, font background color, table border, table row background color

Normal style

Snipaste_2024-04-30_14-22-51

MdXaml Style rendering

Snipaste_2024-04-30_14-24-17

Aligning headers?

Hi!

Is there support for aligning headers, i.e something like

This is my header

p.= # This is a centered header.

I have not been able to make it work, and there is no listed example of this. If not it would be a nice feature!

Escape character \ not working correctly

I've noticed that the \ character is not being processed correctly as it seems to only be working when used for escaping another \ or * character but not for any other character. This causes stuff like links and images to break if there are escape characters in it and also the \ character to display when used for anything else.

Test markdown:

### Working
- \\
- \*

### Not working
- [![.jpg\]](https://steamuserimages-a.akamaihd.net/ugc/923673299818711932/AEB9D81DE88B2B9BCA368885A3B6966D32D1EF16/ ".jpg]")](https://steamuserimages-a.akamaihd.net/ugc/923673299818711932/AEB9D81DE88B2B9BCA368885A3B6966D32D1EF16/)
- \#
- \-
- \]
- \[
- \(

Using MdXaml version 1.21.0 and AvalonEdit 6.0.0 on .Net framework 4.6.2. Markdown is being set via Binding in Markdown property.

Screenshots:

MdXaml:
image

VS Code preview:
image

Memory Leak in MarkdownScrollViewer

The MarkdownScrollViewer Control cannot be garbage collected.

The reason is the use of the AddValueChanged method of the DependencyPropertyDescriptor in the MarkdownScrollViewer constructor.
DependencyPropertyDescriptor .FromProperty(FlowDocumentScrollViewer.DocumentProperty, typeof(FlowDocumentScrollViewer)) .AddValueChanged(this, OnDocumentChanged);

You can find more information about this in the following article:
https://agsmith.wordpress.com/2008/04/07/propertydescriptor-addvaluechanged-alternative/

Extension point for code highligting

AvalonEdit's builtin highliting rules are not good for dark theme.

image

I'think it's better to allow user provide custom highlighting definitions at runtime.

Perhaps we can define some kind of interface:

public interface IMarkdownHighlightingProfider{
    IHighlightingDefinition GetByLang(string lang)
}

and user can set provider at runtime something like this:

MdMarkdownConfig.HighlightingProfider = new CustomHighlightingProvider()

Table of contents or links to anchors

Hi! Thank you for a great library.
Is it possible to navigate on a page with a link to anchors?
I tried this https://stackoverflow.com/a/27953547/3087417 but clicking on a link with ClickAction="OpenBrowser" leads to a fatal exception. With ClickAction="DisplayWithRelativePath" it displays the library definition and XAML code of the control or something like that.

[Question] Is there a easy way to activate smooth scrolling ?

It seems that mdxam:MarkdownScrollViewer doesn't have a built-in smooth scrolling implementation.
And when I try to use FlowDocumentScrollViewer , only the image portion has smooth scrolling, the text portion does not.

I wonder if there is a proper way to implement smooth scrolling correctly, do we have to write it ourselves?

Different code styles

How to configure syntax style for different codeBlock languages?

<mdxam:MarkdownScrollViewer x:Name="Markdownview"
                                                            HorizontalAlignment="Center" Foreground="White" VerticalAlignment="Stretch"
                                                            VerticalScrollBarVisibility="Disabled" Markdown="{Binding content}" Grid.Column="1" Margin="20,20,20,20" PreviewMouseWheel="Markdownview_MouseWheel">
                                    <mdxam:MarkdownScrollViewer.MarkdownStyle>
                                        <Style TargetType="FlowDocument" BasedOn="{x:Static mdxam:MarkdownStyle.Sasabune}">
                                            <Style.Resources>
                                                <Style TargetType="Paragraph">
                                                    <Style.Triggers>
                                                        <Trigger Property="Tag" Value="Heading1">
                                                            <Setter Property="FontSize" Value="42" />
                                                        </Trigger>

                                                        <Trigger Property="Tag" Value="Heading2">
                                                            <Setter Property="FontSize" Value="20" />
                                                        </Trigger>

                                                        <Trigger Property="Tag" Value="CodeBlock">
                                                            <Setter Property="Margin" Value="15"/>
                                                            <Setter Property="Padding" Value="15"/>
                                                        </Trigger>
                                                    </Style.Triggers>
                                                </Style>
                                                <Style TargetType="Hyperlink">
                                                    <Setter Property="TextDecorations" Value="None" />
                                                </Style>
                                            </Style.Resources>
                                        </Style>
                                    </mdxam:MarkdownScrollViewer.MarkdownStyle>
                                </mdxam:MarkdownScrollViewer>

Upgrade to AvalonEdit 6

It would be nice if you could upgrade to AvalonEdit 6 (current is 6.1.2.30)
I'll fork this repo now to get it working for me ;)

EDIT: I meant for .NET Framework. As you already use AvalonEdit 6 for .net-5

Images are not released after they are referenced in markdown

Once an image has been loaded into the markdown control, it is not released even after unloading its contents to some other markdown file.

This forces to close the running application when I want to move images from one directory to another.

Am I missing something regarding this control and how to release image resources?

Bolding first word in unordered list not rendering correctly

I'm attempting to create an unordered list where the first word is bold like so:

  • Bold Header: Details

Using the following markdown:

* **Bold Header**: Details

But the render engine fails to do so properly. I could use the hyphen to do the unordered list like most markdown engines I've used in the past, but I don't really like the open bullet used and am unsure how to change it out.

Document is null in class constructor

Document get returns null in class constructor but its possible to access Document outside it.

Sample code:

<mdxam:MarkdownScrollViewer x:Name="markdown" ../>
public Sample()
{
  markdown.Document.Blocks.Add(new Paragraph("Null exception")));
}

public void SomeFn()
{
  markdown.Document.Blocks.Add(new Paragraph("This works")));
}

Style custom

i am here to consult u how can i custom the style of the md control?

Open Hyper Link crashes when no web browser is installed

MdXaml.LinkActions.OpenCommand.Execute crashes on a Windows that has no Web Browser installed.

System.ComponentModel.Win32Exception: An error occurred trying to start process 'https://atlasti.com/de/atlas-ti-legal-center/datenschutzerklaerung-atlas-ti' with working directory 'C:\Program Files\Scientific Software\ATLASti.23'. Der angegebenen Datei ist keine Anwendung zugeordnet.
at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at MdXaml.LinkActions.OpenCommand.Execute(Object parameter)

scroll-wheel-hijack

I placed the MarkdownScrollViewer inside the DataTemplate of the ListBoxItem, which prevents scrolling of the ListBox when the mouse is within the ListBoxItem.
I attempted to set the method triggered by the PreviewMouseWheel event to an empty method, but it did not work.

    <DataTemplate x:Key="ai">
        <Grid Margin="0,5,0,5">
            <Border x:Name="border"
                    Background="#FFFFFF" CornerRadius="1" 
                    BorderBrush="{DynamicResource message_recv_border_brush}" BorderThickness="1"  
                    VerticalAlignment="Top" HorizontalAlignment="Right"
                    MinHeight="35" MinWidth="50" Padding="5" Margin="0,2,10,2" >
                <Label VerticalContentAlignment="Center">
                    <mdxam:MarkdownScrollViewer Markdown="{Binding Content}"/>
                    <!--<TextBox x:Name="contentBox" Text="{Binding Content}" IsReadOnly="True" TextWrapping="Wrap" BorderThickness="0" Background="Transparent"/>-->
                </Label>
            </Border>
        </Grid>
    </DataTemplate>

Use a lexer/parser lib like ANTLR

Instead of spliting all strings by yourself you should use a lexer like ANTLR.
This has many benefits:

  • There might already be a markdown language definition for ANTLR on the internet.
  • You will get a stream of tokens, that can be parsed way more easy
  • Parsing might be even faster (ANTLR4 is highly optimized)
  • For each token you know the exact index of the original string, that it originates of. Helpfull for #50

Unable to display resource images within library assembly

I want to make a dialog to display help docs within each of my projects(assemblies). I do this by placing the markdown file and image file within a library project. The markdown text is displayed well but the ResourceImage can not be displayed. A red line of error text is displayed instead.

Image Scaling and Gif support

Thank you for the great library!

I'm wondering if it's possible to add support for scaling images, as well as supporting gifs?
or is it possible to achieve these without modifying the library?
Scaling image syntax example:

[image](example.png[150%])

I know image scaling is not part of the Markdown syntax, but would love to hear your opinion on this. Thanks!

SVG Images in Markdown not shown

In most of my projects I'm using some badges (from shields.io) at the top of my Readme.md file. E.g.:
[![Nuget Version](https://img.shields.io/nuget/v/AssemblyInfoHelper.svg)](https://www.nuget.org/packages/AssemblyInfoHelper/)

These badges result in SVG images that aren't correctly shown when the Markdown file is loaded with the MarkdownScrollViewer.
The resulting text is:

!https://img.shields.io/nuget/v/AssemblyInfoHelper.svg
NotSupportedException:No imaging component suitable to complete this operation was found

Is it possible to support SVG images in markdown?
To show the Readme files (including the badges) I'm using a selfwritten library: https://github.com/M1S2/AssemblyInfoHelper
There is also a complete example Readme.md in this repository.

Embedded HTML tags in Markdown

Is it possible to show some HTML tags that are inside the Markdown string using the MarkdownScrollViewer?
E.g.
<img src="https://github.com/M1S2/Ehrungsprogramm/raw/master/Screenshots/Screenshot_Start.png" width="45%"></img>

Example Readme file showing an example for the embedded HTML tags in the Markdown string:
https://github.com/M1S2/Ehrungsprogramm

Document styles not applied in DataTemplates

Hello,

I am trying to use MarkDownScrollViewer inside an <ItemsControl> element. The markdown content is loading properly, but the provided style name is ignored and the text is rendered always with some default style. I also tried to pass a new style from the ResourceDictionary, but the result is just the same.

Maybe this behavior could be related to this?

...
<!-- This prints "Hello world" correctly in "compact" style -->
<mdxam:MarkdownScrollViewer xml:space="preserve" Margin="0 10 0 10" ScrollViewer.VerticalScrollBarVisibility="Auto" MarkdownStyleName="Compact">
# Hello world
</mdxam:MarkdownScrollViewer>
...
<ItemsControl ItemsSource="{Binding MyAwesomeCollection}">
    <ItemsControl.ItemTemplate>
        <DataTemplate>

            <!-- But this prints "Hello world" in default style -->
            <mdxam:MarkdownScrollViewer xml:space="preserve" Margin="0 10 0 10" ScrollViewer.VerticalScrollBarVisibility="Auto" MarkdownStyleName="Compact">
            # Hello world
            </mdxam:MarkdownScrollViewer>

        </DataTemplate>
    </ItemsControl.ItemTemplate>
</ItemsControl>

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.