diff --git a/src/modules/ImageInfo/features/formatInfo.ts b/src/modules/ImageInfo/features/formatInfo.ts index 82de2e2..40b2bb4 100644 --- a/src/modules/ImageInfo/features/formatInfo.ts +++ b/src/modules/ImageInfo/features/formatInfo.ts @@ -1,10 +1,26 @@ import { parseFromRawInfo } from '@bluelovers/auto1111-pnginfo'; -import { Converter } from '@/scripts/formatPrompt'; +import { splitSmartly } from 'split-smartly2'; const formatPrompt = (prompt: string) => { - let newPrompt = prompt.replaceAll('<', '<').replaceAll('>', '>'); - return Converter.convert(newPrompt); + let newPrompt = prompt + .replaceAll('<', '<') + .replaceAll('>', '>') + .replace(/^[\x00\s,,。]+$/gm, '') + .replace(/\n{2,}/g, '\n') + ; + + const entries = splitSmartly(newPrompt.replace(/\n/g, '
'), [',',',','。'], { + brackets: true, + trimSeparators: true, + }) as string[]; + + return entries + .filter(line => line.length) + .join(', ') + .replace(/
/g, '\n') + .replace(/^\s+|\s+$/gm, '') + ; }; export const formatInfo = (info: string) => {