-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Add support for passing files and markdown directly to Show-Markdown
#7354
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
Add support for passing files and markdown directly to Show-Markdown
#7354
Conversation
iSazonov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with one minor comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we can remove System.IO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The compiler complained that Path type here was confused with the Path parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two more comments:
-
ConvertFrom-Markdown e:\powershell\readme.mdthrows error:A positional parameter cannot be found that accepts argument 'E:\PowerShell\README.md'. I think it should work. -
ConvertFrom-Markdown -Path E:\PowerShell\README.md | Show-Markdownfails with this error:Show-Markdown : The property VT100EncodedString of the given object is null or empty.So,ConvertFrom-Markdownby default only populates HTML, whileShow-Markdownby default show VT100. That feels very inconsistent to me.
Opened issue #7363
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This constructor will create a new Runspace. Please use PowerShell.Create(RunspaceMode.CurrentRunspace) instead, which will use a nested pipeline in the same Runsapce.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use is MarkdownInfo markdownInfo, and pass in markdownInfo instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make it throw an InvalidOperationException. The assertion is not that useful with our current building/testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use Invoke<MarkdownInfo>(), so the output will be MarkdownInfo collection and we can avoid the type comparison in ProcessMarkdownInfo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you address the comments above, this check will no longer be needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error message won't be needed if you address the above comments.
|
@daxian-dbw I think the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick. You don't need to call Stop(). Dispose() will do this for you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ConvertMarkdownStrings.InvalidInputObjectType
I guess this resource string can be removed now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That string is still used by ConvertFrom-Markdown and Set-MarkdownOption cmdlets
PaulHigin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
daxian-dbw
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
72a8800 to
1b467d0
Compare
|
@dantraMSFT CI is failing on macOS oslog tests. I don't see any thing related to the changes I've made. Can you take a look? |
6b9445e to
9f2811e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The message should come from a resource file.
PR Summary
Previously you had to use
ConvertFrom-Markdownand pipe that output toShow-Markdownmaking it cumbersome to use interactively. Added-Pathand-LiteralPathparameters as well as allowing markdown text to passed directly as-InputObject(or via pipeline) toShow-Markdown.Internally,
Show-MarkdownusesConvertFrom-Markdownto handle these new capabilities. Removed the use ofOut-Defaultwhich only passed the resulting vt100 text to the console and instead using WriteObject() so that the output can be redirected or captured by scripts or further in the pipeline. The testhook is still needed when-UseBrowseris specified.Note I had to fully qualify
PowerShellandPathtypes due to conflict withPathparameter andPowerShellnamespace.Fix #7338
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:to the beginning of the title and remove the prefix when the PR is ready.[feature]if the change is significant or affects feature tests