diff --git a/.github/ISSUE_TEMPLATE/1-feature-request.md b/.github/ISSUE_TEMPLATE/1-feature-request.md index 007c7d3..be25817 100644 --- a/.github/ISSUE_TEMPLATE/1-feature-request.md +++ b/.github/ISSUE_TEMPLATE/1-feature-request.md @@ -1,13 +1,12 @@ --- name: Feature Request -about: Suggest an idea for this project -labels: enhancement -assignees: checktheroads +about: Suggest an idea for hyperglass +labels: feature --- ", - }, - ini: { start: "#", end: "" }, - }; - // supported directives - const directives = [ - "highlight-next-line", - "highlight-start", - "highlight-end", - ].join("|"); - // to be more reliable, the opening and closing comment must match - const commentPattern = languages - .map( - (lang) => - `(?:${comments[lang].start}\\s*(${directives})\\s*${comments[lang].end})` - ) - .join("|"); - // white space is allowed, but otherwise it should be on it's own line - return new RegExp(`^\\s*(?:${commentPattern})\\s*$`); -}; -// select comment styles based on language -const highlightDirectiveRegex = (lang) => { - switch (lang) { - case "js": - case "javascript": - case "ts": - case "typescript": - return getHighlightDirectiveRegex(["js", "jsBlock"]); - - case "jsx": - case "tsx": - return getHighlightDirectiveRegex(["js", "jsBlock", "jsx"]); - - case "html": - return getHighlightDirectiveRegex(["js", "jsBlock", "html"]); - - case "python": - case "py": - return getHighlightDirectiveRegex(["python"]); - case "ini": - return getHighlightDirectiveRegex(["ini"]); - - default: - // all comment types - return getHighlightDirectiveRegex(); - } -}; -const codeBlockTitleRegex = /title=".*"/; - -export default ({ children, className: languageClassName, metastring }) => { - (typeof global !== "undefined" ? global : window).Prism = Prism; - require("prismjs/components/prism-shell-session"); - require("prismjs/components/prism-nginx"); - require("prismjs/components/prism-ini"); - const { - siteConfig: { - themeConfig: { prism = {} }, - }, - } = useDocusaurusContext(); - - const [showCopied, setShowCopied] = useState(false); - const [mounted, setMounted] = useState(false); - // The Prism theme on SSR is always the default theme but the site theme - // can be in a different mode. React hydration doesn't update DOM styles - // that come from SSR. Hence force a re-render after mounting to apply the - // current relevant styles. There will be a flash seen of the original - // styles seen using this current approach but that's probably ok. Fixing - // the flash will require changing the theming approach and is not worth it - // at this point. - useEffect(() => { - setMounted(true); - }, []); - - const target = useRef(null); - const button = useRef(null); - let highlightLines = []; - let codeBlockTitle = ""; - - const { isDarkTheme } = useThemeContext(); - const lightModeTheme = prism.theme || lightTheme || darkTheme; - const darkModeTheme = prism.darkTheme || darkTheme || lightTheme; - const prismTheme = isDarkTheme ? darkModeTheme : lightModeTheme; - - if (metastring && highlightLinesRangeRegex.test(metastring)) { - const highlightLinesRange = metastring.match(highlightLinesRangeRegex)[1]; - highlightLines = rangeParser - .parse(highlightLinesRange) - .filter((n) => n > 0); - } - - if (metastring && codeBlockTitleRegex.test(metastring)) { - codeBlockTitle = metastring - .match(codeBlockTitleRegex)[0] - .split("title=")[1] - .replace(/"+/g, ""); - } - - useEffect(() => { - let clipboard; - - if (button.current) { - clipboard = new Clipboard(button.current, { - target: () => target.current, - }); - } - - return () => { - if (clipboard) { - clipboard.destroy(); - } - }; - }, [button.current, target.current]); - - let language = - languageClassName && languageClassName.replace(/language-/, ""); - - if (!language && prism.defaultLanguage) { - language = prism.defaultLanguage; - } - - // only declaration OR directive highlight can be used for a block - let code = children.replace(/\n$/, ""); - if (highlightLines.length === 0 && language !== undefined) { - let range = ""; - const directiveRegex = highlightDirectiveRegex(language); - // go through line by line - const lines = children.replace(/\n$/, "").split("\n"); - let blockStart; - // loop through lines - for (let index = 0; index < lines.length; ) { - const line = lines[index]; - // adjust for 0-index - const lineNumber = index + 1; - const match = line.match(directiveRegex); - if (match !== null) { - const directive = match - .slice(1) - .reduce((final, item) => final || item, undefined); - switch (directive) { - case "highlight-next-line": - range += `${lineNumber},`; - break; - - case "highlight-start": - blockStart = lineNumber; - break; - - case "highlight-end": - range += `${blockStart}-${lineNumber - 1},`; - break; - - default: - break; - } - lines.splice(index, 1); - } else { - // lines without directives are unchanged - index += 1; - } - } - highlightLines = rangeParser.parse(range); - code = lines.join("\n"); - } - - const handleCopyCode = () => { - window.getSelection().empty(); - setShowCopied(true); - - setTimeout(() => setShowCopied(false), 2000); - }; - - return ( - - {({ className, style, tokens, getLineProps, getTokenProps }) => ( - <> - {codeBlockTitle && ( -
- {codeBlockTitle} -
- )} -
- {/* */} -
-
- {tokens.map((line, i) => { - if (line.length === 1 && line[0].content === "") { - line[0].content = "\n"; // eslint-disable-line no-param-reassign - } - - const lineProps = getLineProps({ line, key: i }); - - if (highlightLines.includes(i + 1)) { - lineProps.className = `${lineProps.className} docusaurus-highlight-code-line`; - } - - return ( -
- {line.map((token, key) => ( - - ))} -
- ); - })} -
-
-
- - )} -
- ); -}; diff --git a/docs/src/theme/CodeBlock/styles.module.css b/docs/src/theme/CodeBlock/styles.module.css deleted file mode 100644 index dda5caf..0000000 --- a/docs/src/theme/CodeBlock/styles.module.css +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -.codeBlockContent { - position: relative; -} - -.codeBlockTitle { - font-family: var(--ifm-font-family-monospace); - font-weight: bold; - padding: var(--ifm-pre-padding); - border-bottom: 1px solid var(--ifm-color-emphasis-200); - width: 100%; - border-top-left-radius: var(--ifm-global-radius); - border-top-right-radius: var(--ifm-global-radius); -} - -.codeBlock { - overflow: auto; - border-radius: var(--ifm-global-radius); -} - -.codeBlockWithTitle { - border-top-left-radius: 0; - border-top-right-radius: 0; - border-bottom-left-radius: var(--ifm-global-radius); - border-bottom-right-radius: var(--ifm-global-radius); -} - -.copyButton { - background: rgba(0, 0, 0, 0.3); - border: none; - border-radius: var(--ifm-global-radius); - color: var(--ifm-color-content); - cursor: pointer; - line-height: 12px; - opacity: 0; - outline: none; - padding: 4px 8px; - position: absolute; - right: var(--ifm-pre-padding); - top: var(--ifm-pre-padding); - visibility: hidden; - transition: opacity 200ms ease-in-out, visibility 200ms ease-in-out, - bottom 200ms ease-in-out; -} - -.copyButtonWithTitle { - top: calc(var(--ifm-pre-padding)); -} - -.codeBlockTitle:hover + .codeBlockContent .copyButton, -.codeBlockContent:hover > .copyButton { - visibility: visible; - opacity: 1; -} - -.codeBlockLines { - font-family: var(--ifm-font-family-monospace); - font-size: inherit; - line-height: var(--ifm-pre-line-height); - white-space: pre; - float: left; - min-width: 100%; - padding: var(--ifm-pre-padding); -} diff --git a/docs/src/theme/Footer/index.js b/docs/src/theme/Footer/index.js deleted file mode 100644 index 0113f60..0000000 --- a/docs/src/theme/Footer/index.js +++ /dev/null @@ -1,122 +0,0 @@ -/** - * Copyright (c) 2017-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -import React from "react"; -import classnames from "classnames"; - -import Link from "@docusaurus/Link"; -import useDocusaurusContext from "@docusaurus/useDocusaurusContext"; -import useBaseUrl from "@docusaurus/useBaseUrl"; -import styles from "./styles.module.css"; - -function FooterLink({ to, href, label, ...props }) { - const toUrl = useBaseUrl(to); - return ( - - {label} - - ); -} - -const FooterLogo = ({ url, alt }) => ( - {alt} -); - -function Footer() { - const context = useDocusaurusContext(); - const { siteConfig = {} } = context; - const { themeConfig = {} } = siteConfig; - const { footer } = themeConfig; - - const { copyright, links = [], logo = {} } = footer || {}; - const logoUrl = useBaseUrl(logo.src); - - if (!footer) { - return null; - } - - return ( - - ); -} - -export default Footer; diff --git a/docs/src/theme/Footer/styles.module.css b/docs/src/theme/Footer/styles.module.css deleted file mode 100644 index f56e41f..0000000 --- a/docs/src/theme/Footer/styles.module.css +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (c) 2017-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -.footerLogoLink { - opacity: 0.5; - transition: opacity 0.15s ease-in-out; -} - -.footerLogoLink:hover { - opacity: 1; -} - -.footerCol:first-child { - text-align: left; -} - -.footerCol:not(:first-child):not(:last-child) { - text-align: center; -} - -.footerCol:last-child { - text-align: right; -} - -html[data-theme="dark"] .footerLink[class] { - color: var(--ifm-color-emphasis-400); -} - -.footerLink[class] { - color: var(--ifm-color-emphasis-700); -} diff --git a/docs/src/theme/Layout/index.js b/docs/src/theme/Layout/index.js deleted file mode 100644 index 20217ae..0000000 --- a/docs/src/theme/Layout/index.js +++ /dev/null @@ -1,83 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -import React from "react"; -import Head from "@docusaurus/Head"; -import useDocusaurusContext from "@docusaurus/useDocusaurusContext"; -import useBaseUrl from "@docusaurus/useBaseUrl"; - -import ThemeProvider from "@theme/ThemeProvider"; -import UserPreferencesProvider from "@theme/UserPreferencesProvider"; -import AnnouncementBar from "@theme/AnnouncementBar"; -import Navbar from "../Navbar"; -import Footer from "../Footer"; - -import "./styles.css"; - -function Layout(props) { - const { siteConfig = {} } = useDocusaurusContext(); - const { - favicon, - title: siteTitle, - themeConfig: { image: defaultImage }, - url: siteUrl, - } = siteConfig; - const { - children, - title, - noFooter, - description, - image, - keywords, - permalink, - version, - } = props; - const metaTitle = title ? `${title} | ${siteTitle}` : siteTitle; - const metaImage = image || defaultImage; - const metaImageUrl = useBaseUrl(metaImage, { absolute: true }); - const faviconUrl = useBaseUrl(favicon); - return ( - - - - - {metaTitle && {metaTitle}} - {metaTitle && } - {favicon && } - {description && } - {description && ( - - )} - {version && } - {keywords && keywords.length && ( - - )} - {metaImage && } - {metaImage && } - {metaImage && } - {metaImage && ( - - )} - {metaImage && ( - - )} - {permalink && ( - - )} - {permalink && } - - - - -
{children}
- {!noFooter &&