Repository: OrchardCMS/OrchardCore (2026-04-19T23:32:16Z)

Issue:
MarkdownToHtmlAsync doesn't actually convert Markdown
<!-- Please also see the docs on how we manage issues: https://docs.orchardcore.net/en/latest/docs/contributing/managing-issues/. -->
<!-- Please replace all placeholders such as this below. -->

### Describe the bug

Markdown translation doesn't seem to happen. Stuff like `_italic_` or `**bold**` are not converted.

### Orchard Core version

Latest main branch, and 3.0.0-preview-18980 from CloudSmith.

### To Reproduce

Use this code anywhere:

```csharp
await Orchard.MarkdownToHtmlAsync("This _is_ a ==test== markdown.")
```

The result is identical to the input.

### Expected behavior

It should return correct HTML, such as `<p>This <em>is</em> a <mark>test</mark> markdown.</p>` for the above example.

### Logs and screenshots

<img width="1255" height="415" alt="Image" src="https://github.com/user-attachments/assets/37e4831c-87b5-4bf9-ad7e-a939b83f4d5f" />



Discussion:
@hishamco I've already on it. I'm just not allowed to self-assign in this repo.

It's on your plate



Patch:
diff --git a/src/OrchardCore.Modules/OrchardCore.Markdown/Razor/ContentRazorHelperExtensions.cs b/src/OrchardCore.Modules/OrchardCore.Markdown/Razor/ContentRazorHelperExtensions.cs
index a700bd13cb8..79e2afac287 100644
--- a/src/OrchardCore.Modules/OrchardCore.Markdown/Razor/ContentRazorHelperExtensions.cs
+++ b/src/OrchardCore.Modules/OrchardCore.Markdown/Razor/ContentRazorHelperExtensions.cs
@@ -40,7 +40,7 @@ public static async Task<IHtmlContent> MarkdownToHtmlAsync(
         var html = markdownService.ToHtml(markdown ?? string.Empty);
 
         // TODO: provide context argument (optional on this helper as with the liquid helper?).
-        html = await shortcodeService.ProcessAsync(markdown);
+        html = await shortcodeService.ProcessAsync(html);
 
         if (sanitize)
         {


Test patch:
diff --git a/test/OrchardCore.Tests/Modules/OrchardCore.Markdown/MarkdownTests.cs b/test/OrchardCore.Tests/Modules/OrchardCore.Markdown/MarkdownTests.cs
index f5d86b3264a..b7c1e229a86 100644
--- a/test/OrchardCore.Tests/Modules/OrchardCore.Markdown/MarkdownTests.cs
+++ b/test/OrchardCore.Tests/Modules/OrchardCore.Markdown/MarkdownTests.cs
@@ -1,4 +1,6 @@
+using OrchardCore.Infrastructure.Html;
 using OrchardCore.Markdown.Services;
+using OrchardCore.Shortcodes.Services;
 
 namespace OrchardCore.Tests.Modules.OrchardCore.Markdown;
 
@@ -7,12 +9,7 @@ public class MarkdownTests
     [Fact]
     public void ShouldConfigureMarkdownPipeline()
     {
-        var services = new ServiceCollection();
-        services.AddOptions<MarkdownPipelineOptions>();
-        services.ConfigureMarkdownPipeline((pipeline) => pipeline.DisableHtml());
-
-        services.AddScoped<IMarkdownService, DefaultMarkdownService>();
-
+        var services = CreateServiceCollection();
         var markdownService = services.BuildServiceProvider().GetService<IMarkdownService>();
 
         var markdown = @"<h1>foo</h1>";
@@ -25,11 +22,7 @@ public void ShouldConfigureMarkdownPipeline()
     public void ShouldReconfigureMarkdownPipeline()
     {
         // Setup. With defaults.
-        var services = new ServiceCollection();
-        services.AddOptions<MarkdownPipelineOptions>();
-        services.ConfigureMarkdownPipeline((pipeline) => pipeline.DisableHtml());
-
-        services.AddScoped<IMarkdownService, DefaultMarkdownService>();
+        var services = CreateServiceCollection();
 
         // Act. Clear configuration
         services.Configure<MarkdownPipelineOptions>(o =>
@@ -45,4 +38,47 @@ public void ShouldReconfigureMarkdownPipeline()
         html = html.ReplaceLineEndings(string.Empty);
         Assert.Equal(@"<h1>foo</h1>", html);
     }
+
+    [Fact]
+    public async Task ShouldConvertMarkdownToHtmlAsync()
+    {
+        // Arrange
+        var services = CreateServiceCollection();
+        services.AddScoped<IOrchardHelper>(provider => new MockOrchardHelper(provider));
+        services.AddScoped<IShortcodeService, ShortcodeService>();
+        services.AddScoped<IHtmlSanitizerService, HtmlSanitizerService>();
+        
+        // Act
+        var orchard = services.BuildServiceProvider().GetService<IOrchardHelper>();
+        
+        await using var stringWriter = new StringWriter();
+        (await orchard.MarkdownToHtmlAsync("This _is_ a ==test== markdown.")).WriteTo(stringWriter, HtmlEncoder.Default);
+        var html = stringWriter.ToString();
+
+        // Assert
+        html = html.ReplaceLineEndings(string.Empty);
+        Assert.Equal("<p>This <em>is</em> a <mark>test</mark> markdown.</p>", html);
+    }
+
+    private static ServiceCollection CreateServiceCollection()
+    {
+        var services = new ServiceCollection();
+
+        services.AddOptions<MarkdownPipelineOptions>();
+        services.ConfigureMarkdownPipeline(pipeline => pipeline.Configure("nohtml+advanced"));
+        services.AddScoped<IMarkdownService, DefaultMarkdownService>();
+
+        return services;
+    }
+    
+    private sealed class MockOrchardHelper : IOrchardHelper
+    {
+        public HttpContext HttpContext { get; }
+
+        public MockOrchardHelper(IServiceProvider provider)
+        {
+            HttpContext = new DefaultHttpContext();
+            HttpContext.RequestServices = provider;
+        }
+    }
 }