sillsdev / ptx2pdf

XeTeX based macro package for typesetting USFM formatted (Paratext output) scripture files
23 stars 8 forks source link

Possibly unexpected behaviour from ranged milestones with paragraph styles #764

Open davidg-sil opened 2 years ago

davidg-sil commented 2 years ago

The paragraph spacing, etc. in-force at the end of a paragraph are what governs the layout. I.e. the starting state of a paragraph is irrelevant, only the final state. This means that a \p that contains a milestone that alters a paragraph style will be affected by that style, even if it is the very last thing in the paragraph. I.e. while the character styling effects are different, in terms of paragraph styling these are equivalent: \p \zright-s\* [.....] , \p [.....] \zright-s \* [.......] and \p [...............] \zright-s\*

This in turn means that

\p [text]
\zright-s\*
\p I expect just this line to be right
\p And this one.
\zright-e\*

Will not do what the user expects. What will happen is that the preceding paragraph will be set right, along with unless there are \ps added before the milestone start and ends.

A solution to this might be to use futurelet to scan ahead, and if the next non-space item is going to be a paragraph mark, to end the current paragraph before the milestone comes into effect. This could be made more efficient if there was a private/internal parameter defined for the milestone that said whether this milestone caused paragraph changes.

mhosken commented 3 days ago

This is where we need the concept of a paragraph milestone. I'd be happy to add the category to the USFM spec even if we have no instances of it in the USFM spec yet.

davidg-sil commented 3 days ago

I initially thought 'yes please!' (I even typed it), but I expect some push-back (1) and need for clarification (2):

  1. The above issue of the paragraph properties only being valid at the end of the par are quite possibly a TeX-only problem.
  2. Is the paragraph milestone causing a new paragraph, and if so, what sort of new paragraph? or is a mid-paragraph 'paragraph milestone' invalid? It feels to me that a true paragraph-milestone should be considered <div>-like and be immediately followed by a new paragraph marker.
  3. We could say that a milestone that causes changes to paragraph-level settings automatically becomes a paragraph milestone (and thus causes an \endl@stparstyle before setting anything new).