Add max-height setting for code blocks - #310
Open
faisalahammad wants to merge 1 commit into
Open
Conversation
Adds a global "Max Height" setting to the SyntaxHighlighter settings page. When set (in pixels), code blocks get a max-height with a vertical scrollbar so long code no longer stretches the page. Setting is off by default (0). Applies to both shortcode and Gutenberg block output. No build step needed (PHP only). Fixes Automattic#282
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #282
Changes proposed in this Pull Request
Adds a global "Max Height (in pixels)" setting to the SyntaxHighlighter settings page. When set, code blocks get a
max-heightwith a vertical scrollbar instead of stretching the page, which addresses the reporter's request for a settings-page way to cap the length of displayed code.The setting is off by default (
0), so existing sites are unchanged. It applies to both shortcode and Gutenberg block output, independent of which SyntaxHighlighter engine version is active (v2 or v3). No build step is required (PHP only).What changed in
syntaxhighlighter.php:0added to the settings defaults (disabled).0disables).<style>element into<head>:The
!importantrules are needed because the SyntaxHighlighter core stylesheet setsoverflow-y: hidden !importanton.syntaxhighlighter; the injected style comes after in source order so it wins.I picked pixels over a line count because the SH3 engine forces an 8px line height while SH2 uses
1.1em, so a line-based setting would render inconsistently between versions.Testing instructions
[sourcecode]shortcode block and asyntaxhighlighter/codeGutenberg block, each with 50+ lines of code.300in "Max Height (in pixels)", then Save Changes.0, then Save Changes. Expected: code blocks render at full height, same as before this change.New/Updated Hooks
None. No new or updated actions or filters.
Deprecated Code
None. No code is being deprecated.
Screenshot / Video
No UI screenshots submitted for this change (settings page field only, no design change).