]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Remove `src/libs/prism.ts` and clean up Prism old code (#42182)
authorJulien Déramond <juderamond@gmail.com>
Tue, 17 Mar 2026 18:27:37 +0000 (19:27 +0100)
committerGitHub <noreply@github.com>
Tue, 17 Mar 2026 18:27:37 +0000 (19:27 +0100)
package-lock.json
package.json
site/src/components/shortcodes/Code.astro
site/src/libs/astro.ts
site/src/libs/prism.ts [deleted file]

index b288c434511bb1378547dca1907c6ce0012e9a49..635bed353706b1bcee066b5cd40b4bef9712c8f9 100644 (file)
@@ -36,7 +36,6 @@
         "@stackblitz/sdk": "^1.11.0",
         "@types/js-yaml": "^4.0.9",
         "@types/mime": "^4.0.0",
-        "@types/prismjs": "^1.26.5",
         "astro": "^5.16.6",
         "astro-auto-import": "^0.4.5",
         "astro-broken-links-checker": "^1.0.7",
       "dev": true,
       "license": "MIT"
     },
-    "node_modules/@types/prismjs": {
-      "version": "1.26.5",
-      "resolved": "https://registry.npmjs.org/@types/prismjs/-/prismjs-1.26.5.tgz",
-      "integrity": "sha512-AUZTa7hQ2KY5L7AmtSiqxlhWxb4ina0yd8hNbl4TWuqnv/pFP0nDMb3YrfSBf4hJVGLh2YEIBfKaBW/9UEl6IQ==",
-      "dev": true,
-      "license": "MIT"
-    },
     "node_modules/@types/resolve": {
       "version": "1.20.2",
       "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.20.2.tgz",
index a078f1c6a312db04d0c8a9fc1942de7a94d7a07c..adbd6fb62002e078f2a4c5369afcfaa875a7d438 100644 (file)
     "@stackblitz/sdk": "^1.11.0",
     "@types/js-yaml": "^4.0.9",
     "@types/mime": "^4.0.0",
-    "@types/prismjs": "^1.26.5",
     "astro": "^5.16.6",
     "astro-auto-import": "^0.4.5",
     "astro-broken-links-checker": "^1.0.7",
index 03c81e3fa1fe2511cb223c16470d4bdf581244f4..292877ee031bd5f2adf42518ad5341cb099630a8 100644 (file)
@@ -38,7 +38,7 @@ interface Props {
   'data-language'?: string
   /**
    * The language to use for highlighting.
-   * @see https://prismjs.com/#supported-languages
+   * @see https://shiki.style/languages
    */
   lang?: string
   /**
index b282fc6b221ce508353843200845e28aa5f77bc7..71c60a5c37f3ef53aa408d35b2fec33abe04f43e 100644 (file)
@@ -10,7 +10,6 @@ import rehypeAutolinkHeadings from 'rehype-autolink-headings'
 import { getConfig } from './config'
 import { rehypeBsTable } from './rehype'
 import { remarkBsConfig, remarkBsDocsref } from './remark'
-// import { configurePrism } from './prism'
 import {
   docsDirectory,
   getDocsFsPath,
@@ -38,8 +37,6 @@ const headingsRangeRegex = new RegExp(`^h[${getConfig().anchors.min}-${getConfig
 export function bootstrap(): AstroIntegration[] {
   const sitemapExcludedUrls = sitemapExcludes.map((url) => `${getConfig().baseURL}${url}/`)
 
-  // configurePrism()
-
   return [
     bootstrap_auto_import(),
     {
diff --git a/site/src/libs/prism.ts b/site/src/libs/prism.ts
deleted file mode 100644 (file)
index 3b9ef8c..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-import Prism, { type hooks } from 'prismjs'
-const { Token } = Prism
-
-let isPrismConfigured = false
-
-export function configurePrism() {
-  if (isPrismConfigured) {
-    return
-  }
-
-  isPrismConfigured = true
-
-  Prism.hooks.add('after-tokenize', lineWrapPlugin)
-}
-
-// A plugin to wrap each line in a .line span, except for comments and empty lines
-function lineWrapPlugin(env: hooks.HookEnvironmentMap['after-tokenize']) {
-  // Skip processing if the language isn't one we want to modify
-  if (env.language !== 'bash' && env.language !== 'sh' && env.language !== 'powershell') {
-    return
-  }
-
-  // First, split tokens into lines
-  const lines: (string | Prism.Token)[][] = [[]]
-
-  for (let i = 0; i < env.tokens.length; i++) {
-    const token = env.tokens[i]
-
-    if (typeof token === 'string') {
-      // Split string tokens by newlines
-      const parts = token.split('\n')
-
-      for (let j = 0; j < parts.length; j++) {
-        if (j > 0) {
-          // Start a new line after each newline
-          lines.push([])
-        }
-
-        if (parts[j]) {
-          lines[lines.length - 1].push(parts[j])
-        }
-      }
-    } else {
-      lines[lines.length - 1].push(token)
-    }
-  }
-
-  // Now rebuild tokens with the line structure
-  env.tokens = []
-
-  for (let i = 0; i < lines.length; i++) {
-    const line = lines[i]
-
-    // Check if this is an empty line
-    const isEmptyLine = line.length === 0 || (line.length === 1 && typeof line[0] === 'string' && line[0].trim() === '')
-
-    // Check if this is a comment-only line
-    const isCommentLine = line.every((token) => {
-      if (typeof token === 'string') {
-        return token.trim() === ''
-      }
-      return token.type === 'comment'
-    })
-
-    if (isEmptyLine || isCommentLine) {
-      // For comment or empty lines, just add the tokens without a wrapper
-      env.tokens.push(...line)
-
-      // Add a newline after each line (except the last)
-      if (i < lines.length - 1) {
-        env.tokens.push('\n')
-      }
-    } else {
-      // For normal lines, wrap with .line class
-      const lineToken = new Token('span', '', ['line'])
-      const lineChildren: (string | Prism.Token)[] = []
-
-      // Add the line content
-      lineChildren.push(...line)
-
-      // For the last token in the line, append a newline
-      if (i < lines.length - 1) {
-        lineChildren.push('\n')
-      }
-
-      // Set line content
-      lineToken.content = lineChildren
-
-      // Add the entire structure to tokens
-      env.tokens.push(lineToken)
-    }
-  }
-}