Closed ftolsson closed 2 years ago
This is actually not a small issue, because I've struggled with it quite a lot. The issue is caused by the significance of whitespace when parsing Fountain markup. I think the quickest fix would be to just join consecutive centered lines into one paragraph.
The issue itself:
• Empty lines are completely ignored by default, and correct whitespace is created only when rendering the document
• If you have two action lines with no whitespace between them, Beat merges those lines into the earlier one. To preserve stylization, formatted indices in the later line are copied into the preceding one. This works pretty well, though I'm sometimes still fixing bugs dealing with merging lines.
• HOWEVER: A centered line is a line type, not a formatting choice. The quickest fix for this would be to apply the same logic as with action lines, and just merge the centered lines into one paragraph. It should work well with your example.
• If somebody would want to have a centered line in between of a paragraph, the current system makes it very tricky. The Line
object should contain something like centeredIndices
, and Beat would wrap those ranges into containers that are displayed as block
s. I'm a bit scared to do that, honestly.
For now, I think I'll just settle to merging neighboring centered lines.
Well, nobody in their right mind should do this anyway, it's just ugly: :)
Seriously though -- sorry for implying it'd be simple (though I did mean it was trivial problem to live with for me as a user, not trivial to fix).
Just a question about the third bullet point, that a centered line is a line type -- isn't that a good thing in itself though?
Wouldn't that help you (disregarding blank lines, as you say) to just acknowledge the >
in the beginning, regardless of preceding blank line or not?
And then, at render time, add a blank line above,if (previousLine.typeAsString() != "Centered")
.
Perhaps that's just as hard/easy as your own suggestion, I'm just thinking it makes more sense to keep the paragraphs apart if that's how they were entered... But I admit I might be overthinking it, it's just about to take physical form so as long as it looks correct I guess maintaining types etc is less important.
Blank lines are not added, but created using element margins. The lines are merged when preprocessing the parsed content for exporting. This is not a difficult thing per se, I might have overthought it originally when I tried to implement mid-paragraph centering.
Editor: Rendered:
I had to take the cue from lyric blocks, rather than paragraphs. I'm a bit worried about how this is taken into account in pagination, but let's see.
... yeah, it required some tweaking and revealed more underlying issues in my code, but they've been fixed now. It's Friday and I didn't get any writing done, but sometimes that's OK.
I hear you. I'm thinking next week's me will surely be a lot more productive than me of this week. (And probably a bit angry that I left him so much, but that's exactly how I felt when this week started too.)
Great job as always! Enjoy your weekend.
Let's say I want a couple of centered paragraphs. They work fine in the editor:
But in print and preview, they cannot be made to appear on adjacent lines:
I'm thinking that if nothing else, the editor should then probably force that line too so that the print doesn't come out as a surprise. (But my vote would be on not adding a blank line above centered text -- not least to be able to stack stuff like above.)
That's all, hope you agree!