You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Microsoft.PowerShell.MarkdownRender.MarkdownInfo.ToString() should be the HTML #28
While I think it's a good idea to have .ToString() return a meaningful representation, note that the logic of the Microsoft.PowerShell.MarkdownRender.MarkdownInfo-returning ConvertFrom-Markdown cmdlet is to either fill in the .Html (by default) or the .VT100EncodedString property (if requested via -AsVT100EncodedString).
Thus, it's probably better to do something like [operand order updated after feedback]:
I think HTML construction is the more common / intended use case and should be the default.
It is the default, but the problem is that .Html isn't guaranteed to have a value, and if it doesn't (if -AsVT100EncodedString was used), with your approach would it would string-interpolate to the empty string - and I don't think that's desirable.
Defaulting to whichever property is filled in to me seems like the preferable behavior.
As for multiple overloads: That would be useful in the abstract - say .ToString(MarkdownConversionType.Html), .ToString(MarkdownConversionType.VT100), and (not currently an option) .ToString(MarkdownConversionType.PlainText) - but at least currently makes no sense, as long as only ever one property is filled in.
From what I can tell, while you can currently publicly instantiate a MarkdownInfo instance, you cannot fill it yourself, and therefore have no way of requesting that both.Html and .VT100EncodedString be filled - possibly on demand.
Michael Klement (@mklement0) I get what you're saying here, and I think the best approach would be to make the ToString() conditional depending on which had content.
Activity
fix: MarkdownInfo.ToString() should be HTML ( Fixes PowerShell#28 )
mklement0 commentedon Feb 23, 2024
While I think it's a good idea to have
.ToString()return a meaningful representation, note that the logic of theMicrosoft.PowerShell.MarkdownRender.MarkdownInfo-returningConvertFrom-Markdowncmdlet is to either fill in the.Html(by default) or the.VT100EncodedStringproperty (if requested via-AsVT100EncodedString).Thus, it's probably better to do something like [operand order updated after feedback]:
StartAutomating commentedon Feb 23, 2024
Michael Klement (@mklement0) I'm definitely open to the idea of a flag, as I think both are useful.
However / and, I think that should be the job of a local formatter (which should probably call Show-Markdown)
I think HTML construction is the more common / intended use case and should be the default.
I also think ToString() could have multiple overloads ;-)
mklement0 commentedon Feb 23, 2024
It is the default, but the problem is that
.Htmlisn't guaranteed to have a value, and if it doesn't (if-AsVT100EncodedStringwas used), with your approach would it would string-interpolate to the empty string - and I don't think that's desirable.Defaulting to whichever property is filled in to me seems like the preferable behavior.
As for multiple overloads: That would be useful in the abstract - say
.ToString(MarkdownConversionType.Html),.ToString(MarkdownConversionType.VT100), and (not currently an option).ToString(MarkdownConversionType.PlainText)- but at least currently makes no sense, as long as only ever one property is filled in.From what I can tell, while you can currently publicly instantiate a
MarkdownInfoinstance, you cannot fill it yourself, and therefore have no way of requesting that both.Htmland.VT100EncodedStringbe filled - possibly on demand.StartAutomating commentedon Feb 23, 2024
Michael Klement (@mklement0) I get what you're saying here, and I think the best approach would be to make the
ToString()conditional depending on which had content.fix: MarkdownInfo.ToString() should preferrably be HTML ( Fixes Power…
StartAutomating commentedon Feb 23, 2024
PR updated. Thanks for the feedback!
fix: MarkdownInfo.ToString() should preferrably be HTML ( Fixes Power…
mklement0 commentedon Feb 23, 2024