Writerside Help

Reuse pieces of content

To avoid writing the same content in different places, you can reuse any piece of content by including it anywhere you need. This works both for semantic and Markdown markup.

For example, notes and warnings that need to be repeated in various places are good candidates for content reuse. When you update the original piece of content, Writerside will update it in all places where it is included, saving you from having to update it manually.

Make a piece of content reusable

There are three ways to make a piece of content available for reuse:

  • Assign an identifier to any element and reuse it by an ID. This is fine for simple elements that you only reuse in one or two other places.

  • To reuse multiple elements, surround them with a <snippet> element and assign an identifier to it. Works well when you reuse a complex fragment made of a few elements.

  • The preferred way is to keep all your reusable content in a separate topic used as a library and include them from there. Surround each reusable element or fragment with a <snippet> element.

Reuse a single element

  • Add the id attribute to the element, for example, a warning:

    <warning id="generic-warning">This version support ended on January 14, 2022. Download the latest version.</warning>
    > This version support ended on January 14, 2022. > Download the latest version. > {style="warning" id="generic-warning"}

Reuse a fragment with multiple elements

  • Surround the elements with a <snippet> and assign a unique value for the id attribute:

    <snippet id="prerequisites"> <p>Make sure you are logged in the account.</p> <img src="screenshot1.png" alt="Check login" border-effect="line" width="436"/> </snippet>
    <snippet id="prerequisites"> Make sure you are logged in the account. ![Check login](screenshot1.png) {border-effect="line" width="436"} </snippet>

Store snippets in a dedicated library topic

  1. Create a separate topic file.

  2. Add the is-library="true" attribute to the topic element for semantic markup or after the first # element for Markdown. Library topics are not included in the table of contents.

    <topic title="Warnings" id="Warnings_library" is-library="true">
    # Warnings {is-library="true"}
  3. Surround a reusable content fragment with a <snippet> element and assign a unique value for the id attribute:

    <snippet id="generic_warning"> <warning>This version support ended on January 14, 2022. Download the latest version.</warning> </snippet>
    <snippet id="generic_warning"> > This version support ended on January 14, 2022. > Download the latest version. > >{style="note"} </snippet>

You can move a snippet from an ordinary topic to a library or between libraries quicker using the Move a snippet action.

  1. Place the caret at the <snippet> you want to move.

  2. From the main menu, select Refactor | Move Snippet....

    The Move a snippet dialog opens.

  3. In the To a file, select a topic where you want to move a snippet.

  4. Click OK to proceed or Review usages to check the results before the actual refactoring.

All usages of the snippet will be updated.

Include reusable content

You can reuse the snippet with the same ID multiple times, even in the same topic.

  • To reuse a piece of content, add the <include> element with the following attributes

    • from: specify the topic where the reusable content resides

    • element-id: specify the ID of the element you want to include

    <include from="warning_library.topic" element-id="generic-warning"/>

You can use the <include> element in both semantic markup and Markdown topics.

You can also specify filters in the use-filter attribute if you want to include only certain parts of the snippet. For more information, see Filter included content by custom conditions.

If there are variables defined in the snippet, set their values as child elements of the <include> element. For more information, see Variables.

Last modified: 14 May 2024