how to create a chm help file for WPF Application? - chm

For a WPF UI application, a CHM Help file needs to be created.
How to create a chm help file?
First create the document in ms word and convert it into chm help file? or any other method?
Please help
Thanks
Ramm

I used Sandcastle Help File Builder (SHFB) to generate the CHM.
To write the content, I followed the guidance and example in the Sandcastle MAML Guide, available on codeplex. This involved me writing doc in a format called "MAML", which is an XML dialect for describing the help files.
It looks like this:
<?xml version="1.0" encoding="utf-8"?>
<topic id="4e9fd731-fc2f-4bdf-9ca2-3a8755411b2f" revisionNumber="1">
<developerConceptualDocument
xmlns ="http://ddue.schemas.microsoft.com/authoring/2003/5"
xmlns:xlink ="http://www.w3.org/1999/xlink">
<!--
<summary>
<para>Optional summary abstract</para>
</summary>
-->
<introduction>
<!-- Uncomment this to generate an outline of the section and sub-section
titles. Specify a numeric value as the inner text to limit it to
a specific number of sub-topics when creating the outline. Specify
zero (0) to limit it to top-level sections only. -->
<!-- <autoOutline /> -->
<para>
</para>
</introduction>
<!-- Add one or more top-level section elements. These are collapsible.
If using <autoOutline />, add an address attribute to identify it
and specify a title so that it can be jumped to with a hyperlink. -->
<section address="Section1">
<title>Section Title</title>
<content>
<!-- Uncomment this to create a sub-section outline
<autoOutline /> -->
<para>
Lorem ipsum dolor sit amet, consectetuer adipiscing
elit. Integer vulputate, nibh non rhoncus euismod, erat odio
pellentesque lacus, sit amet convallis mi augue et
odio. Phasellus cursus urna facilisis quam. Suspendisse nec
metus et sapien scelerisque
</para>
<para>
Quisque pharetra lacus quis sapien. Duis id est
<externalLink>
<linkText>dictum sed, sapien</linkText>
<linkAlternateText>alt text</linkAlternateText>
<linkUri>http://stackoverflow.com/questions/tagged/chm</linkUri>
</externalLink>
</para>
</content>
</section>
<relatedTopics/>
</developerConceptualDocument>
</topic>
In addition to authoring the content on various pages, you need to specify the outline - how all the pages fit together. Once you get it set up it's pretty easy. Then generating the CHM just requires running SHFB.
Don't be put off by the tagname "developerConceptualContent". There's nothing about the .chm generated that makes it useful only for developers.
The SHFB tool is free.

Using word to create your help files is one option. To do this you would need to get hold of the HTML Help SDK from Microsoft (free) and then convert your documents to HTML and compile using the HTML Help compiler.
However there are some good integrated tools that could help you greatly speed up this process. One I've heard good things about is HelpScribbler from JGSoft. It's not free but would save timer over doing things manually.

Related

Why are extra newlines there if pasting into plaintext context 'p' tags copied from browser?

Consider the example
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<p>In sed diam vitae justo laoreet ullamcorper.</p>
<p>Donec vehicula tellus vitae ligula finibus congue.</p>
<p>In ut sapien consectetur, efficitur ante et, interdum leo.</p>
It is rendered in a browser as expected with each paragraph on its own line:
Now when copying this text and pasting it into any plaintext context extra newlines appear:
Should you paste this into formatting-aware application (say LibreOffice Writer) no extra newlines this time:
And finally by copying this from LibreOffice Writer to the first mentioned plaintext editor we can get rid of these extra newlines:
Tried copying from Firefox and Chromium with the same results, so I assume it is universal among browsers.
Those screenshots were made on GNU/Linux with Geany and LibreOffice Writer. Absolutely the same behaviour is observed under MS Windows with Notepad++ and MS Office Word.
The questions are:
Why is it that newlines are added if pasting into plaintext application?
Is there any way to get rid of them if pasting into plaintext application?

Tools to combine several HTML files into one

