Skip to content

Commit 42b0689

Browse files
committed
Markdown - demos - descriptions added.
1 parent bd02d50 commit 42b0689

File tree

5 files changed

+84
-35
lines changed

5 files changed

+84
-35
lines changed

BlazorBootstrap.Demo.RCL/Components/Pages/Markdown/MarkdownDocumentation.razor

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,43 +11,66 @@
1111

1212
<SectionHeading Size="HeadingSize.H2" Text="Live preview" PageUrl="@pageUrl" HashTagName="live-preview" />
1313
<div class="mb-3"></div>
14-
<Demo Type="typeof(Markdown_Demo_00_Preview)" Tabs="true" />
15-
16-
<SectionHeading Size="HeadingSize.H2" Text="Examples" PageUrl="@pageUrl" HashTagName="examples" />
17-
<div class="mb-3"></div>
18-
<Demo Type="typeof(Markdown_Demo_01_Examples)" Tabs="true" />
14+
<Demo Type="typeof(Markdown_Demo_01_Preview)" Tabs="true" />
1915

2016
<SectionHeading Size="HeadingSize.H2" Text="Headers" PageUrl="@pageUrl" HashTagName="headers" />
21-
<div class="mb-3"></div>
17+
<div class="mb-3">
18+
Use headers to structure your content. Start a line with `#` for a heading. Add more `#` characters for subheadings, up to six levels.
19+
</div>
2220
<Demo Type="typeof(Markdown_Demo_02_Headers)" Tabs="true" />
2321

2422
<SectionHeading Size="HeadingSize.H2" Text="Paragraphs and line breaks" PageUrl="@pageUrl" HashTagName="paragraphs-and-line-breaks" />
25-
<div class="mb-3"></div>
23+
<div class="mb-3">
24+
Break your text into paragraphs or line breaks for easier reading.
25+
</div>
2626
<Demo Type="typeof(Markdown_Demo_03_Paragraphs_and_Line_Breaks)" Tabs="true" />
2727

2828
<SectionHeading Size="HeadingSize.H2" Text="Blockquotes" PageUrl="@pageUrl" HashTagName="blockquotes" />
29-
<div class="mb-3"></div>
29+
<div class="mb-3">
30+
Quote text with `>` before it. Use more `>` characters to nest quotes. For blocks of text, use `>` at the start of each line.
31+
</div>
3032
<Demo Type="typeof(Markdown_Demo_04_Blockquotes)" Tabs="true" />
3133

3234
<SectionHeading Size="HeadingSize.H2" Text="Horizontal rules" PageUrl="@pageUrl" HashTagName="horizontal-rules" />
33-
<div class="mb-3"></div>
35+
<div class="mb-3">
36+
Add a horizontal rule with a line of `---`.
37+
</div>
3438
<Demo Type="typeof(Markdown_Demo_05_Horizontal_Rules)" Tabs="true" />
3539

3640
<SectionHeading Size="HeadingSize.H2" Text="Emphasis (bold, italics, strikethrough)" PageUrl="@pageUrl" HashTagName="emphasis-bold-italics-strikethrough" />
37-
<div class="mb-3"></div>
41+
<div class="mb-3">
42+
Emphasize text with bold, italics, or strikethrough: <br />
43+
- Italics: `*text*` or `_text_` <br />
44+
- Bold: `**text**` <br />
45+
- Strikethrough: `~~text~~` <br />
46+
- Combine for more emphasis.
47+
</div>
3848
<Demo Type="typeof(Markdown_Demo_06_Emphasis_bold_italics_strikethrough)" Tabs="true" />
3949

4050
<SectionHeading Size="HeadingSize.H2" Text="Code highlighting" PageUrl="@pageUrl" HashTagName="code-highlighting" />
4151
<div class="mb-3"></div>
4252
<Demo Type="typeof(Markdown_Demo_07_Code_Highlighting)" Tabs="true" />
4353

4454
<SectionHeading Size="HeadingSize.H2" Text="Tables" PageUrl="@pageUrl" HashTagName="tables" />
45-
<div class="mb-3"></div>
55+
<div class="mb-3">
56+
Tables help organize structured data. <br />
57+
- Place each row on its own line. <br />
58+
- Separate cells with `|`. Escape `|` with `\|` if used within a cell. <br />
59+
- The first two lines set headers and alignment. <br />
60+
- Use `<br />` for new lines within a cell. <br />
61+
- End each row with a carriage return (CR) or line feed (LF). <br />
62+
</div>
4663
<Demo Type="typeof(Markdown_Demo_08_Tables_A_Example)" Tabs="true" />
4764
<div class="mb-3"></div>
4865
<Demo Type="typeof(Markdown_Demo_08_Tables_B_Custom_CssClass)" Tabs="true" />
4966

5067
<SectionHeading Size="HeadingSize.H2" Text="Lists" PageUrl="@pageUrl" HashTagName="lists" />
68+
<div class="mb-3">
69+
Use lists to organize related items: <br />
70+
- Ordered lists: start with a number followed by a period. <br />
71+
- Unordered lists: start with a `-`. <br />
72+
Begin each list item on a new line.
73+
</div>
5174
<SectionHeading Size="HeadingSize.H3" Text="Ordered list" PageUrl="@pageUrl" HashTagName="ordered-list" />
5275
<div class="mb-3"></div>
5376
<Demo Type="typeof(Markdown_Demo_09_Lists_A_Ordered)" Tabs="true" />
@@ -72,6 +95,10 @@
7295
<div class="mb-3"></div>
7396
<Demo Type="typeof(Markdown_Demo_11_Images)" Tabs="true" />
7497

