whistyun / markdown.avalonia Goto Github PK
View Code? Open in Web Editor NEWrender markdown with Avalonia UI
License: MIT License
render markdown with Avalonia UI
License: MIT License
Inline code text appears as what I presume are "missing character" rectangles.
Kubuntu Linux 20.04 x64
Markdown.AvaloniaDemo
and Markdown.AvaloniaFluentDemo
I'm not entirely certain as to why this happens, but I did notice that, of the fonts listed in FontFamilyCollecter.cs
(menlo
, monaco
, consolas
, droid sans mono
, inconsolata
, courier new
, monospace
,droid sans fallback
), none are installed on my setup except the last one (droid sans fallback
)...and uh, something seems a bit...off about that one...
While I was checking which fonts were installed, I noticed that the font manager's preview of droid sans fallback
looked rather peculiar, as shown here:
For comparison, here's a more typical font preview, for comparison (specifically of FreeSans
):
Oddly enough though, Droid Sans Fallback
is perfectly readable in LibreOffice Writer, as shown here:
(...though, given what comes next, I'm not fully convinced that LibreOffice Writer is actually rendering Droid Sans Fallback
at all here...)
...after seeing this bizarre discrepancy, I decided to try comparing the fonts in some other programs. First pick was Microsoft Office Word 2010, which produces some rather...telling results:
Just before submitting this issue, an idea popped into my head. I decided to try adding a font I knew I had installed - and which I knew would not misbehave the way Droid Sans Fallback
did - to the list of fonts in FontFamilyCollecter
, to see if that would help. First, I tried FreeMono
(which I spelled as freemono
in the code)...but this produced the same results as Droid Sans Fallback
, no matter where I put it in the list. After reverting this, I instead tried adding DejaVu Sans Mono
(which I spelled as dejavu sans mono
in the code) to the list, placing it at index 0. I was pleasantly surprised when I built and ran the sample app with the changes, and was met by this:
Further experimentation showed that I could make dejavu sans mono
the second-last entry in the list, and the text would still be displayed correctly as shown just above. To avoid any possibility of ambiguity, that final test (which was successful) had the font list modified as follows:
string[] RequestFamilies = {
"menlo",
"monaco",
"consolas",
"droid sans mono",
"inconsolata",
"courier new",
"monospace",
"dejavu sans mono",
"droid sans fallback"
};
I hope this gives you whatever you need to look into this, if/whenever you're able and willing. If you need anything more from me, feel free to @Splitwirez and I'll see what I can do next time I have a spare moment. Pretty cool library otherwise.
Oh and uh...I've not seen it spelled "CollectEr" before, only "CollectOr"...is that a regional thing?
Hi,
I really like this library.
The only thing I am missing is syntax highlighting for codeblocks.
It would be really nice to make that possible in the future.
Hi, we are using this library in an application we are developing. Due to some requirements, we had to use version 11.0.0-preview4
of Avalonia
. However, this time some of our features started to not work. So we would be very happy if you can provide compatibility with version 11.0.0-preview4
of Avalonia
.
related AvaloniaCommunity/MessageBox.Avalonia#105
Are stackframes not obtained with NativeAOT?
Is there a way to customize the bitmap loader ?
Mainly, I would like to my markdown document remotely and would like to ensure to not load image from other domains (cross site referencing)
About Q2
It is bug that codeblock can not be included in list.
Not support starting ordered lists at an arbitrary number is not specification violation.
But supporting is allowed, so I may support it.
Originally posted by @whistyun in #38 (comment)
If you encountered the same condition when I tap "backspace" key in one kind of input aid software to input something for a TextBox etc, the letter was deleted while a letter in the TextBox also disappeared! Do you know how to fix it?
For programmatically generated MD string it is very usefull to feed not only external images from URI or app resources, but from inmemory image - for example I want to add LiveCharts chart as image, but have no find options to feed these kind or images as source.
It is possible to save temp image and feed it to MD as a local image, but it is not a good solution.
I have an app under development that uses your extension. It works great when the target framework is generic net6.0. When I change the target framework to net6.0-macos, following exception was thrown during run time.
When I comment out the code that uses markdown, the exception was gone.
Is there any workaround for this?
Thanks.
see #18
For now we can't customize placement of CCode etc within that line.
Add new 'VerticalAlignment' style is required.
I consider the implementation along with the line spacing (or TextBlock.LineHeight).
Maybe there needs a contrast table to show how to custom the style, for example, offer lines of code and an image of the real effect. In this way, users may have a direct feeling about how to custom the style of the control.
---------------------------------------------------------------------
<style> |
···· | an image to show effect
</style> |
---------------------------------------------------------------------
I have installed the 11.0.0-a9 (nuget couldn't find a10) version which should be compatible with Avalonia 11.0.0-preview5 and i'm using .NET 7.0 (6.0 didn't work too) on Fedora 37 Linux.
I have tried to bind the strings from my project inside of ListBox DataTemplate but there was nothing instead of markdown view.
Then i created an empty project and pasted the example from wiki but it just rendered some plaintext mess. It was unselectable as the md view should be as i read there. I have tried Simple theme instead of Fluent but that didn't help.
The only warning i got is some old package for .NET Framework was installed:
/home/zero/dev/CSharp/Avalonia/TestMarkdown/TestMarkdown.csproj : warning NU1701: Package 'HarfBuzzSharp.NativeAssets.Linux 2.8.2.1-preview.108' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8, .NETFramework,Version=v4.8.1' instead of the project target framework 'net7.0'. This package may not be fully compatible with your project.
/home/zero/dev/CSharp/Avalonia/TestMarkdown/TestMarkdown.csproj : warning NU1701: Package 'HarfBuzzSharp.NativeAssets.macOS 2.8.2.1-preview.108' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8, .NETFramework,Version=v4.8.1' instead of the project target framework 'net7.0'. This package may not be fully compatible with your project.
/home/zero/dev/CSharp/Avalonia/TestMarkdown/TestMarkdown.csproj : warning NU1701: Package 'HarfBuzzSharp.NativeAssets.Win32 2.8.2.1-preview.108' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8, .NETFramework,Version=v4.8.1' instead of the project target framework 'net7.0'. This package may not be fully compatible with your project.
see #30 (comment)
see #4
Now version is not set style to line (eg '---' '***' ).
Avalonia just released Avalonia 11.0.0-preview5. Any plans to support it?
As the new RC is bringing assemblies with strong name, packages need to be generated against those 'new' references.
Markdown Avalonia doesn't support Unicode and emojis.
Text: 💡
Result:
Version: 0.10.4
Might related to AvaloniaUI/Avalonia#4893
Is there any way to adjust language detection for code blocks? For example, I want both js
and javascript
to be rendered using JavaScript syntax highlighting, but currently only one works.
see #4
If it can be exposed the hyperlink mouse hover and leave after clicked effect could be more appreciate.
Hi! I'm currently developing an Avalonia app that has support for multiple themes. The main window shows the CHANGELOG of the application parsing the current .md thats hosted in the web.
Heres the xaml:
<ScrollViewer Background="{DynamicResource SolidBackgroundFillColorBaseBrush}">
<ScrollViewer.Styles>
<Style Selector="ctxt|CTextBlock.Heading1">
<Setter Property="Foreground" Value="{DynamicResource DefaultTextForegroundThemeBrush}"/>
</Style>
</ScrollViewer.Styles>
<md:MarkdownScrollViewer
Margin="5"
Source="https://chemistry-tools.netlify.app/CHANGELOG.md"/>
</ScrollViewer>
The problem is when I change the theme to dark, the foreground color of the Headings doesn't change. This is weird because all the others do change. I tried creating a style but even though avalonia recognizes that my styles exist, it doesn't apply it.
Light theme (for reference):
Dark Theme (the headings do not change color):
The avalonia debugger shows the styles are recognized for the correct element but are not applied:
If someone knows a workaround or can help point in the right direction would be greatly appreciated.
How do I force a new line?
I have tried using these already and they don't work:
<br />
2 spaces at the end
/
/s
With the new a2 version:
System.IO.FileNotFoundException: Could not load file or assembly 'ColorTextBlock.Avalonia, Version=11.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
File name: 'ColorTextBlock.Avalonia, Version=11.0.0.0, Culture=neutral, PublicKeyToken=null'
For example, if Markdown is created in method called via Avalonia method binding, there is a dynamically compiled method in the stack trace (the method compiled by MethodToCommandConverter.CreateExecute ). This method have no declaring type, thus we have a NullReferenceException
Embedded styles foreground and background are set hardcode color.
If I use dark theme, some text is not visible.
Even if we set 'https://raw.githubusercontent.com/whistyun/Markdown.Avalonia/master/README.md' to this property, Markdown.Avalonia get no images.
I think AssetPathRoot
should be updated based on Source
when I bind a Textbox control to update the Markdown Text, it leads to an exception.
usage:
public void TextChanged(object sender, AvaloniaPropertyChangedEventArgs e) { if (e.Property.Name.Equals("Text")) { // Vector old = markdownPreview.ScrollValue; markdownPreview.Markdown = this.inputTbx.Text; // markdownPreview.ScrollValue = new Vector(old.X, old.Y); } }
exception:
Unhandled exception. Avalonia.AvaloniaInternalException: Value could not be found at the end of batch update. at Avalonia.ValueStore.BatchUpdate.End() in /_/src/Avalonia.Base/ValueStore.cs:line 410 at Avalonia.ValueStore.EndBatchUpdate() in /_/src/Avalonia.Base/ValueStore.cs:line 52 at Avalonia.AvaloniaObject.EndBatchUpdate() in /_/src/Avalonia.Base/AvaloniaObject.cs:line 473 at Avalonia.StyledElement.DetachStyles() in /_/src/Avalonia.Styling/StyledElement.cs:line 777 at Avalonia.StyledElement.OnDetachedFromLogicalTreeCore(LogicalTreeAttachmentEventArgs e) in /_/src/Avalonia.Styling/StyledElement.cs:line 695 at Avalonia.StyledElement.OnDetachedFromLogicalTreeCore(LogicalTreeAttachmentEventArgs e) in /_/src/Avalonia.Styling/StyledElement.cs:line 701 at Avalonia.StyledElement.Avalonia.Controls.ISetLogicalParent.SetParent(ILogical parent) in /_/src/Avalonia.Styling/StyledElement.cs:line 434 at Avalonia.StyledElement.ClearLogicalParent(IList children) in /_/src/Avalonia.Styling/StyledElement.cs:line 745 at Avalonia.StyledElement.LogicalChildrenCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e) in /_/src/Avalonia.Styling/StyledElement.cs:line 507 at Avalonia.Visual.LogicalChildrenCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e) in /_/src/Avalonia.Visuals/Visual.cs:line 381 at Avalonia.Collections.AvaloniaList
1.NotifyRemove(T item, Int32 index) in //src/Avalonia.Base/Collections/AvaloniaList.cs:line 724
at Avalonia.Collections.AvaloniaList1.Remove(T item) in /_/src/Avalonia.Base/Collections/AvaloniaList.cs:line 470 at Avalonia.Controls.ContentControl.ContentChanged(AvaloniaPropertyChangedEventArgs e) in /_/src/Avalonia.Controls/ContentControl.cs:line 124 at Avalonia.Controls.ContentControl.<>c.<.cctor>b__4_0(ContentControl x, AvaloniaPropertyChangedEventArgs e) in /_/src/Avalonia.Controls/ContentControl.cs:line 43 at Avalonia.AvaloniaObjectExtensions.<>c__DisplayClass23_0
1.b__0(AvaloniaPropertyChangedEventArgs e) in //src/Avalonia.Base/AvaloniaObjectExtensions.cs:line 585
at System.Reactive.AnonymousObserver1.OnNextCore(T value) in /_/Rx.NET/Source/src/System.Reactive/AnonymousObserver.cs:line 67 at System.Reactive.ObserverBase
1.OnNext(T value) in //Rx.NET/Source/src/System.Reactive/ObserverBase.cs:line 36
at System.Reactive.Subjects.Subject1.OnNext(T value) in /_/Rx.NET/Source/src/System.Reactive/Subjects/Subject.cs:line 147 at Avalonia.AvaloniaObject.RaisePropertyChanged[T](AvaloniaPropertyChangedEventArgs
1 change) in //src/Avalonia.Base/AvaloniaObject.cs:line 758
at Avalonia.AvaloniaObject.Avalonia.PropertyStore.IValueSink.ValueChanged[T](AvaloniaPropertyChangedEventArgs1 change) in /_/src/Avalonia.Base/AvaloniaObject.cs:line 531 at Avalonia.ValueStore.NotifyValueChanged[T](AvaloniaProperty
1 property, Optional1 oldValue, BindingValue
1 newValue, BindingPriority priority) in //src/Avalonia.Base/ValueStore.cs:line 367
at Avalonia.ValueStore.SetExisting[T](Object slot, StyledPropertyBase1 property, T value, BindingPriority priority) in /_/src/Avalonia.Base/ValueStore.cs:line 285 at Avalonia.ValueStore.SetValue[T](StyledPropertyBase
1 property, T value, BindingPriority priority) in //src/Avalonia.Base/ValueStore.cs:line 109
at Avalonia.AvaloniaObject.SetValue[T](StyledPropertyBase1 property, T value, BindingPriority priority) in /_/src/Avalonia.Base/AvaloniaObject.cs:line 368 at Avalonia.Controls.ContentControl.set_Content(Object value) in /_/src/Avalonia.Controls/ContentControl.cs:line 54 at Markdown.Avalonia.MarkdownScrollViewer.UpdateMarkdown() at Markdown.Avalonia.MarkdownScrollViewer.set_Markdown(String value) at MarkDownAvalonia.MainWindow.TextChanged(Object sender, AvaloniaPropertyChangedEventArgs e) in /Users/dxm/code/personalCode/markdownsharp/MarkDownAvalonia/MarkDownAvalonia/MainWindow.xaml.cs:line 463 at Avalonia.AvaloniaObject.RaisePropertyChanged[T](AvaloniaPropertyChangedEventArgs
1 change) in //src/Avalonia.Base/AvaloniaObject.cs:line 760
at Avalonia.AvaloniaObject.RaisePropertyChanged[T](AvaloniaProperty1 property, Optional
1 oldValue, BindingValue1 newValue, BindingPriority priority) in /_/src/Avalonia.Base/AvaloniaObject.cs:line 676 at Avalonia.AvaloniaObject.SetAndRaise[T](AvaloniaProperty
1 property, T& field, T value) in //src/Avalonia.Base/AvaloniaObject.cs:line 701
at Avalonia.Controls.TextBox.SetTextInternal(String value) in //src/Avalonia.Controls/TextBox.cs:line 1215
at Avalonia.Controls.TextBox.HandleTextInput(String input) in //src/Avalonia.Controls/TextBox.cs:line 552
at Avalonia.Controls.TextBox.OnTextInput(TextInputEventArgs e) in //src/Avalonia.Controls/TextBox.cs:line 519
at Avalonia.Input.InputElement.<>c.<.cctor>b__30_4(InputElement x, TextInputEventArgs e) in //src/Avalonia.Input/InputElement.cs:line 204
at System.Reactive.Subjects.Subject`1.OnNext(T value) in //Rx.NET/Source/src/System.Reactive/Subjects/Subject.cs:line 147
at Avalonia.Interactivity.EventRoute.RaiseEventImpl(RoutedEventArgs e) in //src/Avalonia.Interactivity/EventRoute.cs:line 148
at Avalonia.Interactivity.EventRoute.RaiseEvent(IInteractive source, RoutedEventArgs e) in //src/Avalonia.Interactivity/EventRoute.cs:line 102
at Avalonia.Interactivity.Interactive.RaiseEvent(RoutedEventArgs e) in //src/Avalonia.Interactivity/Interactive.cs:line 120
at Avalonia.Input.KeyboardDevice.ProcessRawEvent(RawInputEventArgs e) in //src/Avalonia.Input/KeyboardDevice.cs:line 245
at Avalonia.Input.InputManager.ProcessInput(RawInputEventArgs e) in //src/Avalonia.Input/InputManager.cs:line 36
at Avalonia.Controls.TopLevel.HandleInput(RawInputEventArgs e) in //src/Avalonia.Controls/TopLevel.cs:line 477
at Avalonia.Native.WindowBaseImpl.RawTextInputEvent(UInt32 timeStamp, String text) in //src/Avalonia.Native/WindowImplBase.cs:line 263
at Avalonia.Native.WindowBaseImpl.WindowBaseEvents.Avalonia.Native.Interop.IAvnWindowBaseEvents.RawTextInputEvent(UInt32 timeStamp, String text) in //src/Avalonia.Native/WindowImplBase.cs:line 202
at Avalonia.Native.Interop.Impl.__MicroComIAvnWindowBaseEventsVTable.RawTextInputEvent(IntPtr this, UInt32 timeStamp, Byte* text) in //src/Avalonia.Native/Interop.Generated.cs:line 3217
--- End of stack trace from previous location where exception was thrown ---
at Avalonia.Native.PlatformThreadingInterface.RunLoop(CancellationToken cancellationToken) in //src/Avalonia.Native/PlatformThreadingInterface.cs:line 92
at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken) in //src/Avalonia.Base/Threading/Dispatcher.cs:line 62
at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.Start(String[] args) in //src/Avalonia.Controls/ApplicationLifetimes/ClassicDesktopStyleApplicationLifetime.cs:line 117
at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime[T](T builder, String[] args, ShutdownMode shutdownMode) in //src/Avalonia.Controls/ApplicationLifetimes/ClassicDesktopStyleApplicationLifetime.cs:line 148
at MarkDownAvalonia.Program.Main(String[] args) in /Users/dxm/code/personalCode/markdownsharp/MarkDownAvalonia/MarkDownAvalonia/Program.cs:line 13
`
i'm trying to render some markdown document which contains image, but this is behaving weirdly.
As example, when rendering https://github.com/AvaloniaUI/Avalonia/wiki/Projects-that-are-using-Avalonia
The images are not fitting the current window with and it seems weird from user point of view :
see #4
Hello, non-breaking space does not work. I've tried  
What are the ways to resolve?
That's for case when doc is relatively small and it contains a code-block. Since TextEditor
has its own ScrollBar
it leads to displaying 2 ScrollBars
.
Can this dependency be removed? Seems like a bit overkill to include that in a tight markdown library?
Actual Behavior:
Expected Behavior:
Steps to reproduce:
What that means for my use case:
I am building a flash card learning program
The cards content is md, drawn using Markdown.Avalonia
One type of card is used to learn guitar tabs and chords, as a type of ascii art
Hint: the tabs can get much more complicated and its impossible to read the tabs in that case - in the above example it does not seem to be a big issue
The tabs and chords are drawn in ascii representation
The tabs and chords are impossible to use without mono spaced fonts
Workaround:
Maybe there needs a horizonal scroll bar when input more words in the direction of horizon. Now is hidden in the tag "```"
Originally posted by @dayAndnight2018 in #38 (comment)
I want to write annotations in CodeBlock, set the fontfamily style and MonospaceFontFamily style but no work.
Question 1:
when I use ">" to perform a break line, it not work. if I add a blank line between ">" lines, it looks ugly.
Question 2:
if it is needed to support padding when I use a “to show codes
” under a list item? otherwise, it looks ugly, too! when I use "code
" under a list item, it also blocks the number to be auto increment as what shows in the following picture.
The MarkdownScrollViewer
control throws InvalidOperationException
when using custom themes.
Here's my App.xaml
:
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:metro="clr-namespace:Ruminoid.Common2.Metro;assembly=rmnd-metro"
x:Class="Ruminoid.Toolbox.Shell.App">
<Application.Styles>
<metro:RuminoidMetro/> <!-- My custom RuminoidMetro style class -->
<StyleInclude Source="/Controls/Styles/Generic.xaml"/> <!-- My project xaml file -->
</Application.Styles>
</Application>
And when constructing MarkdownScrollViewer
control, the ThemeDetector
class skipped the RuminoidMetro
class (√) and tried to get the Host
of my local xaml file in project (x).
Exception:
System.InvalidOperationException: This operation is not supported for a relative URI.
at System.Uri.get_Host()
at Markdown.Avalonia.Utils.ThemeDetector.get_IsFluentUsed()
at Markdown.Avalonia.MarkdownScrollViewer..ctor()
at Ruminoid.Toolbox.Plugins.Common.ConfigSections.Views.IntroConfigSection.!XamlIlPopulate(IServiceProvider , IntroConfigSection ) in D:\Projects\rmnd\Toolbox\plugins\rmbox-plugin-common\ConfigSections/Views/IntroConfigSection.axaml:line 1
at Ruminoid.Toolbox.Plugins.Common.ConfigSections.Views.IntroConfigSection.!XamlIlPopulateTrampoline(IntroConfigSection )
at Ruminoid.Toolbox.Plugins.Common.ConfigSections.Views.IntroConfigSection.InitializeComponent() in D:\Projects\rmnd\Toolbox\plugins\rmbox-plugin-common\ConfigSections\Views\IntroConfigSection.axaml.cs:line 29
at Ruminoid.Toolbox.Plugins.Common.ConfigSections.Views.IntroConfigSection..ctor(JToken sectionConfig) in D:\Projects\rmnd\Toolbox\plugins\rmbox-plugin-common\ConfigSections\Views\IntroConfigSection.axaml.cs:line 24
QuickWatch window:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.