PK Tip: Exporting HTML Code Snippets

One common use for Personal Knowbase is to store code snippets, specifically in this case HTML code snippets.

However, if you try to export an article containing HTML using the export file type HTML Files, you end up with garbage. For example, let’s say you have an article containing this text:

<P>Hello world</P>

If you export it to HTML, you end up with a file including code like this, along with other junk:

<FONT FACE=”Verdana” SIZE=”1″ COLOR=”#000000″>&lt;P&gt;Hello world&lt;/P&gt;<br></FONT>

When loaded into a browser, this file shows you what the article looked like in PK, that is, showing the HTML code as text rather interpreting the HTML code.

But more likely, we want to create an HTML file that will actually load into a browser, showing just the message without the code:

Hello World

To do that:

  • Open the article.
  • Select the Export command from the File menu.
  • In the Export Article Setup dialog box, make sure that the Export Range is set to Current Article.
  • Under the Export What header, un-check all checkboxes except Include Article Content.

    Export Setup dialog box

  • Click OK.
  • In the Export Articles dialog box, under Save as type, select the Text Files option.
  • In the File name field, type your desired file name and explicitly add the extension “.htm”. For example, if your file name is “temp”, type in temp.htm.
  • Click Save.

Your exported file has the desired “htm” file type that can be loaded into your browser, but without the extra formatting which would have been added by the HTML export type.

Leave a Reply

Your email address will not be published. Required fields are marked *