I am working on an HTML theme that contains several HTML templates with the same navigation panel, footer and assets. The problem is when I modify something in a footer, for example, I have to edit all other templates one by one to bring them into line. Is there any tools to automate this procees? Thanks in advance.
EDIT: I'm not aware if you can do this in normal HTML, but if you don't like my suggested method, you can check out .load() from Jquery: $(“#header”).load(“header.html”);
Sure. You can use something like Middleman or Jekyll for simple websites. It's very easy to learn and you can have a general layout, multiple layouts and even partials. Basically you're going to make a _footer.erb and render it in the layout.
If you have multiple pages like about, contact etc, and the structure of your website is not going to change (only content), I suggest you to use one layout and create some views that are yielded in there. It's a easy concept, you can learn it with middleman in few hours.
EDIT2:
How to use this
layout.haml:
%body
%header
%nav
= link_to 'index', '/index.html'
= link_to 'about', '/about.html'
= link_to 'contact', '/contact.html'
%section#wrapper
= yield
%footer
Something here
about.html.haml
%h2
About Us
%p
............
contact.html.haml
%h2
Contact
%p
Constact us at Lorem ipsum dolor sit amet,
consectetur adipiscing elit. Donec sit amet placerat nisi.
Maecenas sollicitudin ut nisl a faucibus. Etiam et cursus eros.
Nulla ut tortor aliquam, rutrum diam vitae, posuere ante.
Basically you create a layout that goes for all pages and yield the content from other pages into it. Of course you can have multiple layouts and invoke different headers and footers from partial files but this is not the case you asked.
This is haml, middleman by default uses erb. You can convert this here if you need it.
I hope is clear enogh

Visual Studio - how to quickly wrap text in HTML tags?

The new HTML editor in VS 2013 removed WYSIWYG mode and the Formatting toolbar is disabled. This is for the good, generally, but it also made simple edits like making some text bold or italics harder.
What I currently do to make some text bold is:
Type <b>
VS autocompletes </b>
I select the end tag and press Ctrl+X
I go to the end of the text that should be bold and press Ctrl+V
This is much less convenient than just pressing Ctrl+B or something similar. I know there is the "Surround with" command in Visual Studio, there are customizable keyboard shortcuts etc. so my hope is that the Ctrl+B functionality can somehow be achieved in Visual Studio. Is there some clever trick or am I possibly missing something other, rather simple?
Web Essentials 2013 has a Surround with tag... feature (Alt+Shift+W) that is more fluid than the built-in Surround with. I'm probably just going to stick with it as I am using Web Essentials anyway.
A good suggestion from How to quickly surround text with HTML markup in VS 2008? is this:
Select your text
Press Ctrl+X to cut it to clipboard
Type your <strong> tag, which Visual Studio will automatically close with your cursor remaining in the middle of the start and end tag
Press Ctrl+V to re-insert your text between the tags
You could also add a custom snippet (I don't know why Visual Studio didn't provide a snippet for the strong tag by default).
To create the snippet:
Create a text file in C:\Users\USERNAME\Documents\Visual Studio 2013\Code Snippets\Visual Web Developer\My HTML Snippets named strong.snippet
Place the following text inside the text file:
strong
YOUR NAME
strong
Markup snippet for a strong text
Expansion
SurroundsWith
$selected$$end$]]>
To use the snippet:
Select your text
Right-click text and choose "Surround With...", or press Ctrl-K,Ctrl-S
Open "My HTML Snippets" folder in the popup menu and choose your strong snippet
It is also possible to put the Surround With command (in the Edit category) in a toolbar.
Create an HTML Custom Code-Snippet in Visual Studio
1. Create a new .xml file
2. Use the following snippet template:
<CodeSnippet Format="1.1.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<!-- HTML Anchor Snippet -->
<Header>
<Title>P</Title>
<Author>Microsoft Corporation</Author>
<Shortcut>P</Shortcut>
<Description>Markup snippet for a Paragraph</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>Paragraph</ID>
<ToolTip>Paragraph</ToolTip>
<Default>p</Default>
</Literal>
<Literal>
<ID>selected</ID>
<ToolTip>content</ToolTip>
<Default>content</Default>
</Literal>
</Declarations>
<Code Language="html"><![CDATA[<p>$selected$</p>$end$]]></Code>
</Snippet>
</CodeSnippet>
3. Give a name to your snippet, and save-it-as using(YourFileName.snippet) extention
Add snippet to Visual Studio
1. Use Code Snippets manager: Go to: Tools/Code Snippets Manager/
2. Choose HTML from a DropDown list, and open HTML folder by DoubleClick on it.
4. Click Import button, and browse to your newly .snippet file
Use Your Custom Snippet
1. Select some text in the Text-Editor.
2. use combination of CTRL+K CTRL+X to open Insert Snippet dialog window
3. Choose HTML from a DropDown list where you previously saved your .snipped file
4.
Choose your custom snippet from a list. It should now wrap your text with <p></p> tag for example
★ Follow the above procedure again for creating a new snippents.
☀ Read More about custom snippets
☕ HINT (just like in Sublime text editor build in feature) You could create a Lorem Ipsum custom snippet just like this in a seconds:
<CodeSnippet Format="1.1.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<!-- HTML Anchor Snippet -->
<Header>
<Title>LoremIpsum</Title>
<Author>Microsoft Corporation</Author>
<Shortcut>Lorem</Shortcut>
<Description>Markup snippet for a Lorem Ipsum</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>Lorem</ID>
<ToolTip>LoremIpsum</ToolTip>
<Default>Lorem</Default>
</Literal>
<Literal>
<ID>selected</ID>
<ToolTip>content</ToolTip>
<Default>content</Default>
</Literal>
</Declarations>
<Code Language="html"><![CDATA[$selected$Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus blandit nunc eget consectetur aliquet. Vivamus feugiat ipsum ex, eget egestas erat condimentum eget. Suspendisse luctus velit ac purus venenatis imperdiet sed vel mauris. Ut tempus risus elit, eget molestie purus hendrerit a. Curabitur ac urna posuere, lacinia neque quis, facilisis libero. Cras viverra tellus eu lacus hendrerit, in auctor neque sodales. Pellentesque et finibus lectus. Vestibulum pulvinar, lorem in dignissim fermentum, nunc ipsum luctus arcu, non malesuada nisi sem nec libero. Integer eget arcu interdum, elementum lacus et, ornare arcu. Phasellus quis nulla non enim porta ornare non eget ex. Mauris at purus sed ipsum congue facilisis. Donec tempor, eros ac posuere tempus, velit sapien faucibus augue, vitae convallis augue nulla ut felis. Nunc sapien libero, dictum non finibus nec, rutrum at odio. Nulla facilisi. $end$]]></Code>
</Snippet>
</CodeSnippet>
☕ HINT
You Can create almost any code snippet you want by providing a language="" property, and by setting up right description in<code> section
The following is the example of a JavaScript Alert() function code snippet
<Code Language="JavaScript"><![CDATA[alert($selected$);$end$]]></Code>
Click on the tag you want to wrap, then hit Ctrl+Alt+W.
In visual studio code you can use the extension by name htmltagwrap
Link
https://marketplace.visualstudio.com/items?itemName=bradgashler.htmltagwrap
Installation Options
Option 1. Search for htmltagwrap in VS Code extensions tab and install it.
Option 2. Go to the marketplace link mentioned above and click on install, it will prompt you to open it with VS Code and once you do that it'll be installed.
Usage
Select one or more blocks of text or strings of text.
Press Alt + W or Option + W for Mac.
Type the tag name you want.

