Rock Mountain
  • Home
  • User Guide
    • Glass Web Components
    • Using reCAPTCHA
    • Publishing Source Code with Syntax Highlighting
  • Developer Guide
    • Getting Started
    • Adding NPM Packages
    • Database
      • Backing Up and Restoring Data
      • Database Schema
      • MongoDB Tips and Snippets
      • VS Code and the MongoDB Playground
    • Common Errors and Their Solutions
    • Developing Glass Web Components
    • DevOps
      • Build and Deployment Procedure
      • GitHub Conventions and Workflow
      • Merging Preview Into Main
    • File Structure
    • React Components
      • SiteLayout Component
      • Toggle Lazy Load Image Component
    • Update or Change the Fav Icon
    • References and Learning Resources
  • Icons
Powered by GitBook
On this page
  1. User Guide

Publishing Source Code with Syntax Highlighting

PreviousUsing reCAPTCHANextGetting Started

Last updated 3 years ago

To publish source code with syntax highlighting, the platform includes the from .

IMPORTANT: The component will only work on documents that have the Syntax Highlighting feature enabled (checked on the form for creating or updating a document).

Following is a brief example of how to use the component in your content.

<deckgo-highlight-code><code slot="code">
// ...insert source code snippet here...
</code></deckgo-highlight-code>

You can either inject a <code/> tag using slot as shown above or you can provide a URI to a file containing your code.

All attributes that can be used on the element are:

  • editable - boolean used to set the code component as being editable

  • highlight-lines - If you wish to highlight some lines of your code. The lines number should be provided as a number (one line) or numbers separated with coma or dash (many lines), group separated with space. For example: 1 3,5 8 14-17 which highlight lines 1, 3 to 5, 8 and 14 to 17

  • line-numbers - Display the number of the lines of code

  • terminal - Present the code in a stylish "windowed" card. Options are:

    • DeckdeckgoHighlightCodeTerminal.CARBON (this is the default)

    • DeckdeckgoHighlightCodeTerminal.NONE

    • DeckdeckgoHighlightCodeTerminal.UBUNTU

Technical Notes for Developers

The dependency for this component is injected into the HTML head when the loaded document has the feature syntax highlighter in its features array. This injection code is defined in the file pages/[...path].js within the function called includeDependencies().

The <deckgo-highlight-code/> Web Component will highlight your code using . Optionally, use the language attribute to define the language to be used for the syntax highlighting.

language - Define the language to be used for the syntax highlighting. The list of is defined by Prism.js

theme - The theme of the selected terminal (applied only in case of carbon). For information see the .

Prism.js
supported languages
deckgo-highlight-code component documentation
Highlight Code web component
DeckDeckGo