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 @@
-

Carousel New

+

Carousel

@@ -107,12 +107,12 @@
-

Dropdown

+

Dropdown Updated

-

Google Map New

+

Google Map Updated

@@ -127,12 +127,12 @@
-

Images New

+

Images

-

Markdown Preview

+

Markdown New

@@ -157,7 +157,7 @@
-

PDF Viewer Updated

+

PDF Viewer

@@ -192,12 +192,12 @@
-

Sidebar Updated

+

Sidebar

-

Sidebar 2 Updated

+

Sidebar 2

@@ -217,7 +217,7 @@
-

Tabs Updated

+

Tabs

@@ -304,12 +304,12 @@
@@ -319,22 +319,22 @@
diff --git a/BlazorBootstrap.Demo.RCL/Components/Pages/Markdown/MarkdownDocumentation.razor b/BlazorBootstrap.Demo.RCL/Components/Pages/Markdown/MarkdownDocumentation.razor index 8992bff13..c0236bd22 100644 --- a/BlazorBootstrap.Demo.RCL/Components/Pages/Markdown/MarkdownDocumentation.razor +++ b/BlazorBootstrap.Demo.RCL/Components/Pages/Markdown/MarkdownDocumentation.razor @@ -108,5 +108,5 @@ private string pageUrl = "/markdown"; private string title = "Blazor Markdown Component"; private string description = "Use Blazor Bootstrap Markdown component to add formatting, tables, images, and more to your project pages."; - private string imageUrl = "https://i.imgur.com/FGgEMp6.jpg"; // TODO: update + private string imageUrl = "https://i.imgur.com/FhN1caj.png"; } \ No newline at end of file diff --git a/BlazorBootstrap.Demo.Server/appsettings.json b/BlazorBootstrap.Demo.Server/appsettings.json index 03290f577..1f5db0e37 100644 --- a/BlazorBootstrap.Demo.Server/appsettings.json +++ b/BlazorBootstrap.Demo.Server/appsettings.json @@ -6,9 +6,9 @@ } }, "AllowedHosts": "*", - "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/getting-started/blazor-webassembly-net-8", diff --git a/BlazorBootstrap.Demo.WebAssembly/wwwroot/appsettings.json b/BlazorBootstrap.Demo.WebAssembly/wwwroot/appsettings.json index 0475051b5..77d3891aa 100644 --- a/BlazorBootstrap.Demo.WebAssembly/wwwroot/appsettings.json +++ b/BlazorBootstrap.Demo.WebAssembly/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/getting-started/blazor-webassembly-net-8", diff --git a/README.md b/README.md index 6b2d2adce..ca0d8936b 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ ## Install -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 @@ -80,6 +80,7 @@ Install [Blazor Bootstrap templates](https://github.com/vikramlearning/blazorboo | 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/content/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) | @@ -178,6 +179,9 @@ Blazor Bootstrap's documentation, which is included in this repository's root di ### Blazor Bootstrap - Image ![Blazor Bootstrap - Image](https://i.imgur.com/eiSTmvO.png "Blazor Bootstrap - Image") +### Blazor Bootstrap - Markdown +![Blazor Bootstrap - Markdown](https://i.imgur.com/FhN1caj.png "Blazor Bootstrap - Markdown") + ### Blazor Bootstrap - Modal ![Blazor Bootstrap - Modal](https://i.imgur.com/n0m4Fhq.jpg "Blazor Bootstrap - Modal") diff --git a/blazorbootstrap/BlazorBootstrap.csproj b/blazorbootstrap/BlazorBootstrap.csproj index 7d0120794..48b19bdcf 100644 --- a/blazorbootstrap/BlazorBootstrap.csproj +++ b/blazorbootstrap/BlazorBootstrap.csproj @@ -3,14 +3,14 @@ Blazor.Bootstrap - 3.0.0 - 3.0.0 + 3.1.0 + 3.1.0 Apache-2.0 https://docs.blazorbootstrap.com/ https://github.com/vikramlearning/blazorbootstrap - Blazor, WebAssembly, BlazorWebAssembly, Bootstrap, Bootstrap5, BlazorBootstrap, BlazorAlert, BlazorAutoComplete, BlazorButtons, BlazorCallout, BlazorCharts, BlazorConfirmDialog, BlazorGrid, BlazorIcon, BlazorImage, BlazorModal, BlazorCurrencyInput, BlazorNumberInput, BlazorInput, BlazorNumber, BlazorDate, BlazorDateInput, BlazorDatePicker, BlazorTime, BlazorTimeInput, BlazorTimePicker, BlazorOffcanvas, BlazorPagination, BlazorPdfViewer, BlazorPlaceholders, BlazorPreload, BlazorProgress, BlazorRibbon, BlazorScriptLoader, BlazorSidebar, BlazorSidebar2, BlazorSortableList, BlazorSwitch, BlazorSpinners, BlazorTabs, BlazorToasts, BlazorTooltips, BlazorTooltips, BlazorBarChart, BlazorDoughnutChart, BlazorLineChart, BlazorPieChart, BlazorPolarAreaChart, BlazorRadarChart, BlazorScatterChart + Blazor, WebAssembly, BlazorWebAssembly, Bootstrap, Bootstrap5, BlazorBootstrap, BlazorAlert, BlazorAutoComplete, BlazorButtons, BlazorCallout, BlazorCharts, BlazorConfirmDialog, BlazorGrid, BlazorIcon, BlazorImage, BlazorModal, BlazorCurrencyInput, BlazorNumberInput, BlazorInput, BlazorNumber, BlazorDate, BlazorDateInput, BlazorDatePicker, BlazorTime, BlazorTimeInput, BlazorTimePicker, BlazorOffcanvas, BlazorPagination, BlazorPdfViewer, BlazorPlaceholders, BlazorPreload, BlazorProgress, BlazorRibbon, BlazorScriptLoader, BlazorSidebar, BlazorSidebar2, BlazorSortableList, BlazorSwitch, BlazorSpinners, BlazorTabs, BlazorToasts, BlazorTooltips, BlazorTooltips, BlazorBarChart, BlazorDoughnutChart, BlazorLineChart, BlazorPieChart, BlazorPolarAreaChart, BlazorRadarChart, BlazorScatterChart, BlazorMarkdown Blazor Bootstrap is a component library built on top of Blazor and Bootstrap5 CSS framework. Vikram Reddy diff --git a/blazorbootstrap/Components/AI/Chat/AIChat.razor.cs b/blazorbootstrap/Components/AI/Chat/AIChat.razor.cs index ab33601c9..cc8c1ec77 100644 --- a/blazorbootstrap/Components/AI/Chat/AIChat.razor.cs +++ b/blazorbootstrap/Components/AI/Chat/AIChat.razor.cs @@ -64,6 +64,7 @@ public async Task ChartCompletetionsStreamJs(string content, bool done) currentCompletion = ""; await InvokeAsync(StateHasChanged); await JSRuntime.InvokeVoidAsync(BlazorBootstrapInterop.ScrollToElementBottom, Id); + return; } @@ -112,15 +113,19 @@ private async Task SendPromptAsync() #region Properties, Indexers protected override string? ClassNames => - BuildClassNames(Class, - (BootstrapClass.Container, true)); + BuildClassNames( + Class, + (BootstrapClass.Container, true) + ); protected override string? StyleNames => - BuildStyleNames(Style, + BuildStyleNames( + Style, //("min-height:200px", true), //("max-height:400px", true), ("overflow-x:hidden", true), - ("overflow-y:auto", true)); + ("overflow-y:auto", true) + ); /// /// The maximum number of tokens to generate shared between the prompt and completion. @@ -149,7 +154,3 @@ private async Task SendPromptAsync() #endregion } - - - - diff --git a/blazorbootstrap/Components/Markdown/Markdown.razor.cs b/blazorbootstrap/Components/Markdown/Markdown.razor.cs index 23ca85f32..df8a60c45 100644 --- a/blazorbootstrap/Components/Markdown/Markdown.razor.cs +++ b/blazorbootstrap/Components/Markdown/Markdown.razor.cs @@ -1,43 +1,22 @@ using Microsoft.AspNetCore.Components.Rendering; -using System.Text.RegularExpressions; namespace BlazorBootstrap; public partial class Markdown : BlazorBootstrapComponentBase { - private string? html; + #region Fields and Constants private const string CODE_HIGHLIGHTING_LINE_SEPERATOR = " $$CHLS$$ "; private const string PATTERN_ORDERED_LIST = @"^\s*\d+\.\s"; private const string PATTERN_UNORDERED_LIST = @"^\s*\-\s"; private const string PATTERN_HORIZONTAL_RULES = @"^\-{3,}$"; private const string PATTERN_BLOCKQUOTES = @"^>{1,}\s(.*)"; - - #region Properties, Indexers - - /// - /// 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"; - - /// - /// Gets or sets the CSS class for blockquotes. - /// - [Parameter] - public string? BlockquotesCssClass { get; set; } = "blockquote"; + private string? html; #endregion + #region Methods + protected override void OnInitialized() { ParseMarkdown(); @@ -53,65 +32,6 @@ protected override void OnParametersSet() base.OnParametersSet(); } - private void ParseMarkdown() - { - var lines = GetLines(); - if (lines is null) - return; - - // 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"); - } - - List GetLines() - { - var inputs = new List(); - - if (ChildContent is not null) - { - var builder = new RenderTreeBuilder(); - ChildContent.Invoke(builder); - - var frames = builder.GetFrames().Array; - foreach (var frame in frames) - { - if (frame.MarkupContent is not null) - { - var lines = frame.MarkupContent.Split("\r\n").ToList(); - - if (lines.Any()) - inputs.AddRange(lines); - } - } - } - - if (inputs.Any()) - { - // remove first blank line - if (string.IsNullOrWhiteSpace(inputs[0])) - inputs.RemoveAt(0); - - // remove last blank line - if (string.IsNullOrWhiteSpace(inputs[^1])) - inputs.RemoveAt(inputs.Count - 1); - } - - return inputs; - } - // Headers private string ConvertMakdownHeadersToHtml(string markup) { @@ -124,6 +44,7 @@ private string ConvertMakdownHeadersToHtml(string markup) { parsedLines.Add(line); parsedLines.Add("\n"); + continue; } @@ -174,7 +95,8 @@ private string ConvertMarkdownBlockquotesToHtml(string markup) foreach (var line in lines) { var trimmerLine = line.Trim(); - var indentLevel = trimmerLine.TakeWhile((c) => c == '>').Count(); + var indentLevel = trimmerLine.TakeWhile(c => c == '>').Count(); + if (Regex.IsMatch(trimmerLine, PATTERN_BLOCKQUOTES)) { if (listStack.Count == 0 || indentStack.Peek() < indentLevel) @@ -241,32 +163,40 @@ private string ConvertMarkdownBlockquotesToHtml(string markup) return string.Join("", htmlLines); } - // HorizontalRules - private string ConvertMarkdownHorizontalRulesToHtml(string markup) + // Code Highlighting + private string ConvertMarkdownCodeHighlightingToHtml(string markup) { var lines = markup.Split("\n"); var parsedLines = new List(); + var isCodeBlockInprogress = false; - foreach (var line in lines) - { - if (string.IsNullOrWhiteSpace(line)) + for (var i = 0; i < lines.Count(); i++) + if (Regex.IsMatch(lines[i].Trim(), @"\```(\w+)")) { - parsedLines.Add(line); - parsedLines.Add("\n"); - continue; + if (!isCodeBlockInprogress) + isCodeBlockInprogress = true; + + lines[i] = Regex.Replace(lines[i].Trim(), @"\```(\w+)", "
");
+                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]); + parsedLines.Add($"{CODE_HIGHLIGHTING_LINE_SEPERATOR}"); } else { - parsedLines.Add(line); + parsedLines.Add(lines[i]); parsedLines.Add("\n"); } - } RemoveLastLineBreak(parsedLines); @@ -284,6 +214,7 @@ private string ConvertMarkdownEmphasisToHtml(string markup) if (string.IsNullOrWhiteSpace(lines[i])) { parsedLines.Add(lines[i]); + continue; } @@ -306,39 +237,30 @@ private string ConvertMarkdownEmphasisToHtml(string markup) return string.Join("\n", parsedLines); } - // Code Highlighting - private string ConvertMarkdownCodeHighlightingToHtml(string markup) + // HorizontalRules + private string ConvertMarkdownHorizontalRulesToHtml(string markup) { var lines = markup.Split("\n"); var parsedLines = new List(); - var isCodeBlockInprogress = false; - for (var i = 0; i < lines.Count(); i++) + foreach (var line in lines) { - if (Regex.IsMatch(lines[i].Trim(), @"\```(\w+)")) + if (string.IsNullOrWhiteSpace(line)) { - if (!isCodeBlockInprogress) - isCodeBlockInprogress = true; + parsedLines.Add(line); + parsedLines.Add("\n"); - lines[i] = Regex.Replace(lines[i].Trim(), @"\```(\w+)", "
");
-                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, "
")); } else { - parsedLines.Add(lines[i]); + parsedLines.Add(line); parsedLines.Add("\n"); } } @@ -348,6 +270,87 @@ private string ConvertMarkdownCodeHighlightingToHtml(string markup) return string.Join("", parsedLines); } + // 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*))?\)"; + + // Replace Markdown image syntax with HTML tag + var html = Regex.Replace( + markup, + pattern, + match => + { + 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 = $"\"{altText}\""; 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(""; - } - } 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 = $"\"{altText}\""; 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) |