From 4f76c2546a4014eb874af79da1fb83e5df849f96 Mon Sep 17 00:00:00 2001 From: iBug Date: Mon, 6 May 2024 21:06:32 +0800 Subject: [PATCH] Try fixing copy button flying out --- CHANGELOG.md | 4 +++ _sass/minimal-mistakes/_page.scss | 4 +++ _sass/minimal-mistakes/_utilities.scss | 9 +++-- docs/_docs/18-history.md | 6 +++- ...009-10-06-edge-case-broken-highlighting.md | 33 +++++++++++++++++++ 5 files changed, 50 insertions(+), 6 deletions(-) create mode 100644 docs/_posts/2009-10-06-edge-case-broken-highlighting.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 285dfaef..72d2aec3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Bug Fixes + +- Fix copy button going out of range for invalid syntax highlighting blocks. + ### Enhancements - Change the icon of a copy button into a tick for 1.5 seconds on successful copy. diff --git a/_sass/minimal-mistakes/_page.scss b/_sass/minimal-mistakes/_page.scss index 847dc4c4..a898d0cd 100644 --- a/_sass/minimal-mistakes/_page.scss +++ b/_sass/minimal-mistakes/_page.scss @@ -139,6 +139,10 @@ body { } } + pre { + position: relative; + } + :not(pre) > code { padding-top: 0.1rem; padding-bottom: 0.1rem; diff --git a/_sass/minimal-mistakes/_utilities.scss b/_sass/minimal-mistakes/_utilities.scss index 42333670..856d9fc2 100644 --- a/_sass/minimal-mistakes/_utilities.scss +++ b/_sass/minimal-mistakes/_utilities.scss @@ -608,6 +608,10 @@ a.reversefootnote { } pre { + &.highlight .clipboard-copy-button { + color: #ffffca; + } + .clipboard-copy-button { display: block; position: absolute; @@ -621,14 +625,9 @@ pre { outline: none; border-radius: 0.1em; padding: 0.2em 0.5em; - color: white; opacity: 0.4; transition: color 0.25s linear -0.25s, opacity 0.25s linear; - &:hover { - color: #ffffca; - } - &::before { content: ''; position: absolute; diff --git a/docs/_docs/18-history.md b/docs/_docs/18-history.md index bae35c10..d5d9a821 100644 --- a/docs/_docs/18-history.md +++ b/docs/_docs/18-history.md @@ -5,7 +5,7 @@ permalink: "/docs/history/" excerpt: Change log of enhancements and bug fixes made to the theme. sidebar: nav: docs -last_modified_at: '2024-05-06T01:20:38+08:00' +last_modified_at: '2024-05-06T21:06:31+08:00' toc: false --- @@ -17,6 +17,10 @@ toc: false {% raw %} ## Unreleased +### Bug Fixes + +- Fix copy button going out of range for invalid syntax highlighting blocks. + ### Enhancements - Change the icon of a copy button into a tick for 1.5 seconds on successful copy. diff --git a/docs/_posts/2009-10-06-edge-case-broken-highlighting.md b/docs/_posts/2009-10-06-edge-case-broken-highlighting.md new file mode 100644 index 00000000..c2fee01e --- /dev/null +++ b/docs/_posts/2009-10-06-edge-case-broken-highlighting.md @@ -0,0 +1,33 @@ +--- +title: "Edge Case: Invalid syntax highlight languages" +categories: + - Edge Case +tags: + - content + - css + - edge case +--- + +Good highlighting: + +```ruby +str = ARGV.first +if str + str = str.b[/\A_(.*)_\z/, 1] + if str and Gem::Version.correct?(str) + version = str + ARGV.shift + end +end +``` + +Bad highlighting: + +```invalid +if Gem.respond_to?(:activate_bin_path) + load Gem.activate_bin_path('jekyll', 'jekyll', version) +else + gem "jekyll", version + load Gem.bin_path("jekyll", "jekyll", version) +end +```