Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nul800sebastiaan/8caf7ab8d5e152029c2c998d60ca8f1b to your computer and use it in GitHub Desktop.
Save nul800sebastiaan/8caf7ab8d5e152029c2c998d60ca8f1b to your computer and use it in GitHub Desktop.
Code block with syntax highlighting on Discord
```js
#onChange(event: InputEvent) {
if (event.target && event.target instanceof HTMLElement) {
const target = event.target;
const firstShadowRoot = target.shadowRoot;
if (firstShadowRoot) {
const umbInputDocument = firstShadowRoot.querySelector('umb-input-document');
if (umbInputDocument && umbInputDocument.shadowRoot) {
const refList = umbInputDocument.shadowRoot.querySelector('uui-ref-list');
if (refList) {
const id = refList.id; // Access the id of the uui-ref-list
console.log(id); // Use the id as needed
}
}
}
}
}
```
@nul800sebastiaan
Copy link
Author

nul800sebastiaan commented Jul 26, 2024

  • Just adding three backticks around a block of code will display it in a monospace font, making it so much easier to read already.
  • In this example, I've added js after the first 3 backticks, which will do Javascript syntax highlighting. Using csharp instead would make it highlight C# code, and so on. A list of supported languages is available as well.
    • Note the 3 backticks plus the language need to connect to each other (no spaces in between) and need to be the only thing on the first line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment