summaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2022-03-23 22:05:30 +0100
committerArmand Philippot <git@armandphilippot.com>2022-03-24 15:01:03 +0100
commit9226671f49b507ce6f71e6e2c3621014f05f74e9 (patch)
tree73a148d12ceebbf0d8a95b82353d3d84f6a7a76a /src/utils
parent4e7a96c5a831882463802cdd4f84fe1464969cb0 (diff)
refactor: load prism plugins without babel
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/helpers/prism.ts21
-rw-r--r--src/utils/providers/prism-theme.tsx (renamed from src/utils/providers/prism.tsx)8
2 files changed, 16 insertions, 13 deletions
diff --git a/src/utils/helpers/prism.ts b/src/utils/helpers/prism.ts
index bc84c91..a5f5787 100644
--- a/src/utils/helpers/prism.ts
+++ b/src/utils/helpers/prism.ts
@@ -17,19 +17,18 @@ export const addPrismClasses = () => {
const preTags = document.getElementsByTagName('pre');
Array.from(preTags).forEach((preTag) => {
- if (
- isLanguageBlock(preTag.classList) &&
- !preTag.classList.contains('command-line') &&
- !preTag.classList.contains('language-diff')
- ) {
- preTag.classList.add('line-numbers', 'match-braces');
- }
+ if (!isLanguageBlock(preTag.classList)) return;
+
+ preTag.classList.add('match-braces');
- if (
- preTag.classList.contains('command-line') &&
- preTag.classList.contains('filter-output')
- ) {
+ if (preTag.classList.contains('filter-output')) {
preTag.setAttribute('data-filter-output', '#output#');
}
+
+ if (preTag.classList.contains('language-bash')) {
+ preTag.classList.add('command-line');
+ } else if (!preTag.classList.contains('language-diff')) {
+ preTag.classList.add('line-numbers');
+ }
});
};
diff --git a/src/utils/providers/prism.tsx b/src/utils/providers/prism-theme.tsx
index 7a4221d..2ed8454 100644
--- a/src/utils/providers/prism.tsx
+++ b/src/utils/providers/prism-theme.tsx
@@ -28,8 +28,12 @@ export type PrismThemeProviderProps = {
export const PrismThemeContext = createContext<UsePrismThemeProps>({
themes: ['dark', 'light', 'system'],
- setTheme: (_) => {},
- setCodeBlocks: (_) => {},
+ setTheme: (_) => {
+ // This is intentional.
+ },
+ setCodeBlocks: (_) => {
+ // This is intentional.
+ },
});
export const usePrismTheme = () => useContext(PrismThemeContext);