Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CodeBlock Highlighting #217

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
165 changes: 165 additions & 0 deletions apps/docs/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,172 @@ const config = {
plain: {
...prismThemes.vsDark.plain,
backgroundColor: "#111827",
color: "#e6e6e6",
},
styles: [
...prismThemes.vsDark.styles,
{
types: ["comment", "prolog", "doctype", "cdata"],
style: {
color: "#6a9955",
fontStyle: "italic",
},
},
{
types: ["namespace"],
style: {
opacity: 0.7,
},
},
{
types: ["string", "attr-value"],
style: {
color: "#ce9178",
},
},
{
types: ["punctuation", "operator"],
style: {
color: "#d4d4d4",
},
},
{
types: ["entity", "url", "symbol", "number", "boolean", "variable", "constant", "property", "regex", "inserted"],
style: {
color: "#b5cea8",
},
},
{
types: ["atrule", "keyword", "attr-name", "selector"],
style: {
color: "#569cd6",
},
},
{
types: ["function", "deleted", "tag"],
style: {
color: "#f44747",
},
},
{
types: ["function-variable"],
style: {
color: "#dcdcaa",
},
},
{
types: ["tag", "selector", "keyword"],
style: {
color: "#569cd6",
},
},
{
types: ["important", "bold"],
style: {
// fontWeight: "bold",
},
},
{
types: ["italic"],
style: {
fontStyle: "italic",
},
},
{
types: ["key", "property"],
languages: ["yaml", "yml"],
style: {
color: "#9cdcfe",
},
},
{
types: ["string"],
languages: ["yaml", "yml"],
style: {
color: "#ce9178",
},
},
{
types: ["number"],
languages: ["yaml", "yml"],
style: {
color: "#C5DDB8",
},
},
{
types: ["function", "builtin"],
languages: ["bash", "shell", "sh"],
style: {
color: "#569CD6", // Light blue for commands
},
},
{
types: ["command", "builtin"],
languages: ["bash", "shell", "sh"],
style: {
color: "#569CD6", // Light blue for commands
fontWeight: "bold",
},
},
{
types: ["option", "parameter"],
languages: ["bash", "shell", "sh"],
style: {
color: "#eac787", // Yellowish for parameters
},
},
{
types: ["keyword", "selector"],
languages: ["bash", "shell", "sh"],
style: {
color: "#81a1c1", // Blue for keywords like if, then, else
},
},
{
types: ["string", "char", "attr-value"],
languages: ["bash", "shell", "sh"],
style: {
color: "#a3be8c", // Green for strings
},
},
{
types: ["variable"],
languages: ["bash", "shell", "sh"],
style: {
color: "#d8dee9", // Light gray for variables
},
},
{
types: ["comment"],
languages: ["bash", "shell", "sh"],
style: {
color: "#616e88", // Gray for comments
fontStyle: "italic",
},
},
{
types: ["shebang"],
languages: ["bash", "shell", "sh"],
style: {
color: "#8fbcbb", // Cyan for shebang
fontWeight: "bold",
},
},
{
types: ["operator"],
languages: ["bash", "shell", "sh"],
style: {
color: "#81a1c1", // Blue for operators
},
},
{
types: ["punctuation"],
languages: ["bash", "shell", "sh"],
style: {
color: "#eceff4", // White for punctuation
},
},
],
},
},
zoom: {
Expand Down
21 changes: 21 additions & 0 deletions apps/docs/src/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,27 @@
.btn-clear {
@apply bg-transparent shadow-none border-0 outline-none cursor-pointer;
}

.code-wrapper {
@apply rounded;
}

/* Add text selection styling */
.code-wrapper pre code::selection,
.code-wrapper pre span::selection,
.code-wrapper pre::selection {
background-color: rgba(66, 153, 225, 0.5) !important; /* sky-blue with transparency */
color: white !important;
}

.code-wrapper .selection\:bg-sky-700.selection\:text-green-400 pre code {
@apply select-auto;
}

/* Add better styling for code blocks */
.theme-code-block {
@apply rounded overflow-hidden;
}
}

:root {
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/src/theme/CodeBlock/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default function CodeBlock({
};

return (
<div className="code-wrapper selection:bg-sky-700 selection:text-green-400">
<div className="code-wrapper">
{(title || badge.label) && (
<div className="code-header">
{title}
Expand Down