98+
<SectionHeading Size="HeadingSize.H2" Text="Examples" PageUrl="@pageUrl" HashTagName="examples" />
99+
<div class="mb-3"></div>
100+
<Demo Type="typeof(Markdown_Demo_99_Examples)" Tabs="true" />
101+
75102
@code{
76103
private string pageUrl = "/markdown";
77104
private string title = "Blazor Markdown Component";

BlazorBootstrap.Demo.RCL/Components/Pages/Markdown/Markdown_Demo_00_Preview.razor renamed to BlazorBootstrap.Demo.RCL/Components/Pages/Markdown/Markdown_Demo_01_Preview.razor

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
<div class="row" style="max-height:486px;">
1+
<div class="row border-bottom mb-3">
2+
<div class="col"><b>Markdown</b></div>
3+
<div class="col"><b>Preview</b></div>
4+
</div>
5+
<div class="row" style="max-height:486px;">
26
<div class="col">
37
<textarea class="form-control"
48
rows="18"
@@ -13,5 +17,5 @@
1317
</div>
1418

1519
@code {
16-
private string markdown = "# Heading 1";
20+
private string markdown = "# Heading 1\n## Heading 2\n\n![BlazorBootstrap](https://demos.blazorbootstrap.com/images/logo/logo-color.svg =50)";
1721
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<Markdown>
22
above
3-
----
3+
---
44
below
55
</Markdown>

BlazorBootstrap.Demo.RCL/Components/Pages/Markdown/Markdown_Demo_01_Examples.razor renamed to BlazorBootstrap.Demo.RCL/Components/Pages/Markdown/Markdown_Demo_99_Examples.razor

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,15 @@ _You **can** combine them_
3636

3737
## Images
3838

39-
![This is an alt text.](/image/sample.webp "This is a sample image.")
39+
![This is an alt text.](https://demos.blazorbootstrap.com/images/logo/logo-color.svg =50)
4040

4141
## Links
4242

43-
You may be using [Markdown Live Preview](https://markdownlivepreview.com/).
43+
[BlazorBootstrap Demos](https://demos.blazorbootstrap.com/).
4444

4545
## Blockquotes
4646

4747
> Markdown is a lightweight markup language with plain-text-formatting syntax, created in 2004 by John Gruber with Aaron Swartz.
48-
>
4948
>> Markdown is often used to format readme files, for writing messages in online discussion forums, and to create rich text using a plain text editor.
5049

5150
## Tables

blazorbootstrap/Components/Markdown/Markdown.razor.cs

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ private void ParseMarkdown()
6666
markup = ConvertMarkdownLineBreaksToHtml(markup);
6767
markup = ConvertMarkdownImageToHtml(markup);
6868
markup = ConvertMarkdownLinksToHtml(markup);
69+
markup = ConvertMarkdownInlineCodeToHtml(markup);
6970
html = markup.Replace(CODE_HIGHLIGHTING_LINE_SEPERATOR, "\n");
7071
}
7172

@@ -572,24 +573,7 @@ private string ConvertMarkdownParagraphsToHtml(string markup)
572573
// Line breaks
573574
private string ConvertMarkdownLineBreaksToHtml(string markup) => markup.Replace("\n", "<br />");
574575

575-
// Links
576-
private string ConvertMarkdownLinksToHtml(string markup)
577-
{
578-
// Pattern to match Markdown link syntax: [Link Text](Link URL)
579-
var pattern = @"\[(.*?)\]\((.*?)\)";
580-
581-
// Replace Markdown link syntax with HTML <a> tag
582-
var html = Regex.Replace(markup, pattern, match =>
583-
{
584-
var linkText = match.Groups[1].Value;
585-
var linkUrl = match.Groups[2].Value;
586-
587-
return $"<a href=\"{linkUrl}\">{linkText}</a>";
588-
});
589-
590-
return html;
591-
}
592-
576+
// Image
593577
private string ConvertMarkdownImageToHtml(string markup)
594578
{
595579
// Pattern to match Markdown image syntax: ![alt text](url "optional title" =WIDTHxHEIGHT)
@@ -629,6 +613,41 @@ private string ConvertMarkdownImageToHtml(string markup)
629613
return html;
630614
}
631615

616+
// Links
617+
private string ConvertMarkdownLinksToHtml(string markup)
618+
{
619+
// Pattern to match Markdown link syntax: [Link Text](Link URL)
620+
var pattern = @"\[(.*?)\]\((.*?)\)";
621+
622+
// Replace Markdown link syntax with HTML <a> tag
623+
var html = Regex.Replace(markup, pattern, match =>
624+
{
625+
var linkText = match.Groups[1].Value;
626+
var linkUrl = match.Groups[2].Value;
627+
628+
return $"<a href=\"{linkUrl}\">{linkText}</a>";
629+
});
630+
631+
return html;
632+
}
633+
634+
// Inline code
635+
private string ConvertMarkdownInlineCodeToHtml(string markup)
636+
{
637+
// Pattern to match inline Markdown code syntax: `code`
638+
var pattern = @"`([^`]+)`";
639+
640+
// Replace inline Markdown code syntax with HTML <code> tag
641+
var html = Regex.Replace(markup, pattern, match =>
642+
{
643+
var codeText = match.Groups[1].Value;
644+
645+
return $"<code>{codeText}</code>";
646+
});
647+
648+
return html;
649+
}
650+
632651
//private string ConvertMarkdownChecklistToHtml(string markup)
633652
//{
634653
// // Pattern to match Markdown checklist syntax: - [ ] or - [x] or 1. [ ] or 1. [x]

0 commit comments

Comments
 (0)