diff --git a/src/components/Markdown/env.ts b/src/components/Markdown/env.ts new file mode 100644 index 0000000..d769642 --- /dev/null +++ b/src/components/Markdown/env.ts @@ -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; + } +} \ No newline at end of file diff --git a/src/components/Markdown/index.tsx b/src/components/Markdown/index.tsx index d110f87..fb14269 100644 --- a/src/components/Markdown/index.tsx +++ b/src/components/Markdown/index.tsx @@ -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