### Set Database Password via Helm Install Argument Source: https://docs.posit.co/helm/charts/rstudio-workbench/README.html This example demonstrates how to set the database password directly during `helm install` using the `--set` argument. This method allows for dynamic configuration without modifying the `values.yaml` file. ```bash `helm install ... --set config.secret.'database\.conf'.password=""` ``` -------------------------------- ### Inline Configuration File Example Source: https://docs.posit.co/helm/charts/rstudio-workbench/README.html This snippet illustrates how to provide configuration file content directly within the `values.yaml` file using a multi-line string. This is useful for in-lining configuration files or mounting them verbatim. ```yaml config: server: rserver.conf: | verbatim-file=format ``` -------------------------------- ### Initialize UI components and clipboard functionality Source: https://docs.posit.co/chronicle This script initializes the documentation page UI, including the color scheme toggle and clipboard copy functionality for code blocks. It ensures that interactive elements are injected into the DOM and event listeners are attached for user interactions. ```javascript window.document.addEventListener("DOMContentLoaded", function (event) { if (window.document.querySelector('.quarto-color-scheme-toggle') === null) { const a = window.document.createElement('a'); a.classList.add('top-right'); a.classList.add('quarto-color-scheme-toggle'); a.href = ""; a.onclick = function() { try { window.quartoToggleColorScheme(); } catch {} return false; }; const i = window.document.createElement("i"); i.classList.add('bi'); a.appendChild(i); window.document.body.appendChild(a); } setColorSchemeToggle(hasAlternateSentinel()); const icon = "\ue9cb"; const anchorJS = new window.AnchorJS(); anchorJS.options = { placement: 'right', icon: icon }; anchorJS.add('.anchored'); const onCopySuccess = function(e) { const button = e.trigger; button.blur(); button.classList.add('code-copy-button-checked'); var currentTitle = button.getAttribute("title"); button.setAttribute("title", "Copied!"); setTimeout(function() { button.setAttribute("title", currentTitle); button.classList.remove('code-copy-button-checked'); }, 1000); e.clearSelection(); }; const clipboard = new window.ClipboardJS('.code-copy-button:not([data-in-quarto-modal])', { text: function(trigger) { const outerScaffold = trigger.parentElement.cloneNode(true); const codeEl = outerScaffold.querySelector('code'); return codeEl.innerText; } }); clipboard.on('success', onCopySuccess); }); ``` -------------------------------- ### Configure License via Helm Install Argument Source: https://docs.posit.co/helm/charts/rstudio-pm/README.html Command-line argument to inject the license file contents directly during the Helm installation process. ```bash --set-file license.file.contents=licenses/rstudio-pm.lic ``` -------------------------------- ### Initialize Tippy.js Tooltips for Elements Source: https://docs.posit.co/chronicle Configures and attaches a Tippy.js instance to a DOM element. It supports custom content functions and trigger/untrigger callbacks, specifically tailored for the Quarto theme. ```javascript function tippyHover(el, contentFn, onTriggerFn, onUntriggerFn) { const config = { allowHTML: true, maxWidth: 500, delay: 100, arrow: false, appendTo: function(el) { return el.parentElement; }, interactive: true, interactiveBorder: 10, theme: 'quarto', placement: 'bottom-start', }; if (contentFn) { config.content = contentFn; } if (onTriggerFn) { config.onTrigger = onTriggerFn; } if (onUntriggerFn) { config.onUntrigger = onUntriggerFn; } window.tippy(el, config); } ``` -------------------------------- ### Deploy Example Shiny Server Configuration Source: https://docs.posit.co/shiny-server Copies an example Shiny Server configuration file and installs example applications. It requires root privileges and backs up the existing configuration first. The default configuration hosts applications in /srv/shiny-server/. ```bash sudo /opt/shiny-server/bin/deploy-example default ``` -------------------------------- ### Configure Custom Startup Files via Helm Source: https://docs.posit.co/helm/charts/rstudio-workbench/README.html Demonstrates how to mount custom configuration files into the /startup/custom directory using Helm values. The content is provided as a verbatim string. ```yaml config: startupCustom: myfile.conf: | file-used-verbatim ``` -------------------------------- ### Initialize Quarto UI and Interaction Features Source: https://docs.posit.co/connect This initialization script sets up the Quarto environment by injecting a color scheme toggle if missing, configuring clipboard copy buttons for code blocks, and applying external link attributes. It also initializes tooltip behavior for cross-references and footnotes using the Tippy.js library. ```javascript window.document.addEventListener("DOMContentLoaded", function (event) { if (window.document.querySelector('.quarto-color-scheme-toggle') === null) { const a = window.document.createElement('a'); a.classList.add('top-right', 'quarto-color-scheme-toggle'); a.href = ""; a.onclick = function() { try { window.quartoToggleColorScheme(); } catch {} return false; }; const i = window.document.createElement("i"); i.classList.add('bi'); a.appendChild(i); window.document.body.appendChild(a); } const clipboard = new window.ClipboardJS('.code-copy-button:not([data-in-quarto-modal])', { text: function(trigger) { const outerScaffold = trigger.parentElement.cloneNode(true); const codeEl = outerScaffold.querySelector('code'); return codeEl.innerText; } }); function tippyHover(el, contentFn) { const config = { allowHTML: true, maxWidth: 500, theme: 'quarto' }; if (contentFn) config.content = contentFn; window.tippy(el, config); } }); ``` -------------------------------- ### Initialize UI Theme Toggle and Clipboard Utilities Source: https://docs.posit.co/connect/admin/reference-architectures/overview This script initializes the color scheme toggle button if missing and configures clipboard copy functionality for code blocks. It ensures a consistent user experience by dynamically injecting UI elements and managing copy-to-clipboard events. ```javascript window.document.addEventListener("DOMContentLoaded", function (event) { if (window.document.querySelector('.quarto-color-scheme-toggle') === null) { const a = window.document.createElement('a'); a.classList.add('top-right'); a.classList.add('quarto-color-scheme-toggle'); a.href = ""; a.onclick = function() { try { window.quartoToggleColorScheme(); } catch {} return false; }; const i = window.document.createElement("i"); i.classList.add('bi'); a.appendChild(i); window.document.body.appendChild(a); } setColorSchemeToggle(hasAlternateSentinel()); const icon = "\ue9cb"; const anchorJS = new window.AnchorJS(); anchorJS.options = { placement: 'right', icon: icon }; anchorJS.add('.anchored'); const onCopySuccess = function(e) { const button = e.trigger; button.blur(); button.classList.add('code-copy-button-checked'); var currentTitle = button.getAttribute("title"); button.setAttribute("title", "Copied!"); e.clearSelection(); setTimeout(function() { button.setAttribute("title", currentTitle); button.classList.remove('code-copy-button-checked'); }, 1000); }; const clipboard = new window.ClipboardJS('.code-copy-button:not([data-in-quarto-modal])', { text: function(trigger) { const outerScaffold = trigger.parentElement.cloneNode(true); const codeEl = outerScaffold.querySelector('code'); return codeEl.innerText; } }); clipboard.on('success', onCopySuccess); }); ``` -------------------------------- ### Deploy Example SSL Configuration for Shiny Server Source: https://docs.posit.co/shiny-server Uses a provided script to configure Shiny Server to use an example SSL configuration file and install sample applications. It's recommended to back up your current configuration before running this command. ```bash sudo /opt/shiny-server/bin/deploy-example ssl ``` -------------------------------- ### Install Shiny Server on Ubuntu Source: https://docs.posit.co/shiny-server Installs Shiny Server on Ubuntu systems after R and the Shiny R package are installed. It uses apt to install the downloaded .deb package. The installation places Shiny Server in /opt/shiny-server/. ```bash wget sudo apt install ./shiny-server-.deb ``` -------------------------------- ### Install Shiny Server on RedHat/CentOS Source: https://docs.posit.co/shiny-server Installs Shiny Server on RedHat/CentOS systems after R and the Shiny R package are installed. It uses yum to install the RPM package, which includes Shiny Server and its dependencies (excluding R and Shiny). The installation places Shiny Server in /opt/shiny-server/. ```bash wget sudo yum install --nogpgcheck shiny-server-.rpm ``` -------------------------------- ### Initialize Biblioreference Tooltips Source: https://docs.posit.co/connect/admin/reference-architectures/azure/single-server Iterates through all bibliographical reference links (`a[role="doc-biblioref"]`) in the document. For each reference, it finds associated citation keys using `findCites` and then uses `tippyHover` to create tooltips that display the full citation content fetched from elements with IDs like 'ref-citekey'. ```javascript var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]'); for (var i=0; i") dep <- deploy(client, bund, "") poll_task(dep) ``` -------------------------------- ### Install R on RedHat/CentOS Source: https://docs.posit.co/shiny-server Installs R version 3.0 or higher on RedHat/CentOS systems by first enabling the EPEL repository and then using yum to install the R package. This ensures that the necessary R version and its dependencies are available. ```bash # Enable EPEL repository as described in the EPEL documentation sudo yum install R ``` -------------------------------- ### JavaScript: Color Scheme and Giscus Theme Toggling Source: https://docs.posit.co/chronicle This JavaScript code handles toggling between light and dark color schemes, managing local storage for theme preferences, and updating the Giscus comment theme based on user preferences and system settings. It includes functions to manage the 'no-transition' class, check for file URLs, set and get color scheme preferences from local storage, and toggle the Giscus theme if the iframe is loaded. ```javascript const toggleNoTransition = (el, enabled) => { const shouldRemove = !enabled; if (shouldRemove) { el.classList.remove('notransition'); } else { el.classList.add('notransition'); } } const isFileUrl = () => { return window.location.protocol === 'file:'; } const hasAlternateSentinel = () => { let styleSentinel = getColorSchemeSentinel(); if (styleSentinel !== null) { return styleSentinel === "alternate"; } else { return false; } } const setStyleSentinel = (alternate) => { const value = alternate ? "alternate" : "default"; if (!isFileUrl()) { window.localStorage.setItem("quarto-color-scheme", value); } else { localAlternateSentinel = value; } } const getColorSchemeSentinel = () => { if (!isFileUrl()) { const storageValue = window.localStorage.getItem("quarto-color-scheme"); return storageValue != null ? storageValue : localAlternateSentinel; } else { return localAlternateSentinel; } } const toggleGiscusIfUsed = (isAlternate, darkModeDefault) => { const baseTheme = document.querySelector('#giscus-base-theme')?.value ?? 'light'; const alternateTheme = document.querySelector('#giscus-alt-theme')?.value ?? 'dark'; let newTheme = ''; if(authorPrefersDark) { newTheme = isAlternate ? baseTheme : alternateTheme; } else { newTheme = isAlternate ? alternateTheme : baseTheme; } const changeGiscusTheme = () => { // From: https://github.com/giscus/giscus/issues/336 const sendMessage = (message) => { const iframe = document.querySelector('iframe.giscus-frame'); if (!iframe) return; iframe.contentWindow.postMessage({ giscus: message }, 'https://giscus.app'); } sendMessage({ setConfig: { theme: newTheme } }); } const isGiscussLoaded = window.document.querySelector('iframe.giscus-frame') !== null; if (isGiscussLoaded) { changeGiscusTheme(); } }; const authorPrefersDark = false; const darkModeDefault = authorPrefersDark; document.querySelector('link#quarto-text-highlighting-styles.quarto-color-scheme-extra').rel = 'disabled-stylesheet'; document.querySelector('link#quarto-bootstrap.quarto-color-scheme-extra').rel = 'disabled-stylesheet'; let localAlternateSentinel = darkModeDefault ? 'alternate' : 'default'; // Dark / light mode switch window.quartoToggleColorScheme = () => { // Read the current dark / light value let toAlternate = !hasAlternateSentinel(); toggleColorMode(toAlternate); setStyleSentinel(toAlternate); toggleGiscusIfUsed(toAlternate, darkModeDefault); window.dispatchEvent(new Event('resize')); }; // Switch to dark mode if need be if (hasAlternateSentinel()) { toggleColorMode(true); } else { toggleColorMode(false); } ``` -------------------------------- ### Initialize Quarto UI and Clipboard Utilities Source: https://docs.posit.co/cloud-products This script initializes the color scheme toggle, configures ClipboardJS for code block copying, and sets up external link behavior. It ensures that code snippets are copyable and that external links open in new tabs with appropriate security attributes. ```javascript window.document.addEventListener("DOMContentLoaded", function (event) { if (window.document.querySelector('.quarto-color-scheme-toggle') === null) { const a = window.document.createElement('a'); a.classList.add('top-right'); a.classList.add('quarto-color-scheme-toggle'); a.href = ""; a.onclick = function() { try { window.quartoToggleColorScheme(); } catch {} return false; }; const i = window.document.createElement("i"); i.classList.add('bi'); a.appendChild(i); window.document.body.appendChild(a); } setColorSchemeToggle(hasAlternateSentinel()); const clipboard = new window.ClipboardJS('.code-copy-button:not([data-in-quarto-modal])', { text: function(trigger) { const codeEl = trigger.previousElementSibling.cloneNode(true); return codeEl.innerText; } }); }); ``` -------------------------------- ### Install Shiny Package Source: https://docs.posit.co/shiny-server Executes the R command to download and install the Shiny package into the system library with root privileges. ```bash sudo su - -c "R -e \"install.packages('shiny')\"" ``` -------------------------------- ### Initialize Quarto UI and Interaction Features Source: https://docs.posit.co/connect/admin/reference-architectures/aws/load-balanced Initializes the DOM environment for Quarto pages by injecting color scheme toggles, configuring clipboard copy buttons for code blocks, and setting up external link behavior. It relies on external libraries like ClipboardJS, Tippy.js, and Bootstrap for interactive components. ```javascript window.document.addEventListener("DOMContentLoaded", function (event) { if (window.document.querySelector('.quarto-color-scheme-toggle') === null) { const a = window.document.createElement('a'); a.classList.add('top-right'); a.classList.add('quarto-color-scheme-toggle'); a.href = ""; a.onclick = function() { try { window.quartoToggleColorScheme(); } catch {} return false; }; const i = window.document.createElement("i"); i.classList.add('bi'); a.appendChild(i); window.document.body.appendChild(a); } setColorSchemeToggle(hasAlternateSentinel()); const clipboard = new window.ClipboardJS('.code-copy-button:not([data-in-quarto-modal])', { text: getTextToCopy }); clipboard.on('success', onCopySuccess); }); ``` -------------------------------- ### Initialize Quarto UI Components and Event Listeners Source: https://docs.posit.co/connect-cloud Initializes the color scheme toggle, configures AnchorJS for headings, and sets up clipboard functionality for code blocks. It ensures that UI elements are dynamically injected or configured upon DOMContentLoaded. ```javascript window.document.addEventListener("DOMContentLoaded", function (event) { if (window.document.querySelector('.quarto-color-scheme-toggle') === null) { const a = window.document.createElement('a'); a.classList.add('top-right', 'quarto-color-scheme-toggle'); a.onclick = function() { try { window.quartoToggleColorScheme(); } catch {} return false; }; window.document.body.appendChild(a); } const anchorJS = new window.AnchorJS(); anchorJS.options = { placement: 'right', icon: '' }; anchorJS.add('.anchored'); }); ``` -------------------------------- ### Install Shiny Server RPM Source: https://docs.posit.co/shiny-server Installs the Shiny Server RPM package using the zypper package manager, which sets up the service in /opt/shiny-server/. ```bash sudo zypper --no-gpg-checks install shiny-server-.rpm ``` -------------------------------- ### Initialize GLightbox for Quarto Source: https://docs.posit.co/connect/admin/reference-architectures/azure/single-server-robust This script initializes GLightbox with specific zoom effects and hooks into slide loading events. It ensures that data-URI images are correctly resolved and that Quarto's mathematical typesetting is triggered after a slide loads. ```javascript var lightboxQuarto = GLightbox({"closeEffect":"zoom","descPosition":"bottom","loop":false,"openEffect":"zoom","selector":".lightbox"}); (function() { let previousOnload = window.onload; window.onload = () => { if (previousOnload) { previousOnload(); } lightboxQuarto.on('slide_before_load', (data) => { const { slideIndex, slideNode, slideConfig, player, trigger } = data; const href = trigger.getAttribute('href'); if (href !== null) { const imgEl = window.document.querySelector(`a[href="${href}"] img`); if (imgEl !== null) { const srcAttr = imgEl.getAttribute("src"); if (srcAttr && srcAttr.startsWith("data:")) { slideConfig.href = srcAttr; } } } }); lightboxQuarto.on('slide_after_load', (data) => { const { slideIndex, slideNode, slideConfig, player, trigger } = data; if (window.Quarto?.typesetMath) { window.Quarto.typesetMath(slideNode); } }); }; })(); ``` -------------------------------- ### Initialize Lightbox Gallery (JavaScript) Source: https://docs.posit.co/connect/admin/reference-architectures/aws/load-balanced Initializes a GLightbox instance for handling image lightboxes. It includes custom event listeners for 'slide_before_load' and 'slide_after_load' to handle image sources and math typesetting within slides. ```javascript var lightboxQuarto = GLightbox({"closeEffect":"zoom","descPosition":"bottom","loop":false,"openEffect":"zoom","selector":".lightbox"}); (function() { let previousOnload = window.onload; window.onload = () => { if (previousOnload) { previousOnload(); } lightboxQuarto.on('slide_before_load', (data) => { const { slideIndex, slideNode, slideConfig, player, trigger } = data; const href = trigger.getAttribute('href'); if (href !== null) { const imgEl = window.document.querySelector(`a[href="${href}"] img`); if (imgEl !== null) { const srcAttr = imgEl.getAttribute("src"); if (srcAttr && srcAttr.startsWith("data:")) { slideConfig.href = srcAttr; } } } }); lightboxQuarto.on('slide_after_load', (data) => { const { slideIndex, slideNode, slideConfig, player, trigger } = data; if (window.Quarto?.typesetMath) { window.Quarto.typesetMath(slideNode); } }); }; })(); ``` -------------------------------- ### Install R and Dependencies on SLES Source: https://docs.posit.co/shiny-server Commands to add the R repository and install the base R environment along with the C++ compiler required for building R packages from source. ```bash sudo zypper addrepo -f http://download.opensuse.org/repositories/devel:/languages:/R:/patched/SLE_12/ R-base sudo zypper install R-base sudo zypper install gcc-c++ ``` -------------------------------- ### Initialize Quarto UI and Clipboard Functionality Source: https://docs.posit.co/ide/user This script initializes the Quarto documentation interface, including the color scheme toggle, AnchorJS for section links, and clipboard integration for code blocks. It also automatically identifies and adorns external links with target attributes and CSS classes. ```javascript window.document.addEventListener("DOMContentLoaded", function (event) { if (window.document.querySelector('.quarto-color-scheme-toggle') === null) { const a = window.document.createElement('a'); a.classList.add('top-right', 'quarto-color-scheme-toggle'); a.href = ""; a.onclick = function() { try { window.quartoToggleColorScheme(); } catch {} return false; }; const i = window.document.createElement("i"); i.classList.add('bi'); a.appendChild(i); window.document.body.appendChild(a); } setColorSchemeToggle(hasAlternateSentinel()); const icon = "\ue9cb"; const anchorJS = new window.AnchorJS(); anchorJS.options = { placement: 'right', icon: icon }; anchorJS.add('.anchored'); const clipboard = new window.ClipboardJS('.code-copy-button:not([data-in-quarto-modal])', { text: getTextToCopy }); clipboard.on('success', onCopySuccess); }); ``` -------------------------------- ### Install R Markdown Package for Shiny Server Source: https://docs.posit.co/shiny-server This command installs the 'rmarkdown' R package system-wide, making it available for Shiny Server to host R Markdown documents. It requires superuser privileges. ```bash sudo su - -c "R -e \"install.packages('rmarkdown')\"" ``` -------------------------------- ### Set Database Password via Helm Install Argument Source: https://docs.posit.co/helm/charts/rstudio-pm/README.html This command demonstrates how to set the database password directly during `helm install` using the `--set` argument. This is an alternative to managing secrets separately in `values.yaml`. ```bash --set config.Postgres.Password="" ``` -------------------------------- ### Initialize Quarto UI and Clipboard Features Source: https://docs.posit.co/connect/admin/reference-architectures/aws/k8s Initializes the color scheme toggle, configures AnchorJS for headings, and sets up ClipboardJS for code block copying. It also handles UI feedback for successful copy operations. ```javascript window.document.addEventListener("DOMContentLoaded", function (event) { if (window.document.querySelector('.quarto-color-scheme-toggle') === null) { const a = window.document.createElement('a'); a.classList.add('top-right'); a.classList.add('quarto-color-scheme-toggle'); a.href = ""; a.onclick = function() { try { window.quartoToggleColorScheme(); } catch {} return false; }; const i = window.document.createElement("i"); i.classList.add('bi'); a.appendChild(i); window.document.body.appendChild(a); } setColorSchemeToggle(hasAlternateSentinel()); const icon = "\ue9cb"; const anchorJS = new window.AnchorJS(); anchorJS.options = { placement: 'right', icon: icon }; anchorJS.add('.anchored'); }); ``` -------------------------------- ### Install Posit Chronicle Helm Chart Source: https://docs.posit.co/helm/charts/posit-chronicle/README.html Installs or upgrades the Posit Chronicle Helm chart to a specific version. It requires adding the RStudio Helm repository first. This command ensures you are using a stable, pinned version for production environments. ```bash helm repo add rstudio https://helm.rstudio.com helm upgrade --install my-release rstudio/posit-chronicle --version=0.4.6 ``` -------------------------------- ### Configure Environment and Generate Manifest Source: https://docs.posit.co/how-to-guides/guides/migrate-shiny-server-pro-to-connect.html Sets up the required environment variables for Posit Connect authentication and generates a manifest file necessary for the deployment process. ```bash su - shiny cd vi .Renviron # Add these lines: CONNECT_SERVER = https:// CONNECT_API_KEY = ``` ```R readRenviron(".Renviron") install.packages("rsconnect") library(rsconnect) rsconnect::writeManifest("") ``` -------------------------------- ### Restart Shiny Server using Upstart Source: https://docs.posit.co/shiny-server This command stops and then starts the Shiny Server service. It is recommended to use separate 'stop' and 'start' commands for a full restart to ensure all changes are detected. This action will interrupt active sessions. ```bash sudo stop shiny-server sudo start shiny-server ``` -------------------------------- ### Configure Tippy Tooltips for References Source: https://docs.posit.co/ide/server-pro/admin/job_launcher/job_launcher.html Initializes Tippy.js tooltips for document references and cross-references. It dynamically fetches content from referenced elements to display in a floating popover. ```javascript function tippyHover(el, contentFn) { const config = { allowHTML: true, interactive: true, theme: 'quarto', placement: 'bottom-start', content: contentFn }; window.tippy(el, config); } ``` -------------------------------- ### Install Posit Connect Helm Chart Source: https://docs.posit.co/helm/charts/rstudio-connect/README.html Installs the Posit Connect Helm chart with a specific release name and version. It first adds the RStudio Helm repository if it's not already added. This command ensures a reproducible deployment by pinning the chart version. ```bash helm repo add rstudio https://helm.rstudio.com helm upgrade --install my-release rstudio/rstudio-connect --version=0.8.30 ``` -------------------------------- ### Initialize Kapa AI Widget Source: https://docs.posit.co/connect/admin/reference-architectures/azure/k8s Dynamically injects the Kapa AI chat widget script into the document head if the current page is part of the Posit documentation domain. ```javascript (() => { const url = window.location.href; const scriptId = "posit-docs-kapa-widget"; if (url.includes("docs.posit.co") && !document.getElementById(scriptId)) { const kapa = document.createElement("script"); kapa.async = true; kapa.id = scriptId; kapa.src = "https://widget.kapa.ai/kapa-widget.bundle.js"; kapa.setAttribute("data-button-text-color", "#447099"); document.head.appendChild(kapa); } })(); ``` -------------------------------- ### Initialize Citation Hover Tooltips Source: https://docs.posit.co/connect/admin/reference-architectures/aws/single-server Iterates through all elements with the role `doc-biblioref` (citation references). For each reference, it finds associated citation information using `findCites`. If found, it uses `tippyHover` to attach a tooltip that displays the content of the corresponding bibliography entries. ```javascript var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]'); for (var i=0; i { const parentEl = el.parentElement; if (parentEl) { const cites = parentEl.dataset.cites; if (cites) return { el, cites: cites.split(' ') }; else return findCites(el.parentElement); } return undefined; }; var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]'); for (var i=0; i { const stripColumnClz = (el) => { el.classList.remove("page-full", "page-columns"); if (el.children) { for (const child of el.children) { stripColumnClz(child); } } } stripColumnClz(note) if (id === null || id.startsWith('sec-')) { const container = document.createElement("div"); if (note.children && note.children.length > 2) { container.appendChild(note.children[0].cloneNode(true)); for (let i = 1; i < note.children.length; i++) { const child = note.children[i]; if (child.tagName === "P" && child.innerText === "") { continue; } else { container.appendChild(child.cloneNode(true)); break; } } if (window.Quarto?.typesetMath) { window.Quarto.typesetMath(container); } return container.innerHTML } else { if (window.Quarto?.typesetMath) { window.Quarto.typesetMath(note); } return note.innerHTML; } } else { const anchorLink = note.querySelector('a.anchorjs-link'); if (anchorLink) { anchorLink.remove(); } if (window.Quarto?.typesetMath) { window.Quarto.typesetMath(note); } if (note.classList.contains("callout")) { return note.outerHTML; } else { return note.innerHTML; } } } const xrefs = window.document.querySelectorAll('a.quarto-xref'); for (var i=0; i res.text()) .then(html => { const parser = new DOMParser(); const htmlDoc = parser.parseFromString(html, "text/html"); const note = htmlDoc.getElementById(id); if (note !== null) { const html = processXRef(id, note); instance.setContent(html); } }).finally(() => { instance.enable(); instance.show(); }); } } else { fetch(url) .then(res => res.text()) .then(html => { const parser = new DOMParser(); const htmlDoc = parser.parseFromString(html, "text/html"); const note = htmlDoc.querySelector('main.content'); if (note !== null) { if (note.children.length > 0 && note.children[0].tagName === "HEADER") { note.children[0].remove(); } const html = processXRef(null, note); instance.setContent(html); } }).finally(() => { instance.enable(); instance.show(); }); } }, function(instance) { }); } ``` -------------------------------- ### Code Annotation Check Function Source: https://docs.posit.co/cloud Defines a helper function `isCodeAnnotation` that checks if an HTML element has a class starting with 'code-annotation-'. This is used to identify and potentially remove annotation elements before copying code. ```javascript const isCodeAnnotation = (el) => { for (const clz of el.classList) { if (clz.startsWith('code-annotation-')) { return true; } } return false; } ``` -------------------------------- ### Initialize Kapa.ai Documentation Widget Source: https://docs.posit.co/connect/admin/reference-architectures/aws/load-balanced Injects the Kapa.ai script into the document head to provide an AI-powered search and question-answering interface for Posit documentation. ```javascript const url = window.location.href; const scriptId = "posit-docs-kapa-widget"; if (url.includes("docs.posit.co") && !document.getElementById(scriptId)) { const kapa = document.createElement("script"); kapa.async = true; kapa.id = scriptId; kapa.src = "https://widget.kapa.ai/kapa-widget.bundle.js"; kapa.setAttribute("data-button-text-color", "#447099"); document.head.appendChild(kapa); } ``` -------------------------------- ### Throttle Event Execution Source: https://docs.posit.co/chronicle A utility function to limit the frequency of function execution, commonly used for performance optimization during window resize events. ```javascript function throttle(fn, ms) { let throttle = false; let timer; return (...args) => { if(!throttle) { fn.apply(this, args); throttle = true; } else { if(timer) clearTimeout(timer); timer = setTimeout(() => { fn.apply(this, args); timer = throttle = false; }, ms); } }; } ```