Skip to content

How to use Enhanched syntax

whistyun edited this page Jul 13, 2023 · 4 revisions

Text decolation (Include proprietary adaptations)

Markdown.Avalonia support italic, bold, strikethrough, underline, and color text.

Below table shows each idioms.

Example

Name           |Type       |Format                      
---------------|-----------|----------------------------
italic         |Standard   | *italic*
bold           |Standard   | **bold**
bold-italic    |Standard   | ***bold-italic***
strikethrough  |Standard   | ~~strikethrough~~
underline      |Proprietary| __underline__
color-text(1)  |Proprietary| %{color:red}colortext%
color-text(2)  |Proprietary| %{color:#00FF00}colortext%
bgcolor-text(1)|Proprietary| %{background:red}colortext%
bgcolor-text(2)|Proprietary| %{background:#FF00FF}colortext%
color&bgcolor  |Proprietary| %{color:red; background:yellow}colortext%

text_deco

Text alignment (Proprietary adaptations)

Markdown.Avalonia support text-alignment. It is base on textile.

  • If put 'p<.' to paragraph-start, Markdown.Avalonia arrange paragraph left-side.
  • If put 'p>.' to paragraph-start, Markdown.Avalonia arrange paragraph right-side.
  • If put 'p=.' to paragraph-start, Markdown.Avalonia arrange paragraph center.

Example

p<. arrange paragraph left-side.

p>. arrange paragraph right-side.

p=. arrange paragraph center.  
p=>. inner paragraph is ignored.

text_alignment

List

#### alphabet-ol (Proprietary adaptations)
a. one
b. two

#### alphabet-ol (Proprietary adaptations)
A. one
B. two

#### roman-ol (Proprietary adaptations)
i, one
ii, two

#### roman-ol (Proprietary adaptations)
I, one
II, two

list

Table

linebreak (Proprietary adaptations)

Markdown.Avalonia treats '\n' which is contained in the cell of tables as linebreak. If you don't want it, use escape sequence.

Example

| column1\nwith linebreak     | column2       |
|-----------------------------|---------------|
| text\nwith\nlinebreak       | text\\nnobreak|

view1

colspan or rowspan (Proprietary adaptations)

Markdown.Avalonia extends table format to explain colspan and rowspan. Its format is Influenced by textile.

Example

| column1     | column2       | column4       | column5  |
|-------------|---------------|---------------|----------|
|\2. colspan2                 |/3\2. row3&col2           |
|/2. rowspan2 |<. left-algn   |
              |=. center-algn |
| hoge        |>. right-align | hoge          | hoge     |

view1

Format

Type any character between pipe(|) and period(.), and Markdown.Avalonia parse it.

char details
\ column span: after character parse as the number as columns.
/ row span: after character parse as the number as rows.
< left alignment
> right alignment
= center

If you don't want to parse, type space after pipe(|).

| column1     | column2       |
|-------------|---------------|
|\2. parse as column span     |
| \2. ignore  | hoge          |

view2

Horizontal rule (Proprietary adaptations)

Markdown.Avalonia provide four type rules (---, ===, *** and ___). ---, *** and ___ are provided with standard. However Markdown.Avalonia render theirs with different looks.

single line
 ---
two lines
 ===
bold line
 ***
bold with single
___

Note (Proprietary adaptations)

< notetext >

some text

<p>. notetext

ContainerBlock

This is partial support of https://talk.commonmark.org/t/generic-directives-plugins-syntax/444. This feature allows to expand markdown functionality with pluggable content handling.

Markdown syntax

::: plugin_name
some lines
:::

How to setup

How to create a container block handler

using Markdown.Avalonia.Utils;
class MyBlockHandler1 : IContainerBlockHandler
{
    public Border ProvideControl(string assetPathRoot, string blockName, string lines)
    {
        return new Border()
        {
            Child = new Button()
            {
                Content = $"MyBlockHandler1[{blockName}]\nlines[{lines}]"
            }
        };
    }
}

class MyBlockHandler2 : IContainerBlockHandler
{
    public Border ProvideControl(string assetPathRoot, string blockName, string lines)
    {
        return new Border()
        {
            Child = new TextBox()
            {
                Text = $"MyBlockHandler2[{blockName}]\nlines[{lines}]"
            }
        };
    }
}

How to include container block handlers

<md:MarkdownScrollViewer>
    <md:MarkdownScrollViewer.Engine>
        <md:Markdown>
            <md:Markdown.ContainerBlockHandler>
                <md:ContainerSwitch>
                    <markdownEx:MyBlockHandler1 x:Key="plugin_name1"/>
                    <markdownEx:MyBlockHandler2 x:Key="plugin_name2"/>
                </md:ContainerSwitch>
            </md:Markdown.ContainerBlockHandler>
        </md:Markdown>
    </md:MarkdownScrollViewer.Engine>
</md:MarkdownScrollViewer>

demo

ChatAI mode

Markdown.Avalonia has a build-in plugin for ChatGPT; ChatAISetup.

This plugin disables some ehnaced syntax and enable code pre-rendering.

How to setup

<!-- 
  xmlns:md=
    "https://github.com/whistyun/Markdown.Avalonia"
    or
    "https://github.com/whistyun/Markdown.Avalonia.Tight"

  xmlns:mdt=
    "https://github.com/whistyun/Markdown.Avalonia.Tight"
-->

<md:MarkdownScrollViewer>
  <md:MarkdownScrollViewer.Plugins>
    <md:MdAvPlugins>
      <mdt:ChatAISetup/>
    </md:MdAvPlugins>
  </md:MarkdownScrollViewer.Plugins>
</md:MarkdownScrollViewer>