Skip to content

Commit

Permalink
Disable copy button for bad pre blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
iBug committed May 6, 2024
1 parent 4f76c25 commit 438710d
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Bug Fixes

- Fix copy button going out of range for invalid syntax highlighting blocks.
- Disable copy button on invalid syntax highlighting blocks to avoid positioning issues.

### Enhancements

Expand Down
4 changes: 0 additions & 4 deletions _sass/minimal-mistakes/_page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,6 @@ body {
}
}

pre {
position: relative;
}

:not(pre) > code {
padding-top: 0.1rem;
padding-bottom: 0.1rem;
Expand Down
2 changes: 1 addition & 1 deletion assets/js/_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ $(document).ready(function () {

if (window.enable_copy_code_button) {
document
.querySelectorAll(".page__content pre > code")
.querySelectorAll(".page__content pre.highlight > code")
.forEach(function (element, index, parentList) {
// Locate the <pre> element
var container = element.parentElement;
Expand Down
2 changes: 1 addition & 1 deletion assets/js/main.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/main.min.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/_docs/18-history.md
Original file line number Diff line number Diff line change
Expand Up @@ -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-06T21:06:31+08:00'
last_modified_at: '2024-05-06T21:15:29+08:00'
toc: false
---

Expand All @@ -19,7 +19,7 @@ toc: false

### Bug Fixes

- Fix copy button going out of range for invalid syntax highlighting blocks.
- Disable copy button on invalid syntax highlighting blocks to avoid positioning issues.

### Enhancements

Expand Down
25 changes: 20 additions & 5 deletions docs/_posts/2009-10-06-edge-case-broken-highlighting.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,28 @@ if str
end
```

Good (but dumb) highlighting:

```
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)
str = ARGV.first
if str
str = str.b[/\A_(.*)_\z/, 1]
if str and Gem::Version.correct?(str)
version = str
ARGV.shift
end
end
```

0 comments on commit 438710d

Please sign in to comment.