diff --git a/BlazorBootstrap.Demo.Hosted/Client/wwwroot/appsettings.json b/BlazorBootstrap.Demo.Hosted/Client/wwwroot/appsettings.json index 5b3794f71..2ab437181 100644 --- a/BlazorBootstrap.Demo.Hosted/Client/wwwroot/appsettings.json +++ b/BlazorBootstrap.Demo.Hosted/Client/wwwroot/appsettings.json @@ -1,7 +1,7 @@ { - "version": "3.0.0", + "version": "3.1.0", "release": { - "short_description": "New Carousel, Google Map, Image, Polar Area Chart, Radar Chart, Scatter Chart components, and other improvements!!!" + "short_description": "New Markdown component and other enhancements!!!" }, "urls": { "docs": "//docs.blazorbootstrap.com/docs/getting-started/blazor-webassembly", diff --git a/BlazorBootstrap.Demo.RCL/Components/Pages/Index.razor b/BlazorBootstrap.Demo.RCL/Components/Pages/Index.razor index 6f3c55ce5..6041f4148 100644 --- a/BlazorBootstrap.Demo.RCL/Components/Pages/Index.razor +++ b/BlazorBootstrap.Demo.RCL/Components/Pages/Index.razor @@ -77,7 +77,7 @@
");
+ parsedLines.Add(lines[i]);
}
+ else if (Regex.IsMatch(lines[i].Trim().Trim(), @"```"))
+ {
+ if (isCodeBlockInprogress)
+ isCodeBlockInprogress = false;
- if (Regex.IsMatch(line.Trim(), PATTERN_HORIZONTAL_RULES))
+ lines[i] = Regex.Replace(lines[i].Trim(), @"```", "
");
+ parsedLines.Add(lines[i]);
+ }
+ else if (isCodeBlockInprogress)
{
- RemoveLastLineBreak(parsedLines);
- parsedLines.Add(Regex.Replace(line.Trim(), PATTERN_HORIZONTAL_RULES, "");
- parsedLines.Add(lines[i]);
+ continue;
}
- else if (Regex.IsMatch(lines[i].Trim().Trim(), @"```"))
- {
- if (isCodeBlockInprogress)
- isCodeBlockInprogress = false;
- lines[i] = Regex.Replace(lines[i].Trim(), @"```", "
");
- parsedLines.Add(lines[i]);
- }
- else if (isCodeBlockInprogress)
+ if (Regex.IsMatch(line.Trim(), PATTERN_HORIZONTAL_RULES))
{
- parsedLines.Add(lines[i]);
- parsedLines.Add($"{CODE_HIGHLIGHTING_LINE_SEPERATOR}");
+ RemoveLastLineBreak(parsedLines);
+ parsedLines.Add(Regex.Replace(line.Trim(), PATTERN_HORIZONTAL_RULES, " tag
+ var html = Regex.Replace(
+ markup,
+ pattern,
+ match =>
+ {
+ var codeText = match.Groups[1].Value;
+
+ return $"{codeText}
";
+ }
+ );
+
+ return html;
+ }
+
+ // Line breaks
+ private string ConvertMarkdownLineBreaksToHtml(string markup) => markup.Replace("\n", "
");
+
+ // Links
+ private string ConvertMarkdownLinksToHtml(string markup)
+ {
+ // Pattern to match Markdown link syntax: [Link Text](Link URL)
+ var pattern = @"\[(.*?)\]\((.*?)\)";
+
+ // Replace Markdown link syntax with HTML tag
+ var html = Regex.Replace(
+ markup,
+ pattern,
+ match =>
+ {
+ var linkText = match.Groups[1].Value;
+ var linkUrl = match.Groups[2].Value;
+
+ return $"{linkText}";
+ }
+ );
+
+ return html;
+ }
+
// Lists
private string ConvertMarkdownListToHtml(string markup)
{
@@ -386,6 +389,7 @@ private string ConvertMarkdownListToHtml(string markup)
indentStack.Push(indentLevel);
}
}
+
htmlLines.Add($"{Regex.Replace(line, PATTERN_ORDERED_LIST, "")}");
}
else if (indentStack.Peek() > indentLevel)
@@ -426,6 +430,7 @@ private string ConvertMarkdownListToHtml(string markup)
indentStack.Push(indentLevel);
}
}
+
htmlLines.Add($" {Regex.Replace(line, PATTERN_UNORDERED_LIST, "")}");
}
else if (indentStack.Peek() > indentLevel)
@@ -462,19 +467,39 @@ private string ConvertMarkdownListToHtml(string markup)
}
// Close any open list items
- for (int i = 0; i < htmlLines.Count; i++)
- {
+ for (var i = 0; i < htmlLines.Count; i++)
if (htmlLines[i].StartsWith(" ") && (i == htmlLines.Count - 1 || htmlLines[i + 1].StartsWith(" ") || htmlLines[i + 1].StartsWith("")))
- {
htmlLines[i] += " ";
- }
- }
RemoveLastLineBreak(htmlLines);
return string.Join("", htmlLines);
}
+ // Paragraphs
+ private string ConvertMarkdownParagraphsToHtml(string markup)
+ {
+ var lines = markup.Split("\n\n\n");
+ var parsedLines = new List();
+
+ if (lines.Length == 1)
+ return markup;
+
+ foreach (var line in lines)
+ {
+ if (string.IsNullOrWhiteSpace(line))
+ {
+ parsedLines.Add(line);
+
+ continue;
+ }
+
+ parsedLines.Add($"{line}
");
+ }
+
+ return string.Join("", parsedLines);
+ }
+
// Tables
private string ConvertMarkdownTableToHtml(string markup)
{
@@ -491,11 +516,13 @@ private string ConvertMarkdownTableToHtml(string markup)
if (string.IsNullOrWhiteSpace(line))
{
parsedLines.Add(line);
+
continue;
}
// Trim row with spaces
var trimmedLine = line.Trim();
+
if (trimmedLine.StartsWith("| "))
{
if (!isTableStart)
@@ -553,105 +580,63 @@ private string ConvertMarkdownTableToHtml(string markup)
return string.Join("\n", parsedLines);
}
- // Paragraphs
- private string ConvertMarkdownParagraphsToHtml(string markup)
+ private List GetLines()
{
- var lines = markup.Split("\n\n\n");
- var parsedLines = new List();
-
- if (lines.Length == 1)
- return markup;
-
- foreach (var line in lines)
- {
- if (string.IsNullOrWhiteSpace(line))
- {
- parsedLines.Add(line);
- continue;
- }
-
- parsedLines.Add($"{line}
");
- }
-
- return string.Join("", parsedLines);
- }
-
- // Line breaks
- private string ConvertMarkdownLineBreaksToHtml(string markup) => markup.Replace("\n", "
");
-
- // Image
- private string ConvertMarkdownImageToHtml(string markup)
- {
- // Pattern to match Markdown image syntax: ![alt text](url "optional title" =WIDTHxHEIGHT)
- var pattern = @"!\[(.*?)\]\((.*?)(\s*""[^""]*"")?(\s*=\s*(\d*)x?(\d*))?\)";
+ var inputs = new List();
- // Replace Markdown image syntax with HTML tag
- var html = Regex.Replace(markup, pattern, match =>
+ if (ChildContent is not null)
{
- var altText = match.Groups[1].Value;
- var url = match.Groups[2].Value;
- var title = match.Groups[3].Value;
- var width = match.Groups[5].Value;
- var height = match.Groups[6].Value;
-
- var imgTag = $"";
+ var builder = new RenderTreeBuilder();
+ ChildContent.Invoke(builder);
- return imgTag;
- });
+ var frames = builder.GetFrames().Array;
- return html;
- }
+ foreach (var frame in frames)
+ if (frame.MarkupContent is not null)
+ {
+ var lines = frame.MarkupContent.Split("\r\n").ToList();
- // Links
- private string ConvertMarkdownLinksToHtml(string markup)
- {
- // Pattern to match Markdown link syntax: [Link Text](Link URL)
- var pattern = @"\[(.*?)\]\((.*?)\)";
+ if (lines.Any())
+ inputs.AddRange(lines);
+ }
+ }
- // Replace Markdown link syntax with HTML tag
- var html = Regex.Replace(markup, pattern, match =>
+ if (inputs.Any())
{
- var linkText = match.Groups[1].Value;
- var linkUrl = match.Groups[2].Value;
+ // remove first blank line
+ if (string.IsNullOrWhiteSpace(inputs[0]))
+ inputs.RemoveAt(0);
- return $"{linkText}";
- });
+ // remove last blank line
+ if (string.IsNullOrWhiteSpace(inputs[^1]))
+ inputs.RemoveAt(inputs.Count - 1);
+ }
- return html;
+ return inputs;
}
- // Inline code
- private string ConvertMarkdownInlineCodeToHtml(string markup)
+ private void ParseMarkdown()
{
- // Pattern to match inline Markdown code syntax: `code`
- var pattern = @"`([^`]+)`";
-
- // Replace inline Markdown code syntax with HTML tag
- var html = Regex.Replace(markup, pattern, match =>
- {
- var codeText = match.Groups[1].Value;
+ var lines = GetLines();
- return $"{codeText}
";
- });
+ if (lines is null)
+ return;
- return html;
+ // NOTE: do not change the sequence of these two lines
+ var markup = string.Join("\n", lines);
+ markup = ConvertMakdownHeadersToHtml(markup);
+ markup = ConvertMarkdownBlockquotesToHtml(markup);
+ markup = ConvertMarkdownHorizontalRulesToHtml(markup);
+ markup = ConvertMarkdownEmphasisToHtml(markup);
+ markup = ConvertMarkdownCodeHighlightingToHtml(markup);
+ markup = ConvertMarkdownListToHtml(markup);
+ markup = ConvertMarkdownTableToHtml(markup);
+ markup = ConvertMarkdownParagraphsToHtml(markup);
+ markup = ConvertMarkdownLineBreaksToHtml(markup);
+ markup = ConvertMarkdownImageToHtml(markup);
+ markup = ConvertMarkdownLinksToHtml(markup);
+ markup = ConvertMarkdownInlineCodeToHtml(markup);
+ html = markup.Replace(CODE_HIGHLIGHTING_LINE_SEPERATOR, "\n");
}
//private string ConvertMarkdownChecklistToHtml(string markup)
@@ -674,7 +659,6 @@ private string ConvertMarkdownInlineCodeToHtml(string markup)
// return html;
//}
-
// Emoji
// Mathematical notation and characters
@@ -687,4 +671,31 @@ private static void RemoveLastLineBreak(List htmlLines)
if (htmlLines.Any() && htmlLines[^1] == "\n")
htmlLines.RemoveAt(htmlLines.Count - 1);
}
+
+ #endregion
+
+ #region Properties, Indexers
+
+ ///
+ /// Gets or sets the CSS class for blockquotes.
+ ///
+ [Parameter]
+ public string? BlockquotesCssClass { get; set; } = "blockquote";
+
+ ///
+ /// Gets or sets the content to be rendered within the component.
+ ///
+ ///
+ /// Default value is .
+ ///
+ [Parameter]
+ public RenderFragment? ChildContent { get; set; }
+
+ ///
+ /// Gets or sets the CSS class for table.
+ ///
+ [Parameter]
+ public string? TableCssClass { get; set; } = "table";
+
+ #endregion
}
diff --git a/blazorbootstrap/Usings.cs b/blazorbootstrap/Usings.cs
index d7bab412e..47a2a1d9d 100644
--- a/blazorbootstrap/Usings.cs
+++ b/blazorbootstrap/Usings.cs
@@ -3,9 +3,8 @@
global using Microsoft.AspNetCore.Components.Routing;
global using Microsoft.AspNetCore.Components.Web;
global using Microsoft.JSInterop;
-global using System.Buffers;
global using System.Drawing;
global using System.Globalization;
global using System.Linq.Expressions;
-global using System.Text;
global using System.Text.Json.Serialization;
+global using System.Text.RegularExpressions;
\ No newline at end of file
diff --git a/docs/blog/2024-10-21-blazorbootstrap-3.1.0.md b/docs/blog/2024-10-21-blazorbootstrap-3.1.0.md
new file mode 100644
index 000000000..f53cb3f5b
--- /dev/null
+++ b/docs/blog/2024-10-21-blazorbootstrap-3.1.0.md
@@ -0,0 +1,30 @@
+---
+title: Blazor Bootstrap v3.1.0
+authors:
+ name: Vikram Reddy
+ title: Creator
+ url: https://github.com/gvreddy04
+ image_url: https://avatars.githubusercontent.com/u/2337067
+tags: [v3.1.0, blazor, bootstrap, blazorbootstrap, charts, dropdown, googlemap, grid, linechart, markdown]
+---
+
+We are excited to release version 3.1.0, which includes new Markdown component and other enhancements!!!
+
+![image](https://i.imgur.com/FhN1caj.png "Blazor Bootstrap: Markdown Component")
+
+
+
+## What's new
+- `Markdown` component
+
+## What's changed
+- Dark mode support added
+- Grid enum filter - select text translation support added
+- Line Chart - Fill support added
+- Dropdown - Docs updated
+- Google Map - Docs updated
+
+
+## Links
+- [Docs Website - Blazor Bootstrap](https://docs.blazorbootstrap.com/)
+- [Demos Website - Blazor Bootstrap](https://demos.blazorbootstrap.com/)
diff --git a/docs/docs/01-getting-started/01-a-getting-started-webassembly-NET-8.mdx b/docs/docs/01-getting-started/01-a-getting-started-webassembly-NET-8.mdx
index 93382206d..8fff1a014 100644
--- a/docs/docs/01-getting-started/01-a-getting-started-webassembly-NET-8.mdx
+++ b/docs/docs/01-getting-started/01-a-getting-started-webassembly-NET-8.mdx
@@ -18,7 +18,7 @@ Get started with the Enterprise-class Blazor Bootstrap Component library built o
Looking to quickly add **Blazor Bootstrap** to your project? Use NuGet package manager.
```shell
-Install-Package Blazor.Bootstrap -Version 3.0.0
+Install-Package Blazor.Bootstrap -Version 3.1.0
```
## Add CSS references
diff --git a/docs/docs/01-getting-started/01-b-getting-started-webapp-server-global-NET-8.mdx b/docs/docs/01-getting-started/01-b-getting-started-webapp-server-global-NET-8.mdx
index f2a354eae..2553a8b84 100644
--- a/docs/docs/01-getting-started/01-b-getting-started-webapp-server-global-NET-8.mdx
+++ b/docs/docs/01-getting-started/01-b-getting-started-webapp-server-global-NET-8.mdx
@@ -18,7 +18,7 @@ Get started with the Enterprise-class Blazor Bootstrap Component library built o
Looking to quickly add **Blazor Bootstrap** to your project? Use NuGet package manager.
```shell
-Install-Package Blazor.Bootstrap -Version 3.0.0
+Install-Package Blazor.Bootstrap -Version 3.1.0
```
## Add CSS references
diff --git a/docs/docs/01-getting-started/01-c-getting-started-webapp-auto-global-NET-8.mdx b/docs/docs/01-getting-started/01-c-getting-started-webapp-auto-global-NET-8.mdx
index 7256013c1..b012d6fe0 100644
--- a/docs/docs/01-getting-started/01-c-getting-started-webapp-auto-global-NET-8.mdx
+++ b/docs/docs/01-getting-started/01-c-getting-started-webapp-auto-global-NET-8.mdx
@@ -20,7 +20,7 @@ Get started with the Enterprise-class Blazor Bootstrap Component library built o
Use NuGet package manager.
```shell
-Install-Package Blazor.Bootstrap -Version 3.0.0
+Install-Package Blazor.Bootstrap -Version 3.1.0
```
### Add CSS references
@@ -87,7 +87,7 @@ The default Blazor template includes demonstration code and Bootstrap. To remove
Use NuGet package manager.
```shell
-Install-Package Blazor.Bootstrap -Version 3.0.0
+Install-Package Blazor.Bootstrap -Version 3.1.0
```
### Register services
diff --git a/docs/docs/01-getting-started/01-d-getting-started-maui-blazor-NET-8.mdx b/docs/docs/01-getting-started/01-d-getting-started-maui-blazor-NET-8.mdx
index 46c3a26ab..30926ba29 100644
--- a/docs/docs/01-getting-started/01-d-getting-started-maui-blazor-NET-8.mdx
+++ b/docs/docs/01-getting-started/01-d-getting-started-maui-blazor-NET-8.mdx
@@ -18,7 +18,7 @@ Get started with the Enterprise-class Blazor Bootstrap Component library built o
Looking to quickly add **Blazor Bootstrap** to your project? Use NuGet package manager.
```shell
-Install-Package Blazor.Bootstrap -Version 3.0.0
+Install-Package Blazor.Bootstrap -Version 3.1.0
```
## Add CSS references
diff --git a/docs/docs/01-getting-started/02-a-getting-started-webassembly-NET-7.mdx b/docs/docs/01-getting-started/02-a-getting-started-webassembly-NET-7.mdx
index 8e83087b9..c96c1c503 100644
--- a/docs/docs/01-getting-started/02-a-getting-started-webassembly-NET-7.mdx
+++ b/docs/docs/01-getting-started/02-a-getting-started-webassembly-NET-7.mdx
@@ -18,7 +18,7 @@ Get started with the Enterprise-class Blazor Bootstrap Component library built o
Looking to quickly add **Blazor Bootstrap** to your project? Use NuGet package manager.
```shell
-Install-Package Blazor.Bootstrap -Version 3.0.0
+Install-Package Blazor.Bootstrap -Version 3.1.0
```
## Add CSS references
diff --git a/docs/docs/01-getting-started/02-b-getting-started-server-NET-7.mdx b/docs/docs/01-getting-started/02-b-getting-started-server-NET-7.mdx
index ae03dd92c..4965f597e 100644
--- a/docs/docs/01-getting-started/02-b-getting-started-server-NET-7.mdx
+++ b/docs/docs/01-getting-started/02-b-getting-started-server-NET-7.mdx
@@ -18,7 +18,7 @@ Get started with the Enterprise-class Blazor Bootstrap Component library built o
Looking to quickly add **Blazor Bootstrap** to your project? Use NuGet package manager.
```shell
-Install-Package Blazor.Bootstrap -Version 3.0.0
+Install-Package Blazor.Bootstrap -Version 3.1.0
```
## Add CSS references
diff --git a/docs/docs/01-getting-started/02-c-getting-started-maui-blazor-NET-7.mdx b/docs/docs/01-getting-started/02-c-getting-started-maui-blazor-NET-7.mdx
index c155f4432..b38384a6f 100644
--- a/docs/docs/01-getting-started/02-c-getting-started-maui-blazor-NET-7.mdx
+++ b/docs/docs/01-getting-started/02-c-getting-started-maui-blazor-NET-7.mdx
@@ -18,7 +18,7 @@ Get started with the Enterprise-class Blazor Bootstrap Component library built o
Looking to quickly add **Blazor Bootstrap** to your project? Use NuGet package manager.
```shell
-Install-Package Blazor.Bootstrap -Version 3.0.0
+Install-Package Blazor.Bootstrap -Version 3.1.0
```
## Add CSS references
diff --git a/docs/docs/01-getting-started/03-a-getting-started-webassembly-NET-6.mdx b/docs/docs/01-getting-started/03-a-getting-started-webassembly-NET-6.mdx
index 9fee3b1ee..de1623c07 100644
--- a/docs/docs/01-getting-started/03-a-getting-started-webassembly-NET-6.mdx
+++ b/docs/docs/01-getting-started/03-a-getting-started-webassembly-NET-6.mdx
@@ -18,7 +18,7 @@ Get started with the Enterprise-class Blazor Bootstrap Component library built o
Looking to quickly add **Blazor Bootstrap** to your project? Use NuGet package manager.
```shell
-Install-Package Blazor.Bootstrap -Version 3.0.0
+Install-Package Blazor.Bootstrap -Version 3.1.0
```
## Add CSS references
diff --git a/docs/docs/01-getting-started/03-b-getting-started-server-NET-6.mdx b/docs/docs/01-getting-started/03-b-getting-started-server-NET-6.mdx
index e6bd4b0d9..e436525ad 100644
--- a/docs/docs/01-getting-started/03-b-getting-started-server-NET-6.mdx
+++ b/docs/docs/01-getting-started/03-b-getting-started-server-NET-6.mdx
@@ -18,7 +18,7 @@ Get started with the Enterprise-class Blazor Bootstrap Component library built o
Looking to quickly add **Blazor Bootstrap** to your project? Use NuGet package manager.
```shell
-Install-Package Blazor.Bootstrap -Version 3.0.0
+Install-Package Blazor.Bootstrap -Version 3.1.0
```
## Add CSS references
diff --git a/docs/docs/05-components/markdown.mdx b/docs/docs/05-components/markdown.mdx
index dc7d426bc..41951fba3 100644
--- a/docs/docs/05-components/markdown.mdx
+++ b/docs/docs/05-components/markdown.mdx
@@ -19,6 +19,7 @@ Use Blazor Bootstrap Markdown component to add formatting, tables, images, and m
| Name | Type | Default | Required | Description | Added Version |
|:--|:--|:--|:--|:--|:--|
+| ChildContent | RenderFragment | null | ✔️ | Gets or sets the content to be rendered within the component. | 3.1.0 |
| TableCssClass | string? | `table` | | Gets or sets the CSS class for table. | 3.1.0 |
| BlockquotesCssClass | string? | `blockquote` | | Gets or sets the CSS class for blockquotes. | 3.1.0 |
diff --git a/docs/package.json b/docs/package.json
index 762fe6e4c..a45b71997 100644
--- a/docs/package.json
+++ b/docs/package.json
@@ -1,6 +1,6 @@
{
"name": "blazorbootstrap",
- "version": "3.0.0",
+ "version": "3.1.0",
"private": true,
"scripts": {
"docusaurus": "docusaurus",
diff --git a/nuget/README.md b/nuget/README.md
index fce0624bd..7658f212c 100644
--- a/nuget/README.md
+++ b/nuget/README.md
@@ -18,7 +18,7 @@
Get started any way you want
- Clone the repo: `git clone https://github.com/vikramlearning/blazorbootstrap.git`
-- Install with [NuGet](https://www.nuget.org/): `Install-Package Blazor.Bootstrap -Version 3.0.0`
+- Install with [NuGet](https://www.nuget.org/): `Install-Package Blazor.Bootstrap -Version 3.1.0`
- Install [Blazor Bootstrap templates](https://github.com/vikramlearning/blazorbootstrap-project-templates) with **.NET CLI**: `dotnet new install Blazor.Bootstrap.Templates::1.10.0`
![image](https://user-images.githubusercontent.com/2337067/233800604-43986ae7-27dd-4f17-9af6-c2f1a6f07097.png)
@@ -59,6 +59,7 @@ Get started any way you want
| Grid | [Docs](https://docs.blazorbootstrap.com/components/grid) | [Demos](https://demos.blazorbootstrap.com/grid) |
| Icons | [Docs](https://docs.blazorbootstrap.com/content/icons) | [Demos](https://demos.blazorbootstrap.com/icons) |
| Images | [Docs](https://docs.blazorbootstrap.com/content/images) | [Demos](https://demos.blazorbootstrap.com/images) |
+| Markdown | [Docs](https://docs.blazorbootstrap.com/components/markdown) | [Demos](https://demos.blazorbootstrap.com/markdown) |
| Modals | [Docs](https://docs.blazorbootstrap.com/components/modal) | [Demos](https://demos.blazorbootstrap.com/modals) |
| Number Input | [Docs](https://docs.blazorbootstrap.com/forms/number-input) | [Demos](https://demos.blazorbootstrap.com/form/number-input) |
| Offcanvas | [Docs](https://docs.blazorbootstrap.com/components/offcanvas) | [Demos](https://demos.blazorbootstrap.com/offcanvas) |