Added markdown string preprocessing to include CRLF carriage returns #2055
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.
Related to #1429
Changelog Entry
Description
Web Chat's default markdown renderer - Markdown-it - does not respect CRLF carriage returns. So, each time an activity is received with a CRLF carriage return, Web Chat renders it as a newline character instead of as a carriage return.
Current Behavior
Expected Behavior
Specific Changes
I added a boolean value - markdownRespectCRLF - to the default style options and set the value to true so clients can choose between CRLF and LFCR carriage returns.
I also added the style options as a parameter to the render markdown function and logic to respect either LFCR or CRLF carriage returns based on the markdownRespectCRLF value. If the value is false, the function passes the markdown string to renderer because the renderer already respects LFCR carriage returns; otherwise, the function processes the string prior to rendering it.
The preprocessing step takes advantage of the fact that the markdown renderer already respects LFCR carriage returns and disrespect CRLF. Subsequently, to achieve the converse behavior, we can swap CRLF and LFCR so the renderer will respect CRLF carriage returns and disrespect LFCR carriage returns.