whistyun / Markdown.Avalonia

render markdown with Avalonia UI
MIT License
294 stars 22 forks source link

recommend #30

Closed dayAndnight2018 closed 3 years ago

dayAndnight2018 commented 3 years ago

recommend to support relative path of the image to render:

image

whistyun commented 3 years ago

Relative path is already supported (default, the current directory is root).

Did you run it on Mac? and did you start appliction from .app file? It is a story on an unix-like system instead of Mac, however if we start application by clicking the executable file. the current directory will be the home directory (~/).

I provide MarkdownScrollViewer.AssetPathRoot. You can change root by setting this property to the directory path.

dayAndnight2018 commented 3 years ago

Relative path is already supported (default, the current directory is root).

Did you run it on Mac? and did you start appliction from .app file? It is a story on an unix-like system instead of Mac, however if we start application by clicking the executable file. the current directory will be the home directory (~/).

I provide MarkdownScrollViewer.AssetPathRoot. You can change root by setting this property to the directory path.

great!

dayAndnight2018 commented 3 years ago

Besides, I want to complain about the render of the markdownpreviewer control. when the textbox's content changes, the markdownpreviewer render again and scroll to the top of content, could we only refresh content with no scroll? Or if we could bind the relative location between the input textbox and markdownPreview?

image

dayAndnight2018 commented 3 years ago

and why it auto wrap?

image

whistyun commented 3 years ago

could we only refresh content with no scroll?

I'm checking the API reference, I may be able to add properties for providing scroll saving property and scroll value property.

Or if we could bind the relative location between the input textbox and markdownPreview?

There is no method. TextBox is not provide property to get scroll value. For current Avalonia version, I can only support the first question.

whistyun commented 3 years ago

and why it auto wrap?

MarkdownScrollViewer uses FormattedText to check all text elements whether wrapping is required.

It's looks like character-based wrapping like Chinese and Japanese is not considered in Avalonia, which results in line breaks at unexpected positions.

image

For now, I'm not sure if I should ignore the behavior of Avalonia and implement wrap-processing myself.

dayAndnight2018 commented 3 years ago

could we only refresh content with no scroll?

I'm checking the API reference, I may be able to add properties for providing scroll saving property and scroll value property.

Or if we could bind the relative location between the input textbox and markdownPreview?

There is no method. TextBox is not provide property to get scroll value. For current Avalonia version, I can only support the first question.

Ok! Thanks

dayAndnight2018 commented 3 years ago

and why it auto wrap?

MarkdownScrollViewer uses FormattedText to check all text elements whether wrapping is required.

It's looks like character-based wrapping like Chinese and Japanese is not considered in Avalonia, which results in line breaks at unexpected positions.

image

For now, I'm not sure if I should ignore the behavior of Avalonia and implement wrap-processing myself.

Thanks, anyway

whistyun commented 3 years ago

could we only refresh content with no scroll?

I'm checking the API reference, I may be able to add properties for providing scroll saving property and scroll value property.

Or if we could bind the relative location between the input textbox and markdownPreview?

There is no method. TextBox is not provide property to get scroll value. For current Avalonia version, I can only support the first question.

Ok! Thanks

In v0.10.0-a9 and v0.9.0-a9, I add new property 'SaveScrollValueWhenContentUpdated' and ScrollValue to MarkdownScrollViewer The first property save scroll value even if scroll changed. The second property change scroll value. If you reflesh content, please set expected initial scroll value to it.

View:

<md:MarkdownScrollViewer
    SaveScrollValueWhenContentUpdated="True"
    ScrollValue="{Binding ScrollValueInitial}"
    />

ViewModel (ReactiveUI):

public Vector ScrollValueInitial => new Vector(0, 0);
...
public void LoadNewMarkdown(){
    // Load some markdown content...
    ...
    // Reset Scroll Value
    this.RaisePropertyChanged(nameof(ScrollValueInitial));
}
dayAndnight2018 commented 3 years ago

could we only refresh content with no scroll?

I'm checking the API reference, I may be able to add properties for providing scroll saving property and scroll value property.

Or if we could bind the relative location between the input textbox and markdownPreview?

There is no method. TextBox is not provide property to get scroll value. For current Avalonia version, I can only support the first question.

Ok! Thanks

In v0.10.0-a9 and v0.9.0-a9, I add new property 'SaveScrollValueWhenContentUpdated' and ScrollValue to MarkdownScrollViewer The first property save scroll value even if scroll changed. The second property change scroll value. If you reflesh content, please set expected initial scroll value to it.

View:

<md:MarkdownScrollViewer
    SaveScrollValueWhenContentUpdated="True"
    ScrollValue="{Binding ScrollValueInitial}"
    />

ViewModel (ReactiveUI):

public Vector ScrollValueInitial => new Vector(0, 0);
...
public void LoadNewMarkdown(){
    // Load some markdown content...
    ...
    // Reset Scroll Value
    this.RaisePropertyChanged(nameof(ScrollValueInitial));
}

