diff --git a/iosHyperskillApp/iosHyperskillApp/Sources/Frameworks/CodeEditor/Model/CodeLanguage.swift b/iosHyperskillApp/iosHyperskillApp/Sources/Frameworks/CodeEditor/Model/CodeLanguage.swift index 9bb28e7257..783b1dac1a 100644 --- a/iosHyperskillApp/iosHyperskillApp/Sources/Frameworks/CodeEditor/Model/CodeLanguage.swift +++ b/iosHyperskillApp/iosHyperskillApp/Sources/Frameworks/CodeEditor/Model/CodeLanguage.swift @@ -35,6 +35,7 @@ enum CodeLanguage: String, CaseIterable { case pascal = "pascalabc" case perl = "perl" case sql = "sql" + case mysql = "mysql" case swift = "swift" case php = "php" case julia = "julia" @@ -78,7 +79,7 @@ enum CodeLanguage: String, CaseIterable { return "delphi" case .perl: return "perl" - case .sql: + case .sql, .mysql: return "sql" case .swift: return "swift" @@ -133,6 +134,8 @@ enum CodeLanguage: String, CaseIterable { return "Perl" case .sql: return "SQL" + case .mysql: + return "MySQL" case .swift: return "Swift" case .php: diff --git a/iosHyperskillApp/iosHyperskillApp/Sources/Frameworks/CodeEditor/Model/CodeLanguageSamples/CodeLanguageSamples.swift b/iosHyperskillApp/iosHyperskillApp/Sources/Frameworks/CodeEditor/Model/CodeLanguageSamples/CodeLanguageSamples.swift index 2b7f347b16..6d07c6a5b5 100644 --- a/iosHyperskillApp/iosHyperskillApp/Sources/Frameworks/CodeEditor/Model/CodeLanguageSamples/CodeLanguageSamples.swift +++ b/iosHyperskillApp/iosHyperskillApp/Sources/Frameworks/CodeEditor/Model/CodeLanguageSamples/CodeLanguageSamples.swift @@ -73,7 +73,7 @@ enum CodeLanguageSamples { return pascal case .perl: return perl - case .sql: + case .sql, .mysql: return sql case .swift: return swift diff --git a/iosHyperskillApp/iosHyperskillApp/Sources/Modules/StepQuizSubmodules/StepQuizFillBlanks/ViewData/StepQuizFillBlanksViewDataMapper.swift b/iosHyperskillApp/iosHyperskillApp/Sources/Modules/StepQuizSubmodules/StepQuizFillBlanks/ViewData/StepQuizFillBlanksViewDataMapper.swift index e25e954622..ee88fb128a 100644 --- a/iosHyperskillApp/iosHyperskillApp/Sources/Modules/StepQuizSubmodules/StepQuizFillBlanks/ViewData/StepQuizFillBlanksViewDataMapper.swift +++ b/iosHyperskillApp/iosHyperskillApp/Sources/Modules/StepQuizSubmodules/StepQuizFillBlanks/ViewData/StepQuizFillBlanksViewDataMapper.swift @@ -34,9 +34,10 @@ final class StepQuizFillBlanksViewDataMapper { private func mapFillBlanksDataToViewData(_ fillBlanksData: FillBlanksData) -> StepQuizFillBlanksViewData { let language = fillBlanksData.language + let codeLanguage = language.flatMap(CodeLanguage.init(rawValue:)) var components = fillBlanksData.fillBlanks - .map { mapFillBlanksItem($0, language: language) } + .map { mapFillBlanksItem($0, language: language, codeLanguage: codeLanguage) } .flatMap { $0 } for index in components.indices { components[index].id = index @@ -63,7 +64,8 @@ final class StepQuizFillBlanksViewDataMapper { private func mapFillBlanksItem( _ fillBlanksItem: FillBlanksItem, - language: String? + language: String?, + codeLanguage: CodeLanguage? ) -> [StepQuizFillBlankComponent] { switch FillBlanksItemKs(fillBlanksItem) { case .text(let data): @@ -80,7 +82,7 @@ final class StepQuizFillBlanksViewDataMapper { } else { let unescaped = HTMLString.unescape(string: data.text) - if let highlightedCode = highlight(code: unescaped, language: language) { + if let highlightedCode = highlight(code: unescaped, codeLanguage: codeLanguage) { cache.setHighlightedCode(highlightedCode, for: hash) result.append(StepQuizFillBlankComponent(type: .text, attributedText: highlightedCode)) } else { @@ -101,7 +103,7 @@ final class StepQuizFillBlanksViewDataMapper { } } - private func highlight(code: String, language: String?) -> NSAttributedString? { - highlightr.highlight(code, as: language, fastRender: true) + private func highlight(code: String, codeLanguage: CodeLanguage?) -> NSAttributedString? { + highlightr.highlight(code, as: codeLanguage?.highlightr, fastRender: true) } }