Home

tailwind-ctp-intellisense @19a550d0de1f3bfbc2a49297e9f7e0c53cfc1ca6 - refs - log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Tailwind intellisense + Catppuccin
tailwind-ctp-intellisense / packages / tailwindcss-language-service / src / util / doc.ts
- raw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import type { TextDocument, Range } from 'vscode-languageserver'

export function getTextWithoutComments(
  doc: TextDocument,
  type: 'html' | 'js' | 'jsx' | 'css',
  range?: Range
): string
export function getTextWithoutComments(text: string, type: 'html' | 'js' | 'jsx' | 'css'): string
export function getTextWithoutComments(
  docOrText: TextDocument | string,
  type: 'html' | 'js' | 'jsx' | 'css',
  range?: Range
): string {
  let text = typeof docOrText === 'string' ? docOrText : docOrText.getText(range)

  if (type === 'js' || type === 'jsx') {
    return text.replace(/\/\*.*?\*\//gs, replace).replace(/\/\/.*?$/gms, replace)
  }

  if (type === 'css') {
    return text.replace(/\/\*.*?\*\//gs, replace)
  }

  return text.replace(/<!--.*?-->/gs, replace)
}

function replace(match: string): string {
  return match.replace(/./gs, (char) => (char === '\n' ? '\n' : ' '))
}