From 288b5f01afe4af24926081ce74feebeb1479a47b Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Tue, 7 Feb 2023 13:52:37 +0100 Subject: [PATCH] Add gleam highlightjs support (#3430) This reverts commit a3e3745718085d89e870469110cc6553baeb42be. --- app/javascript/declarations/index.d.ts | 7 +++++++ app/javascript/utils/highlight.ts | 2 ++ package.json | 1 + yarn.lock | 5 +++++ 4 files changed, 15 insertions(+) diff --git a/app/javascript/declarations/index.d.ts b/app/javascript/declarations/index.d.ts index 58f6c53ca3..09de0e3a65 100644 --- a/app/javascript/declarations/index.d.ts +++ b/app/javascript/declarations/index.d.ts @@ -74,3 +74,10 @@ declare module 'highlightjs-bqn' { export default setup } + +declare module 'highlightjs-gleam' { + import { LanguageFn } from 'highlight.js' + const setup: LanguageFn + + export default setup +} diff --git a/app/javascript/utils/highlight.ts b/app/javascript/utils/highlight.ts index 523ff3b714..28caa32fba 100644 --- a/app/javascript/utils/highlight.ts +++ b/app/javascript/utils/highlight.ts @@ -3,10 +3,12 @@ import { useEffect, useRef } from 'react' import setupABAP from 'highlightjs-sap-abap' import setupCobol from 'highlightjs-cobol' import setupBqn from 'highlightjs-bqn' +import setupGleam from '@gleam-lang/highlight.js-gleam' highlighter.default.registerLanguage('abap', setupABAP) highlighter.default.registerLanguage('cobol', setupCobol) highlighter.default.registerLanguage('bqn', setupBqn) +highlighter.default.registerLanguage('gleam', setupGleam) highlighter.default.configure({ throwUnescapedHTML: true, diff --git a/package.json b/package.json index cd8c5422e5..0b68d404f2 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "@exercism/active-background": "^0.6.2", "@exercism/codemirror-lang-wren": "https://github.com/exercism/codemirror-lang-wren", "@exercism/twine2-story-format": "https://github.com/exercism/twine2-story-format.git", + "@gleam-lang/highlight.js-gleam": "^1.0.0", "@hotwired/turbo-rails": "^7.1.3", "@popperjs/core": "^2.5.2", "@rails/actioncable": "^6.0.0", diff --git a/yarn.lock b/yarn.lock index 0a62c8df7f..5ea7b01a98 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1393,6 +1393,11 @@ npm "^6.3.0" underscore "^1.8.3" +"@gleam-lang/highlight.js-gleam@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@gleam-lang/highlight.js-gleam/-/highlight.js-gleam-1.0.0.tgz#c9868daf7bc04df3477aaa3357c49a27edd3a18a" + integrity sha512-PNtTN5u7yQgo3uj+vm4SkZ2dbH+ozVMlsbaq8KdrNW5OPWsbRsPluSvGrhCkjJ2RVQKBsKK1o8WTjEU1hNTY1A== + "@hotwired/turbo-rails@^7.1.3": version "7.1.3" resolved "https://registry.yarnpkg.com/@hotwired/turbo-rails/-/turbo-rails-7.1.3.tgz#a4e04ecb800a06e7f9aa6e298170fa4580b74216"