added dotenv highlight support for prismjs

This commit is contained in:
Mahamed-Belkheir
2020-10-24 09:39:30 +01:00
parent d9445cfa21
commit e618b22ab4
2 changed files with 35 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
import Prism from "prismjs"
if (supportsLookBehind()) {
Prism.languages.env = {
property: {
pattern: /(.*.)(?==)/,
},
string: {
pattern: /(?<==)(.*.)/g,
global: true,
},
operator: {
pattern: /=/
}
}
} else {
Prism.languages.env = {
property: {
pattern: /(.*.)(?==)/,
},
operator: {
pattern: /=/
}
}
}
function supportsLookBehind() {
try {
return /(?<==)(.*)/.test("=hello")
} catch(e) {
return false;
}
}
+1
View File
@@ -16,6 +16,7 @@ import "prismjs/plugins/line-numbers/prism-line-numbers.css"
import React, { FC, useEffect } from "react"
import { MDXRenderer } from "gatsby-plugin-mdx"
import * as SC from "./styles"
import "./env";
interface IMarkdownProps {
content: string