Giter VIP home page Giter VIP logo

markdown.xaml's Introduction

Markdown XAML

Markdown XAML is a port of the popular MarkdownSharp Markdown processor, but with one very significant difference: Instead of rendering to a string containing HTML, it renders to a FlowDocument suitable for embedding into a WPF window or usercontrol.

With HTML output, details of fonts and colours (and so on) are handled by CSS, but with a FlowDocument there's no direct equivalent. Instead of the HTML approch of linking a stylesheet to the rendered output, MarkDown.Xaml uses WPF styles that are linked to the rendering engine and applied to the output as it is generated. See the included demo application for an example of how this can be configured.

Where would I use this?

I wrote this to use in a WPF application where I was generating paragraphs of text for that described the output of a rules engine, and I wanted a richer display than just a column of plain text.

Potentially, I could have used MarkdownSharp and an embeded browser or other HTML renderer to achieve this (the route taken by MarkPad, but this didn't give me the fine control over appearance that I desired.

Where shouldn't I use this?

If the Markdown you are processing is going to end up translated to HTML, stick with MarkdownSharp or one of the other similar translators, so that your rendering is as accurate as possible. On the otherhand, if you are showing the Markdown within your WPF application and not passing it out to a browser elsewhere, Markdown XAML may be a great fit.

What differences are there?

Since the output is not HTML, any embedded HTML is going to end up displayed as raw code. This also means that there's no way to bypass (or tunnel through) the Markdown engine to achieve anything not supported by Markdown directly. Depending on your context this may or may not be a significant issue.

What remains to be done?

The core of the Markdown render is complete, as is support for basic styling. The structure of the MarkdownSharp codebase has been retained to aid maintenance - if there are any regular expression fixes there, they should be easy to patch in here.

There are a number of Markdown extensions that could be supported, though since MarkdownSharp targets only the core, this would necessitate a departure from keeping the codebase as similar as possible.

License

Markdown XAML is licensed under the MIT license.

markdown.xaml's People

Contributors

francescoformenti avatar gpailler 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

markdown.xaml's Issues

Hyperlink not causing navigation

We have been using your converter to convert Markdown from our Github Repository into our WPF application with great success, and so far it is working really well. The only slight issue is the the rendered Hyperlink, when clicked, don't seem to do anything. Can you please suggest what technique can be used to capture the click event of the Hyperlink and open an external browser window to navigate to the specified URL?

Thanks!

Support Table

Not Support Table Like

Tables Are Cool
col 1 is left-aligned $1600
col 2 is centered $12
col 3 is right-aligned $1

Links aren't clickable

I have Markdown with some links to URLs. They look clickable, but it happens nothing when the text is clicked :(

Support Embedded Images

I noticed that the way you're doign images is to copy them to the output directory and load from the file system. I wouldn't want to do this with my applications (I want an exe and nothing else).

I've modified my own copy to load these resources.

All that needs changing is the ImageInlineEvaluator method where it loads the BitmapImage:

imgSource = new BitmapImage();
imgSource.BeginInit();
imgSource.CacheOption = BitmapCacheOption.None;
imgSource.UriCachePolicy = new RequestCachePolicy(RequestCacheLevel.BypassCache);
imgSource.CacheOption = BitmapCacheOption.OnLoad;
imgSource.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
//imgSource.UriSource = new Uri(url);
//imgSource.UriSource = new Uri(@"pack://application:,,,/Assets/yourimage.png", UriKind.RelativeOrAbsolute);
imgSource.UriSource = new Uri($"pack://application:,,,{url}", UriKind.RelativeOrAbsolute);
imgSource.EndInit();

If I find time I'll think of a nice way to switch between pulling the file from the filesystem or looking for embedded images. This currently requires the following markdown syntax:
![My Image](/Assets/myimage.png)

Installation & Usage Documentation

There is no documentation on how to install, configure and use this library.

Granted there is code in the demo project that shows you how to implement the library, I would suggest either adding the steps to the current readme or adding a new instructions file

Raised this as an issue, but I will be writing up these steps and will submit a PR, since I did get it working and other people would definitely benefit from this lib!

The default style (typeface) are not very readable

It seems that the default font that renders in the FlowDocument is not very readable. How should we change it? Setting the FontName in the FlowDocumentScrollViewer doesn't work?

Thanks in advance :)

NuGet Package Not The Same As Demo Code

I ran the demo project and it worked as expected. I then pulled the NuGet package into my own project and installed it. There is an issue with the following properties of the Markdown class:

  • TableBodyStyle`

  • TableHeaderStyle

I pulled the code out of the sample, pulled in the xaml namespace and recieve the following warning:
xaml warning

With these 2 styles set the app will not build, if these are removed then the app builds and displays the markdown, without table support.

visual studio error

Consider the following markdown document:

# Markdown

## My Markdown Page

This is great I have rendered some markdown!

 - List Item
 - List Item
 - List Item

Lets render a table!

| Name  | Email           |
|-------|-----------------|
| User1 | [email protected] |
| User2 | [email protected] |

Hooray!

When referencing the NuGet package the following is rendered:
NuGet Render

If I pull the code from Markdown.Xaml directly into my project (bypassing the NuGet) then it renders correctly:

Directly Referencing Files

Does the NuGet package need rebuilding?

Bold / Italic rendering is wrong

If you just run the Demo, there is a Markup MarkdownSharp that should get rendered italic, but get rendered bold. Same is true for bold Markup: it is rendered italic.

Question: Can this be used for editable text?

I want to include in my app a rich text editor that output Markdown text, so that I can store it and display it later, but I want people to see only the formatted text, not the Markdown. Is this possible with this control?

Support for line break

Hello, would it be possible to add support for a single newline? Ie. by interpreting a single \ at the end of a line, and/or two or more spaces as meaning a single newline. Thanks for a great control! Greets, Menno

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.