diff --git a/assets/css/code.css b/assets/css/code.css index b1524e4d64..89369a61d2 100644 --- a/assets/css/code.css +++ b/assets/css/code.css @@ -1,30 +1,28 @@ -.prose { - pre { - @apply rounded-sm border border-gray-light-200 p-3 dark:border-gray-dark-400; - } - :not(pre) > code { - display: inline-block; - margin: 0 !important; - white-space: nowrap; - font-weight: 400; - padding: 0 4px; - border: 1px solid; - border-radius: theme("spacing.1"); - background: theme("colors.gray.light.200"); - border-color: theme("colors.gray.light.300"); - .dark & { - background: theme("colors.gray.dark.200"); - border-color: theme("colors.gray.dark.300"); - } - } - code::before { - content: ""; - } - code::after { - content: ""; +.highlight, :not(pre) > code { + font-size: .875em; + border: 1px solid; + border-radius: theme("spacing.1"); + border-color: theme("colors.gray.light.300"); + .dark & { + background: theme("colors.gray.dark.200"); + border-color: theme("colors.gray.dark.300"); } } +.highlight { + @apply p-3 my-4 overflow-x-auto; + background: theme("colors.white"); +} + +:not(pre) > code { + background: theme("colors.gray.light.200"); + display: inline-block; + margin: 0; + white-space: nowrap; + font-weight: 400; + padding: 0 4px; +} + .chroma { /* LineTableTD */ .lntd { diff --git a/assets/css/tables.css b/assets/css/tables.css index a90f4e946f..f17081b7c6 100644 --- a/assets/css/tables.css +++ b/assets/css/tables.css @@ -1,5 +1,5 @@ .prose table { - @apply block overflow-x-auto; + @apply block overflow-x-auto text-base; thead tr { @apply bg-gray-light-300 dark:bg-gray-dark-300 } @@ -7,6 +7,6 @@ @apply bg-gray-light-200 dark:bg-gray-dark-200 } th, td { - @apply p-2 !important; + @apply p-2; } } diff --git a/assets/css/typography.css b/assets/css/typography.css index 998d56e321..54084444e2 100644 --- a/assets/css/typography.css +++ b/assets/css/typography.css @@ -1,6 +1,9 @@ .prose { li { @apply mt-1 mb-1; + & > :first-child, & > :last-child { + @apply m-0; + } } a { font-weight: 400; diff --git a/assets/js/src/vars.js b/assets/js/src/vars.js new file mode 100644 index 0000000000..eb11632cab --- /dev/null +++ b/assets/js/src/vars.js @@ -0,0 +1,10 @@ +const codeblocks = document.querySelectorAll(".highlight") + +for (const codeblock of codeblocks) { + codeblock.innerHTML = codeblock.innerHTML + .replaceAll( + /<([A-Z_]+)>/g, + `$1` + ) +} diff --git a/layouts/_default/_markup/render-codeblock.html b/layouts/_default/_markup/render-codeblock.html index 2fa0fa14f1..39cd2dcf20 100644 --- a/layouts/_default/_markup/render-codeblock.html +++ b/layouts/_default/_markup/render-codeblock.html @@ -1,22 +1,13 @@ -{{ $innerHTML := highlight .Inner .Type -| replaceRE - `<([A-Z_]+)?>` - `$1` -}} - -
+
-
- {{- safeHTML $innerHTML -}} -
+ {{- highlight .Inner .Type .Options -}}
diff --git a/tailwind.config.js b/tailwind.config.js index 18e4994561..f7340f5b55 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -7,6 +7,12 @@ module.exports = { typography: (theme) => ({ DEFAULT: { css: { + pre: false, + code: false, + 'pre code': false, + 'code::before': false, + 'code::after': false, + table: false, // light colors for prose "--tw-prose-body": theme("colors.black"), "--tw-prose-headings": theme("colors.black"), @@ -19,9 +25,6 @@ module.exports = { "--tw-prose-quotes": theme("colors.black"), "--tw-prose-quote-borders": theme("colors.blue.light.500"), "--tw-prose-captions": theme("colors.gray.light.600"), - "--tw-prose-code": theme("colors.black"), - "--tw-prose-pre-code": theme("colors.gray.light.800"), - "--tw-prose-pre-bg": theme("colors.white"), "--tw-prose-th-borders": theme("colors.gray.light.200"), "--tw-prose-td-borders": theme("colors.gray.light.200"), @@ -37,9 +40,6 @@ module.exports = { "--tw-prose-invert-quotes": theme("colors.white"), "--tw-prose-invert-quote-borders": theme("colors.blue.dark.500"), "--tw-prose-invert-captions": theme("colors.gray.dark.600"), - "--tw-prose-invert-code": theme("colors.white"), - "--tw-prose-invert-pre-code": theme("colors.background.light"), - "--tw-prose-invert-pre-bg": theme("colors.gray.dark.200"), "--tw-prose-invert-th-borders": theme("colors.gray.dark.200"), "--tw-prose-invert-td-borders": theme("colors.gray.dark.200"), },