feat: make Buckram compatible with latest SCSSPHP #304
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.
Context for the issue
When a book author selects the position for running content in PDF outputs, a complex series of rules must be applied. For example, if one indicates that:
…the CSS needs to respond appropriately:
@bottom-left
area when a chapter begins on the left page@bottom-right
area when a chapter begins on the right page@bottom-center
area on all other left/right pages in the chapter.In all earlier implementations of Buckram, such rules were composed using the following syntax within a few different mixins:
$content-position
would be something like@bottom-center
and the#{}
syntax is Sass's method of string interpolation.HOWEVER. That's not valid Sass. You can't (as far as I can tell) generate an entire selector from an interpolation rule. Trying to do this with
@bottom-center
throws a critical error and the Sass fails to compile. A bug in SCSSPHP <= 1.1.1 was allowing this non-standard SCSS to compile, but the bug was resolved in SCSSPHP 1.2 which broke Buckram's SCSS.What this PR does
Instead of using interpolation, I've created a helper mixin called
position
which, when passed a position value such as@bottom-left
,@top-left
, etc, will wrap content in it. So for example:Compiles to:
This resolves the incompatibility with SCSSPHP (and the SCSS standard) and allows SCSSPHP to be safely updated to the current version.
Testing
To verify that the page structure still works as expected, I completed the following tests:
dev
version of Buckram, I ran:vendor/bin/pscss tests/source/styles/prince-toc-left.scss > before.css
vendor/bin/pscss tests/source/styles/prince-toc-left.scss > after.css
You can compare the output files in the attached Zip archive.
Related issues
Resolves pressbooks/pressbooks#2281.