Skip to content

Commit 6badb57

Browse files
committed
Support nested code blocks in pasted text symbols by using dynamic backtick fences
- if pasted text/website (then inlined in prompt) has triple backticks in it (code blocks) it should be placed within four backticks ├── apps │ └── editor │ └── src │ └── views │ └── prompt │ ├── backend │ │ ├── message-handlers │ │ │ ├── handle-paste-url.ts │ │ │ ├── handle-save-prompt-pasted-text.ts │ │ │ └── utils │ │ │ └── build-prompt-payload.ts │ │ ├── prompt-view-provider.ts │ │ └── utils │ │ ├── persistent-text-storage.ts │ │ ├── symbols │ │ │ ├── pasted-text │ │ │ │ └── replace-pasted-text-symbol.ts │ │ │ ├── replace-symbols.ts │ │ │ └── website │ │ │ └── replace-website-symbol.ts │ │ └── website-fetcher.ts │ ├── frontend │ │ └── hooks │ │ └── use-prompt │ │ └── use-prompt.ts │ └── types │ └── messages.ts └── packages └── ui └── src └── components └── editor └── common └── prompts └── PromptField └── hooks └── use-handlers └── handle-paste.ts
1 parent 81d319f commit 6badb57

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎apps/editor/src/views/prompt/backend/utils/symbols/pasted-text/replace-pasted-text-symbol.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ export const replace_pasted_text_symbol = async (params: {
4444
result_string += instruction.slice(last_index, match.index)
4545

4646
if (replacement.success && replacement.content) {
47-
result_string += `\n\`\`\`\n${replacement.content}\n\`\`\`\n`
47+
const backticks = replacement.content.includes('```') ? '````' : '```'
48+
result_string += `\n${backticks}\n${replacement.content}\n${backticks}\n`
4849
} else {
4950
result_string += match[0]
5051
}

0 commit comments

Comments
 (0)