Skip to content

Commit 3c4dd15

Browse files
committed
Fix regex
1 parent 3aa860e commit 3c4dd15

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Core/Sources/PromptToCodeService/OpenAIPromptToCodeService.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ extension OpenAIPromptToCodeService {
222222
{
223223
func extractCodeFromMarkdown(_ markdown: String) -> (code: String, endIndex: Int)? {
224224
let codeBlockRegex = try! NSRegularExpression(
225-
pattern: #"```(?:\w+)?[\n]([\s\S]+?)[\n]```"#,
225+
pattern: #"```(?:\w+)?\R([\s\S]+?)\R```"#,
226226
options: .dotMatchesLineSeparators
227227
)
228228
let range = NSRange(markdown.startIndex..<markdown.endIndex, in: markdown)
@@ -232,7 +232,7 @@ extension OpenAIPromptToCodeService {
232232
}
233233

234234
let incompleteCodeBlockRegex = try! NSRegularExpression(
235-
pattern: #"```(?:\w+)?[\n]([\s\S]+?)$"#,
235+
pattern: #"```(?:\w+)?\R([\s\S]+?)$"#,
236236
options: .dotMatchesLineSeparators
237237
)
238238
let range2 = NSRange(markdown.startIndex..<markdown.endIndex, in: markdown)

Pro

Submodule Pro updated from cf46363 to 46c52cb

0 commit comments

Comments
 (0)