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
Fix Show-Markdown
cmdlet to handle string array input
#20971
base: master
Are you sure you want to change the base?
Fix Show-Markdown
cmdlet to handle string array input
#20971
Conversation
src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowMarkdownCommand.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowMarkdownCommand.cs
Show resolved
Hide resolved
Had some time to look at this again and I see a main challenge. If we want to combine all input from > $mdText = "**Bold**"
> $mdVT100String = $mdText | ConvertFrom-Markdown -AsVT100EncodedString
> $mdVT100String | Format-List
Html :
VT100EncodedString : Bold # This is bold in terminal, as expected
Tokens : {Markdig.Syntax.ParagraphBlock}
> [Microsoft.PowerShell.MarkdownRender.MarkdownConverter]::Convert($mdVT100String.VT100EncodedString, [Microsoft.PowerShell.MarkdownRender.MarkdownConversionType]::VT100, [Microsoft.PowerShell.MarkdownRender.PSMarkdownOptionInfo]::new()) | Format-List
Html :
VT100EncodedString : mBoldm # This has strange characters, almost looking like it was unescaped or something
Tokens : {Markdig.Syntax.ParagraphBlock} Which shows some strange This above makes it challenging since after combining all strings, you will need to run One option I was looking into was seeing if you can get the original markdown from AST with Another option was perhaps running the conversion line by line for With above findings I can see why this was never done in the first place. Perhaps existing approach of just handling strings is not a bad idea, I do consider mixing types in input to be an edge case. |
@ArmaanMcleod, I'm a bit confused: |
That said, that it effectively breaks such escape sequences instead of passing them through is definitely problematic (seemingly, it removes the |
I agree with @mklement0 I can't think of a realistic scenario for such a transformation. |
Show-Markdown
cmdlet to handle string array inputShow-Markdown
cmdlet to handle string array input
Thanks @mklement0 & @iSazonov In this case I don't think it makes sense to try and combine |
Show-Markdown
cmdlet to handle string array inputShow-Markdown
cmdlet to handle string array input
6de7df1
to
9552bc8
Compare
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? 👍 :ok_hand: :thumbsdown: (Email) |
Show-Markdown
cmdlet to handle string array inputShow-Markdown
cmdlet to handle string array input
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
PR Summary
Fixes #20951
Added fix to
Show-Markdown
to allow pipeline processing of array of strings using-InputObject
.PR Context
Added input object buffer to process strings in
EndProcessing()
instead ofProcessRecord()
so all strings can be collected at once from-InputObject
.This change follows similar approach to buffering in
ConvertFrom-Json
.PR Checklist
.h
,.cpp
,.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
or[ WIP ]
to the beginning of the title (theWIP
bot will keep its status check atPending
while the prefix is present) and remove the prefix when the PR is ready.(which runs in a different PS Host).