Skip to content

Commit

Permalink
Fixed highlighted lines in code blocks being cutoff on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
squidfunk committed Apr 14, 2024
1 parent cd08611 commit 9d33f8a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion material/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@
</script>
{% endblock %}
{% block scripts %}
<script src="{{ 'assets/javascripts/bundle.b4d6038a.min.js' | url }}"></script>
<script src="{{ 'assets/javascripts/bundle.ae821067.min.js' | url }}"></script>
{% for script in config.extra_javascript %}
{{ script | script_tag }}
{% endfor %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {
import { feature } from "~/_"
import {
getElementContentSize,
getElements,
watchElementSize,
watchElementVisibility
} from "~/browser"
Expand Down Expand Up @@ -226,6 +227,14 @@ export function mountCodeBlock(
}
}

// If the code block has line spans, we can add this additional class to
// the code block element, which fixes the problem for highlighted code
// lines not stretching to the entirety of the screen when the code block
// overflows, e.g., on mobile - see
const spans = getElements(":scope > span[id]", el)
if (spans.length)
el.classList.add("md-code__content")

/* Create and return component */
return watchCodeBlock(el)
.pipe(
Expand Down

0 comments on commit 9d33f8a

Please sign in to comment.