Skip to content

Conversation

@SteveL-MSFT
Copy link
Member

@SteveL-MSFT SteveL-MSFT commented Jul 25, 2018

PR Summary

Previously you had to use ConvertFrom-Markdown and pipe that output to Show-Markdown making it cumbersome to use interactively. Added -Path and -LiteralPath parameters as well as allowing markdown text to passed directly as -InputObject (or via pipeline) to Show-Markdown.

Internally, Show-Markdown uses ConvertFrom-Markdown to handle these new capabilities. Removed the use of Out-Default which 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 -UseBrowser is specified.

Note I had to fully qualify PowerShell and Path types due to conflict with Path parameter and PowerShell namespace.

Fix #7338

PR Checklist

Copy link
Collaborator

@iSazonov iSazonov left a 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.

Copy link
Collaborator

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.

Copy link
Member Author

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.

Copy link
Member

@daxian-dbw daxian-dbw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two more comments:

  1. ConvertFrom-Markdown e:\powershell\readme.md throws error: A positional parameter cannot be found that accepts argument 'E:\PowerShell\README.md'. I think it should work.

  2. ConvertFrom-Markdown -Path E:\PowerShell\README.md | Show-Markdown fails with this error: Show-Markdown : The property VT100EncodedString of the given object is null or empty. So, ConvertFrom-Markdown by default only populates HTML, while Show-Markdown by default show VT100. That feels very inconsistent to me.

Opened issue #7363

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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.

@SteveL-MSFT
Copy link
Member Author

@daxian-dbw I think the ConvertFrom-Markdown issues you bring up should be a separate issue

Copy link
Contributor

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.

Copy link
Member

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.

Copy link
Member Author

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

Copy link
Contributor

@PaulHigin PaulHigin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@daxian-dbw daxian-dbw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@SteveL-MSFT
Copy link
Member Author

@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?

Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Showing markdown with new commands is harder than it should be

5 participants