Hi, there has another quest:

image

dayAndnight2018 commented 3 years ago

I search on the Internet about markdown code rules, it not support this character, but I recommend that two and more blank lines, We could translate to N-1 blank lines (N is blank lines, one for break a paragraph, N -1 for blank lines).

whistyun commented 3 years ago

Hm... I think enhance syntax have to be more clear. Some people insert empty line to change section. and may not mind the number of empty line.

For example, Insert 1 blank line in chapter and Insert 2 blank lines before header.

## Chapter 1
some text
some text

some text
some text

## Chapter2
some text
some text

It should be unified with the line breaks in the table cells that have already been implemented, but I think it is better to specify the line breaks with \n or<br>.

dayAndnight2018 commented 3 years ago

Hm... I think enhance syntax have to be more clear. Some people insert empty line to change section. and may not mind the number of empty line.

For example, Insert 1 blank line in chapter and Insert 2 blank lines before header.

## Chapter 1
some text
some text

some text
some text

## Chapter2
some text
some text

It should be unified with the line breaks in the table cells that have already been implemented, but I think it is better to specify the line breaks with \n or<br>.

If we introduce html style tag like <br> or plain text style tag '\n', it could pollute the markdown text.

dayAndnight2018 commented 3 years ago

Hm... I think enhance syntax have to be more clear. Some people insert empty line to change section. and may not mind the number of empty line.

For example, Insert 1 blank line in chapter and Insert 2 blank lines before header.

## Chapter 1
some text
some text

some text
some text

## Chapter2
some text
some text

It should be unified with the line breaks in the table cells that have already been implemented, but I think it is better to specify the line breaks with \n or<br>.

In my opinions, one blank line is enough to tell a paragraph. If we could support it, it would be more convenient.

whistyun commented 3 years ago

About <br>, It is implemented on Github, and We can avoid to treat \
as line break using backslash. In addition, many user realise it

If I implement to leave a blank line as a vertical align space, It difficult to provide a workaround for those who don't want it and want to leave a blank line for markdown readability.

dayAndnight2018 commented 3 years ago

About <br>, It is implemented on Github, and We can avoid to treat
as line break using backslash. In addition, many user realise it

If I implement to leave a blank line as a vertical align space, It difficult to provide a workaround for those who don't want it and want to leave a blank line for markdown readability.

maybe, you are right. but i still think it will pollute the style of markdown if an html style tag introduced in.

whistyun commented 3 years ago

Probably, the discussion will not solve it, so I think that there is only choice to provide an option; not reduce space duplication and line break duplication.

By the way, Markdown.Avalonia provides some extension syntaxes, which are not standard Markdown. (Partial extensions explain on document. and you can look all preview in README.MD) Do you have any thoughts about them?

dayAndnight2018 commented 3 years ago

Probably, the discussion will not solve it, so I think that there is only choice to provide an option; not reduce space duplication and line break duplication.

By the way, Markdown.Avalonia provides some extension syntaxes, which are not standard Markdown. (Partial extensions explain on document. and you can look all preview in README.MD) Do you have any thoughts about them?

It's nice to have so much thought. In my opinion, I may not need these styles for the time being. In many web versions of markdown parsing tools, they often provide additional buttons to achieve alignment, merge cell operations, etc., rather than relying on parsing syntax.

dayAndnight2018 commented 3 years ago

Probably, the discussion will not solve it, so I think that there is only choice to provide an option; not reduce space duplication and line break duplication.

By the way, Markdown.Avalonia provides some extension syntaxes, which are not stan, dard Markdown. (Partial extensions explain on document. and you can look all preview in README.MD) Do you have any thoughts about them?

So, How to add more blank lines to markdownScrollViewer?

dayAndnight2018 commented 3 years ago

Probably, the discussion will not solve it, so I think that there is only choice to provide an option; not reduce space duplication and line break duplication.

By the way, Markdown.Avalonia provides some extension syntaxes, which are not standard Markdown. (Partial extensions explain on document. and you can look all preview in README.MD) Do you have any thoughts about them?

I have an option to support more blank lines with a property, for example it is defalt set "false" to behave not to add blank lines and "true" to behave to add blank lines.

whistyun commented 3 years ago

I'm not going to add any options for parsing to the MarkdownScrollViewer. It accepts an another markdown parse engine which may be not support that option.

I'm going to make new a markdown parse engine FlexibleMarkdown. FlexibleMarkdown has switching options for linebreak and other extensions(all options default is false).

dayAndnight2018 commented 3 years ago

I'm not going to add any options for parsing to the MarkdownScrollViewer. It accepts an another markdown parse engine which may be not support that option.

I'm going to make new a markdown parse engine FlexibleMarkdown. FlexibleMarkdown has switching options for linebreak and other extensions(all options default is false).

Looking forward to your new pushes!