Raw code library items provide a way to add custom code or text to the generated documentation. They can include HTML, CSS, JavaScript, Markdown, or plain text content, either stored directly in the HelpNDoc project or loaded from an external file at generation time.

The content used depends on the output format:

They can be useful in multiple situations:

Note: Raw code library items replace the former HTML code library items. Existing HTML code library items can now be used as raw code items, with additional content options for Markdown and plain text output. Extra care should be taken when inserting HTML, CSS, or JavaScript code, as compatibility can vary between browsers, help viewers, and eBook readers.

Overview of the user interface

1. Library item name

Enter a unique name for the raw code library item. This name is used to identify the item in the library and when inserting it into topics.

2. Item type

Choose how the raw content should be provided:

3. Actions menu

Click the menu button to access additional actions for the raw code content. From this menu, you can load raw code content from a file, save the current raw code content to disk, or clear the current content.

4. Formats tabs

Select the type of raw content to edit:

5. Code editor

Insert or edit the raw content for the selected format. The content is exported as-is in the documentation format it applies to, without conversion or validation by HelpNDoc.

HTML raw code

Use the HTML tab to enter custom HTML, CSS, or JavaScript code for HTML-based outputs such as CHM, HTML, ePub, Kindle, and Qt Help. This content is exported as-is.

Example:

<div class="custom-note">
  <strong>Tip:</strong> This custom note is inserted as raw HTML.
</div>

<style>
  .custom-note {
    border: 1px solid #cccccc;
    padding: 10px;
    background: #f8f8f8;
  }
</style>


Markdown raw code

Use the Markdown tab to enter Markdown content for Markdown output. This can include formatted text, tables, code blocks, Mermaid diagrams, or any Markdown syntax supported by the target Markdown processor. This content is exported as-is.

Example:

## Process overview

```mermaid
flowchart TD
  A[Start] --> B[Generate Markdown documentation]
  B --> C[Publish output]
```

```javascript
console.log("Sample code block exported as Markdown");
```


Text raw code

Use the Text tab to enter plain text content for formats that do not use HTML or Markdown, such as Word and PDF. This content is exported as-is.

Example:

Tip: This note is inserted as plain text in Word and PDF documentation.