mirror of
https://github.com/bookorbit/bookorbit.git
synced 2026-11-03 00:11:37 -06:00
fix(reader): honor line spacing over publisher styles
Ensure explicit reader spacing overrides higher-specificity EPUB typography and cover the cascade with a regression test. Fixes #1302
This commit is contained in:
@@ -142,12 +142,33 @@ describe('useReaderState', () => {
|
||||
const css = state.generateCSS()
|
||||
|
||||
expect(css).toContain('font-family: serif !important;')
|
||||
expect(css).toContain('line-height: 1.8;')
|
||||
expect(css).toContain('line-height: 1.8 !important;')
|
||||
expect(css).toContain('font-size: 20px;')
|
||||
expect(css).toContain('text-align: start !important;')
|
||||
expect(css).toContain('hyphens: none;')
|
||||
})
|
||||
|
||||
it('overrides a more specific publisher line height on body text', () => {
|
||||
const state = useReaderState()
|
||||
state.setLineHeight(3)
|
||||
|
||||
const publisherStyle = document.createElement('style')
|
||||
publisherStyle.textContent = '.TX { line-height: 1.31; }'
|
||||
const readerStyle = document.createElement('style')
|
||||
readerStyle.textContent = state.generateCSS()
|
||||
const paragraph = document.createElement('p')
|
||||
paragraph.className = 'TX'
|
||||
|
||||
document.head.append(publisherStyle, readerStyle)
|
||||
document.body.append(paragraph)
|
||||
|
||||
expect(getComputedStyle(paragraph).lineHeight).toBe('3')
|
||||
|
||||
paragraph.remove()
|
||||
publisherStyle.remove()
|
||||
readerStyle.remove()
|
||||
})
|
||||
|
||||
it('preserves publisher paragraph margins at the default spacing', () => {
|
||||
const state = useReaderState()
|
||||
|
||||
|
||||
@@ -230,7 +230,7 @@ export function useReaderState() {
|
||||
}
|
||||
}
|
||||
html {
|
||||
line-height: ${lh};
|
||||
line-height: ${lh} !important;
|
||||
hanging-punctuation: allow-end last;
|
||||
orphans: 2;
|
||||
widows: 2;
|
||||
@@ -276,7 +276,7 @@ export function useReaderState() {
|
||||
: ''
|
||||
}
|
||||
p, li, blockquote, dd {
|
||||
line-height: ${lh};
|
||||
line-height: ${lh} !important;
|
||||
text-align: ${j ? 'justify' : 'start'} !important;
|
||||
hyphens: ${h ? 'auto' : 'none'};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user