<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Huddled Masses &#187; Html</title>
	<atom:link href="http://huddledmasses.org/tag/html/feed/" rel="self" type="application/rss+xml" />
	<link>http://huddledmasses.org</link>
	<description>You can do more than breathe for free...</description>
	<lastBuildDate>Sat, 28 Jan 2012 21:37:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<cloud domain='huddledmasses.org' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
		<item>
		<title>Rich formatting for PowerShell help</title>
		<link>http://huddledmasses.org/rich-formatting-for-powershell-help/</link>
		<comments>http://huddledmasses.org/rich-formatting-for-powershell-help/#comments</comments>
		<pubDate>Sat, 28 Jan 2012 03:54:33 +0000</pubDate>
		<dc:creator>Joel 'Jaykul' Bennett</dc:creator>
				<category><![CDATA[Huddled]]></category>
		<category><![CDATA[Help]]></category>
		<category><![CDATA[Html]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[ShowUI]]></category>

		<guid isPermaLink="false">http://huddledmasses.org/?p=1802</guid>
		<description><![CDATA[[updated] Ok, I just updated this with a new post on PoshCode. I posted the HtmlHelp module to PoshCode for generating HTML web pages based on the help for functions or cmdlets. It basically has one command: Get-HtmlHelp, which takes a couple of parameters now. The only mandatory parameter is the name of the command [...]]]></description>
			<content:encoded><![CDATA[	<p><strong>[updated]</strong> Ok, I just updated this with a new post on PoshCode.  I posted the <a href="http://poshcode.org/3197">HtmlHelp</a> module to PoshCode for <em>generating <span class="caps">HTML</span> web pages based on the help for functions or cmdlets</em>. It basically has one command: Get-HtmlHelp, which takes a couple of parameters now.  The only mandatory parameter is the name of the command you want help for, in this case the html is output on the pipeline and can be redirected into a file.</p>

	<div class="posh code posh" style="font-family:monospace;"><span style="color: #0066cc; font-style: italic;">Get-<span style="font-style: normal;">HtmlHelp</span></span> <span style="color: #0066cc; font-style: italic;">Get-<span style="font-style: normal;">HtmlHelp</span></span> <span style="color: #66cc66;">|</span> <span style="color: #0066cc; font-style: italic;">Set-<span style="font-style: normal;">Content</span></span> <span style="color: #0066cc; font-style: italic;">Get-<span style="font-style: normal;">HtmlHelp</span></span>.<span style="color: #003366;">html</span><br />
&nbsp;</div>

	<p>The markup generated is (I hope) reasonable and lightweight, with some simple css rules pre-applied.  Feel free to customize the script to generate help however you like.  </p>

	<h2><strong> <img src='http://huddledmasses.org/wordpress/wp-includes/' alt='[new]' class='wp-smiley' /> </strong> Generating many at once</h2>

	<p>I forgot to mention the other parameters on Get-HtmlHelp. They&#8217;re pretty cool, because if you want to upload your help you can do so with this. Say you created a module, and you wanted to generate all the help into files for uploading.  You want to set the <code>-BaseUrl</code> to the location you will upload them to, and then use the <code>-OutputFolder</code> parameter to generate an html file for each command into the specified folder:</p>

	<div class="posh code posh" style="font-family:monospace;"><span style="color: #0066cc; font-style: italic;">Get-<span style="font-style: normal;">Command</span></span> <span style="color: #000066;">-Module</span> ModuleName <span style="color: #66cc66;">|</span> <br />
<span style="color: #0066cc; font-style: italic;">Get-<span style="font-style: normal;">HtmlHelp</span></span> <span style="color: #000066;">-BaseUrl</span> http:<span style="color: #66cc66;">//</span>HuddledMasses.<span style="color: #003366;">org</span><span style="color: #66cc66;">/</span>HtmlHelp<span style="color: #66cc66;">/</span> <span style="color: #000066;">-OutputFolder</span> ~\sites\HuddledMasses\HtmlHelp\<br />
&nbsp;</div>

	<p>Now you can just take those files and upload them to the right spot on your website. I actually have some scripts which I can wrap around this to post the help to a wiki, but you&#8217;re just going to have to wait for that until the next time I get inspired to work on help &#8230;</p>

	<h3>Show-Help</h3>

	<p>I did include a little function in the comments and in the help for Get-HtmlHelp which uses <a href="http://ShowUI.CodePlex.com">ShowUI</a> to display the rich formatted help in a popup window:</p>

	<div class="posh code posh" style="font-family:monospace;"><span style="color: #666699; font-weight: bold;">function</span> <span style="color: #0066cc; font-style: italic;">Show-<span style="font-style: normal;">Help</span></span> <span style="color: #333;">&#123;</span><br />
<span style="color: #333;">&#91;</span>CmdletBinding<span style="color: #333;">&#40;</span><span style="color: #333;">&#41;</span><span style="color: #333;">&#93;</span><br />
<span style="color: #666699; font-weight: bold;">param</span><span style="color: #333;">&#40;</span><span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span><span style="color: #003366; font-weight: bold;">String</span><span style="color: #333;">&#93;</span></span><span style="color: #660033; font-weight: bold;">$Name</span><span style="color: #333;">&#41;</span> &nbsp;<br />
&nbsp; &nbsp;Window <span style="color: #333;">&#123;</span> WebBrowser <span style="color: #000066;">-Name</span> wb <span style="color: #333;">&#125;</span> <span style="color: #000066;">-On_Loaded</span> <span style="color: #333;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; <span style="color: #660033; font-weight: bold;">$wb</span>.<span style="color: #003366;">NavigateToString</span><span style="color: #333;">&#40;</span><span style="color: #333;">&#40;</span><span style="color: #0066cc; font-style: italic;">Get-<span style="font-style: normal;">HtmlHelp</span></span> <span style="color: #660033; font-weight: bold;">$Name</span><span style="color: #333;">&#41;</span><span style="color: #333;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #660033; font-weight: bold;">$this</span>.<span style="color: #003366;">Title</span> <span style="color: #66cc66;">=</span> <span style="color: #009900;">&quot;Get-Help $Name&quot;</span><br />
&nbsp; &nbsp;<span style="color: #333;">&#125;</span> <span style="color: #000066;">-Show</span><br />
<span style="color: #333;">&#125;</span><br />
&nbsp;</div>

	<p>So anyway, enough of that. When you run it, it looks like this (click for the full screenshot):</p>

	<p><a href="http://joelbennett.net/wordpress/wp-content/uploads/2012/01/Show-Help.png"><img src="http://joelbennett.net/wordpress/wp-content/uploads/2012/01/Show-Help-Mini.png" alt="Click to see full screen-shot" title="Show-Help" width="630" height="486" class="alignright size-full wp-image-1804" /></a></p>]]></content:encoded>
			<wfw:commentRss>http://huddledmasses.org/rich-formatting-for-powershell-help/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Converting HTML to XML in PowerShell</title>
		<link>http://huddledmasses.org/converting-html-to-xml-in-powershell/</link>
		<comments>http://huddledmasses.org/converting-html-to-xml-in-powershell/#comments</comments>
		<pubDate>Fri, 16 Nov 2007 21:40:32 +0000</pubDate>
		<dc:creator>Joel 'Jaykul' Bennett</dc:creator>
				<category><![CDATA[Huddled]]></category>
		<category><![CDATA[Cmdlet]]></category>
		<category><![CDATA[Converting]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Html]]></category>
		<category><![CDATA[Parsing]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Xml]]></category>

		<guid isPermaLink="false">http://HuddledMasses.org/converting-html-to-xml-in-powershell/</guid>
		<description><![CDATA[I&#8217;ll write up more information later, but a couple people have asked for this in #PowerShell on irc.freenode.net, and I had it already written, so here you go &#8230; my ConvertFrom-Html cmdlet (in a Huddled.HtmlSnapin). It converts HTML to valid xml using the SGML Parser which was available on GotDotNet years ago. It only works [...]]]></description>
			<content:encoded><![CDATA[	<p>I&#8217;ll write up more information later, but a couple people have asked for this in #PowerShell on irc.freenode.net, and I had it already written, so here you go &#8230; my ConvertFrom-Html cmdlet (in a Huddled.HtmlSnapin). It converts <span class="caps">HTML</span> to valid xml using the <span class="caps">SGML</span> Parser which was available on GotDotNet years ago. It only works with files (doesn&#8217;t do <span class="caps">URL</span> downloads yet). Use it like this:</p>

	<div class="posh code posh" style="font-family:monospace;"><br />
<span style="color: #660033; font-weight: bold;">$url</span> <span style="color: #66cc66;">=</span> <span style="color: #009900;">&quot;http://huddledmasses.org/&quot;</span><br />
<span style="color: #660033; font-weight: bold;">$file</span> <span style="color: #66cc66;">=</span> <span style="color: #0066cc; font-style: italic;">Join-<span style="font-style: normal;">Path</span></span> <span style="color: #660033; font-weight: bold;">$pwd</span> <span style="color: #009900;">&quot;HuddledMasses.html&quot;</span><br />
<br />
<span style="color: #660033; font-weight: bold;">$client</span> <span style="color: #66cc66;">=</span> <span style="color: #0066cc; font-style: italic;">new-<span style="font-style: normal;">object</span></span> System.<span style="color: #003366;">Net</span>.<span style="color: #003366;">WebClient</span><br />
<span style="color: #660033; font-weight: bold;">$client</span>.<span style="color: #003366;">DownloadFile</span><span style="color: #333;">&#40;</span> <span style="color: #660033; font-weight: bold;">$url</span>, <span style="color: #660033; font-weight: bold;">$file</span> <span style="color: #333;">&#41;</span> <span style="color: #666666; font-style: italic;">#NOTE: You need to use a full path here, not relative</span><br />
<br />
<span style="color: #660033; font-weight: bold;">$xml</span> <span style="color: #66cc66;">=</span> <span style="color: #0066cc; font-style: italic;">ConvertFrom-<span style="font-style: normal;">Html</span></span> <span style="color: #660033; font-weight: bold;">$file</span><br />
<br />
<span style="color: #666666; font-style: italic;"># Or even</span><br />
<span style="color: #333;">&#40;</span><span style="color: #0066cc; font-style: italic;">ConvertFrom-<span style="font-style: normal;">Html</span></span> <span style="color: #660033; font-weight: bold;">$file</span><span style="color: #333;">&#41;</span>.<span style="color: #003366;">Save</span><span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$file</span><span style="color: #333;">&#41;</span></div>

	<p>The source code to my plugin may be considered public domain, and is included in <a href="http://HuddledMasses.org/wordpress/wp-content/uploads/2007/11/huddledhtmlsnapin.zip">the Huddled <span class="caps">HTML</span> SnapIn Zip</a>.  </p>

	<p><del>However, the SgmlReader library is a Microsoft Sample which is licensed under <a href="http://dev.live.com/sampleseula.aspx">the old MS Samples license</a> which doesn&#8217;t allow reuse with viral open source software. I&#8217;ve seen some work being done on an <a href="http://www.codeplex.com/htmlagilitypack">HtmlAgilityPack</a> on CodePlex (using a Creative Commons <a href="http://www.codeplex.com/htmlagilitypack/Project/License.aspx"><span class="caps">ASA</span> license</a>) but I have not really looked at it except to see that it has a several active issues related to entity encoding and dropping malformed tags which I haven&#8217;t encountered in SgmlReader &#8230;</del></p>

	<p>The <a href="http://code.msdn.microsoft.com/SgmlReader">SGMLReader</a> library has been re-released on <a href="http://code.msdn.microsoft.com/"><span class="caps">MSDN</span> Code Gallery</a> under an Ms-PL license, and all is well with the world.  <img src='http://huddledmasses.org/wordpress/wp-includes/' alt=':D' class='wp-smiley' /> </p>]]></content:encoded>
			<wfw:commentRss>http://huddledmasses.org/converting-html-to-xml-in-powershell/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

