The
Insert Snippet tool in enables you to insert the contents of another topic or a Help & Manual XML file at the cursor position. You can insert topics and files from the current project, from other Help & Manual projects (some restrictions in the Standard version of H&M) and from collections of Help & Manual XML files. This means that you can build up a library of reusable content that you can access very easily.
You can insert snippets in two different modes, Copy and Link. Copy mode is like normal copy & paste – it pastes the contents of the topic or file at the cursor position and you can then edit it. Link mode creates a live link to the snippet file. To edit the snippet you must then edit the original topic or file, but then it updates automatically in all the places where you have inserted it, even if you are using it in multiple projects.
Productivity Tip
If you send your project for translation remember to include any external snippet files you have referenced, otherwise the translator won't see them!
|
You can insert topics and XML files into your current topic at the cursor position. These topics can be inserted in Copy mode or Link mode. In Link mode the snippet content updates automatically when the source topic or XML file is edited.
The topics can be in your current project, another Help & Manual project or a directory of H&M XML files.
| 1. | Click in your topic where you want to insert the snippet. |
| 2. | Select the Insert Snippet tool in |
| 3. | Choose From Topic to insert a topic from the current project or From File to insert an external H&M XML file or a topic from another project. (You can also insert XML topic files from the current project if you want.) |
| • | Copy & Paste inserts a copy of the file that you can then edit. |
| • | Linked creates a live link to the file – changes in the source file or topic are updated automatically. |
| • | You can also insert XML files from your current project instead of using the From Topic mode. This is only possible when your topic is saved as uncompressed XML (Professional version only). |
| 4. | Select the topic or file you want to insert and click on OK to insert it. |
"Use project search path to locate snippet"
This option adds the location of the snippet file to the project search path – if you deselect it the path to the snippet is stored with the snippet.
Rather than using snippets from many locations it is better to store all your snippet files in a common location. This will make them easier to manage, particularly if you ever need to move your project or have it translated.
|
You can export selected text or the current topic to an external XML file, for example for use as a snippet in a snippet directory.
Export the entire topic:
| 1. | Select the topic you want to export in the Project Explorer (TOC or Topic Files). |
| 2. | Select File > Save Topic to File in and choose the save location. |
Export selected text:
| 1. | Select text in the editor – the text can include anything that a topic can contain, i.e. also images, tables, etc. |
| 2. | Select File > Save Snippet in and choose a save location and a filename. |
If you save in the uncompressed XML format you can also copy the XML files directly from your project directory to other locations in Windows Explorer (Professional version only).
|
You can insert snippets from any location. However, if you use snippets from many locations your linked snippets will not be displayed if you move your project or send it to someone by email. You can solve this problem by storing your snippet files together with your project in a special directory.
| 1. | Create a folder for your snippets in a location where you can easily transport it together with your project folder. |
| 2. | Add the path to the snippets folder to your Project Search Path in your project's Configuration > Common Properties settings. |
| 3. | When you insert a snippet select the Use project search path to locate snippet option to tell Help & Manual to look for the snippet files in the folders listed in the Project Search Path. |
When you do this you can always move your snippets folders to any location you like. To get Help & Manual to find the snippets you just need to add the new location to your project search path.
|
When you use topic files from your current project as snippets you will generally want to exclude the source files from your published output. If you don't do this these files will be published and the user will able to find them with Search in formats like HTML Help and Webhelp.
| 1. | Select the entry of the topic file in the Project Files section of the Project Explorer. |
| 2. | In select Change > Include in Builds and deselect all build options. This will ensure that these topics will never be included when you publish your project. |
This is not necessary for snippets inserted from other projects or external XML files, of course!
|
There are two ways to edit the content of a snippet file in Help & Manual. Which you use depends on whether the snippet contains a small or large amount of text.
Editing small snippets:
| 1. | Press ENTER a couple of times to create some space in the current topic. |
| 2. | Insert the snippet file you want to edit in Copy & Paste mode (see above) and make the necessary changes. |
| 3. | Select the edited text and export it as a snippet, overwriting the original snippet file (see above). |
Editing larger snippets:
| 1. | Create an empty dummy topic in the TOC. |
| 2. | Select File > Load Topic from File in and load the snippet file. |
| 3. | Edit the content and then select File > Save Topic to File and overwrite the original snippet file. |
|
If a linked snippet contains an anchor (jump target) you can link to it from other topics. However, since the snippet file is not really inserted in the current topic you cannot select the anchor from the drop-down list next to the Target: field in the Insert Hyperlink dialog. You need to enter the anchor name manually.
| 1. | Make a note of the name of the anchor you want to link to. |
| 2. | Create a normal hyperlink to the topic containing the linked snippet. |
| 3. | Double-click on the hyperlink to edit it and type in the name of the anchor in the drop-down list box next to the Target: field. |
| 4. | Publish your project and test the link to make sure that it works. |
You won't have this problem with snippets inserted in Copy mode because the text containing the anchor is inserted in the topic directly.
|
You can use the Find Referrers function to check where a topic file is being used as a linked snippet. You can also use the same function to find the location of the linked snippet topic files inserted in the current topic.
This only works for topic files used as snippets in the current project. It won't work across multiple projects or for XML files that are not part of projects.
| 1. | In the Project Explorer select the topic file – either a file containing a linked snippet or a file that you think is being used as a linked snippet. |
| 2. | Select Find > Find Referrers in (or just right-click and select Find Referrers). |
| 3. | The sources of linked snippets in the topic are shown as incoming links. Topics in which the topic is used as a linked snippet are shown as outgoing links. |
|
If snippet files are H&M topic files containing index keywords the keywords are imported when you use Link mode. A-keywords are not supported in snippets, however.
Keywords are not imported with snippets in Copy & Paste mode.
|
See also:
Multiple TOC entries for one topic
Snippets and multiple TOC references
Topic include options
Anchors - jump targets
Page url:
http://www.helpandmanual.com/help/index.html?hm_working_topics_snippets.htm