Embed Code from an External Source
You can set your help content to use the latest code samples from a repository, such as GitHub or BitBucket. Once set up, your HTML5 help will be able to update code samples automatically, without being republished.
Note
The code samples need to be in an "https" URL.
Tip
For embedding Swagger/Open API code, see Embed Swagger OpenAPI.
Use dynamic code snippets to have your HTML5 output to use "live" code snippets from a repository.
-
Select Layout in the top menu.
-
Select the Layout you want to update or Create a Layout.
Tip
You can copy the URL of the Layout Editor and paste it into a new tab in your browser. This can be useful if you frequently switch between your Paligo content and the Layout settings.
-
Select Classes and attributes in the sidebar.
-
Select Enable for Output 'role' attribute as class names.
-
Select Save.
-
Select the topic or component in the Content Manager to open it in the Editor.
-
Select the position where you want the code to appear.
-
Press Alt + Enter ⏎ (Windows) or Command ⌘ + Enter ⏎ (Mac) to display the Element Context Menu.
-
Add a code block element, either
programlisting
orscreen
. -
Select the
programlisting
orscreen
element in the topic.Tip
You can add a
programlisting
element with these attributes added by the shortcut Alt,. Then you just need to add the URL value. -
Add these attributes and values In the Element Attributes Panel:
-
role
attribute with the valueembedcode
-
xlink:href
attribute with the URL to the code snippet in your repository.
-
-
Optional: If you want or need fallback code for other output formats, add the code snippet in the
programlisting
orscreen
element as well. -
Select Save.
When you publish, your code will be fetched from the repository and will be automatically updated if that code changes.
Note
If you also publish to other outputs such as PDF, the embedded code will still be fetched dynamically at publish time. But if you change the code samples in your repository, you will need to republish the PDF output to have Paligo fetch the latest changes.