Global RegEx search and replace to fix HTML in an XML export file?

I have a fairly large WordPress .XML export file from a blog that I am going to migrate to Drupal. One glaring issue with the export file is that it's missing <p> tags for any paragraph breaks. However, the tags are present on the actual site.
From what I can see from the raw text in the XML file, there are multiple line breaks between paragraphs where there should have been a single <p> tag. I was hoping to globally add in a <p> tag where there's a line break and a capital letter using RegEx but I don't have a working knowledge of how that works. A sample XML tag in the export file that contains the text in question is:
<content:encoded><![CDATA[Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur gravida risus at sem interdum iaculis. Curabitur eget est tellus, quis viverra arcu.
Cras posuere turpis imperdiet odio aliquet sollicitudin. Maecenas et neque eget quam fringilla tempor. Vivamus sodales vulputate consectetur.
Sed ullamcorper elementum est, at dapibus orci fermentum vitae. Vivamus nisi turpis, pretium sed tincidunt et, dapibus at eros. Quisque neque magna, posuere eget eleifend ut.
As you can see from the above, there are multiple line breaks in between what should be paragraphs. I was thinking of the line break / capital letter combo for the RegEx so as to only put in one <p> tag and also target specifically the <content:encoded> XML tag so that I don't add tags elsewhere in the XML file. One other issue to make things more complicated is that some paragraphs already have <p> tags where the editor added in a custom class like <p class="myclass">.
This issue was discussed on StackOverflow somewhere before. Problem is, that Wordpress doesn't store the p tags in its database (if you use its WYSIWYG editor), these tags are created upon rendering by wpautop() function (instead of breaks). So I edited the export.php file (running WP 3.4.1) and added the function there. You can see the result on Pastebin (changes are on lines 375 and 376).
<content:encoded><?php echo wxr_cdata( apply_filters( 'the_content_export', wpautop( $post->post_content ) ) ); ?></content:encoded>
<excerpt:encoded><?php echo wxr_cdata( apply_filters( 'the_excerpt_export', wpautop( $post->post_excerpt ) ) ); ?></excerpt:encoded>
You can copy and paste the whole code in file [root]/wp-admin/icludes/export.php and run the export again. Don't forget to backup the file before - I don't guarantee it will work other versions, but you can get the idea how to edit the export.

Storing cached data - what amount of formatting?

I am in the middle of a web app and we're just about to start with a cache-layer that features memcache and disk-based cache.
We just questioned ourself - what level/amount of formatting should we use on the stored cache data?
Let say that we have a database table called articles. Articles table have a number of columns including headline and content.
If we we're about to store this as an array, it would look like this:
array (
'headline' => 'Brilliant news - sunshine all week',
'content' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis a
semper mi. Aenean rutrum ultrices mauris sed dictum. ');
Or, the pre-formatted HTML version:
<div class="article">
<h1>Brilliant news - sunshine all week</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis a
semper mi. Aenean rutrum ultrices mauris sed dictum. </p>
</div>
Pros and cons
Obviously, the pre-formatted html version increases the size of each cached datablock, since it includes a number of html tags. Also, there will be some headache included if the data were about to be formatted in different ways (I don't think that we will do this though). The option for that is of course to instead store multiple versions of each article in the cache.
So, what's common sense to do in our case? Let the HTML be rendered each time based upon the array that are retrieved from memcache, or just output the pre-formatted html?
I think it all depends on performance you need but I would use array version as it give possibility to play with content before rendering. Also building HTML having content is usually quite cheap when compared to getting content itself.