-
Notifications
You must be signed in to change notification settings - Fork 824
Add documentation for IMarkdownToHtmlConverter for CMS 17.2
#7740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8a0fabc
Added documentation for IMarkdownToHtmlConverter for 17.2
AndyButland d30503e
Linked from markdown property editor
AndyButland 0c2474f
Update markdown-editor.md
sofietoft ad595b0
Refine language and clarity in markdown conversion doc
sofietoft a4c89f5
Added link from property editor page
AndyButland c6c967a
Update 17/umbraco-cms/reference/markdown-to-html-conversion.md
AndyButland 4b414e2
Update markdown-editor.md
sofietoft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| --- | ||
| description: Describes how markdown to HTML is carried out within Umbraco. | ||
| --- | ||
|
|
||
| # Markdown to HTML Conversion | ||
|
|
||
| Umbraco requires Markdown to be converted into HTML. Primarily, this is to support the [Markdown property editor](../fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/markdown-editor.md). There are also internal use cases, for example, in rendering email notification content for [health checks](../extending/health-check/README.md). | ||
|
|
||
| The conversion is managed via the `IMarkdownToHtmlConverter` interface. | ||
|
|
||
| Umbraco registers a default implementation of `HeyRedMarkdownToHtmlConverter`, which is based on the [Hey Red Markdown library](https://github.com/hey-red/Markdown). | ||
|
|
||
| Also provided is an unregistered, alternate implementation of `MarkdigMarkdownToHtmlConverter`, based on the [Markdig library](https://github.com/xoofx/markdig). | ||
|
|
||
| Both implementations convert standard markdown into HTML, but there are some subtle differences in the output produced. | ||
|
|
||
| ## Modifying the Default Behavior | ||
|
|
||
| If you prefer to use the Markdig-based implementation, replace the default registration by adding the following composer: | ||
|
|
||
| ```csharp | ||
| using Umbraco.Cms.Core.Composing; | ||
| using Umbraco.Cms.Core.Strings; | ||
| using Umbraco.Cms.Infrastructure.Strings; | ||
|
|
||
| public class MarkdownToHtmlComposer : IComposer | ||
| { | ||
| public void Compose(IUmbracoBuilder builder) | ||
| { | ||
| builder.Services.AddUnique<IMarkdownToHtmlConverter, MarkdigMarkdownToHtmlConverter>(); | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| Alternatively, the interface itself can be implemented directly, enabling you to use the library and custom behavior you prefer: | ||
|
|
||
| ```csharp | ||
| namespace Umbraco.Cms.Core.Strings; | ||
|
|
||
| public interface IMarkdownToHtmlConverter | ||
| { | ||
| /// <summary> | ||
| /// Converts the specified Markdown-formatted text to an HTML-encoded string. | ||
| /// </summary> | ||
| /// <param name="markdown">The input string containing Markdown syntax to be converted.</param> | ||
| /// <returns>A string containing the HTML representation of the input Markdown.</returns> | ||
| public string ToHtml(string markdown); | ||
| } | ||
| ``` | ||
|
|
||
| ## Planned Updates | ||
|
|
||
| The Hey Red Markdown library is now deprecated. We expect to make the implementation based on Markdig the default one registered from Umbraco 18. The Hey Red Markdown library implementation will be removed in Umbraco 19. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.