Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Extra line breaks between paragraphs

I want a blank line automatically inserted between paragraphs, how do I do it?

I thought CSS was the way, but Sugar Cane seems to break paragraphs with <br> rather than <p>, so is pretty much immune to CSS.

I thought postrender might be a way, but so far that has eluded me too. What are the properties and methods on the content object, for instance?

I am using Sugar Cane, by the way.

Comments

  • You can manually wrap the text within your passages with paragraph tags and then use CSS to style them.

    <p>
    The quick brown fox jumped over the lazy dog.
    </p>
  • I had thought of that. I could also just manually put extra breaks between paragraphs (which is probably what  will do). i was hoping there was a more elegant way to do it.
  • To my mind, the fact that it produces <br> separated text rather than <p> elements is one of the very worst things about it. I don't really have any interest at all in Twine 2 (at least not until there is a way to avoid the visual interface in favor of a text editor), but the switch to Markdown (which produces real HTML) I count as a big plus.
  • I want to ask a question: in Twine 1.4.2 I'm considering not generating <br> elements at all, and instead simply set white-space:pre-line on the passage element. (This change is live in the second beta.) The main motivation for doing this is to prevent <br> elements being created inside complex HTML structures (previously, a bug caused the <table> elements to not work unless their HTML contained no line breaks, or was inside a <<nobr>>) and breaking them in unpredictable ways, or causing structural CSS selectors like :first-child to select a stray <br> instead of the element.

    But, I wonder if this would just cause other unforseen problems - for instance, someone could be selecting <br>s in CSS and styling them in some way.

    Any thoughts on this are welcome.
  • Oh, Lord. I shudder when I think of changes to the CSS in Twine/Sugarcane, honestly. Getting CSS in Twine/Sugarcane to look like it does in a notepad-made webpage is my biggest headache. I don't know if it would cause more problems than fixes, personally.

    I use a lot of tables styled with CSS, but they are all in "nobr" passages, so I guess I never noticed.

    Actually, all of my passages have the "nobr tag." I'd love if there was a way to set that to be the default.

    Also, speaking of <br>, in a passage tagged "nobr", these produce different results:
    <span/div class/id="whatever"><span/div class/id="whatever">
    And
    <span/div class/id="whatever>
    <span/div whatever="class/id">
    Would you ever consider some sort of super blank un-styled sort of CSS header for Twine for people who want to write their own CSS basically from scratch or as near to it as possible? Maybe that's out of the question, and I know you're hard at work on Twine, just throwing that out there. I don't mind battling CSS nearly as much as I hate battling CSS in Twine.

    Anyway, I'm not griping at you for my inadequacies in CSS. I appreciate all your hard work and effort greatly and am thankful you asked for our opinions.
  • Using only the white-space property will probably break copy-pasting text from the story (by which I mean that on paste the selected text will all be one line, not reflecting any line-breaks).
  • Is generating actual paragraphs (<p>) an option?
  • mth wrote:

    Is generating actual paragraphs (<p>) an option?


    Yes, but the devil is in the details and that would be what is a paragraph and what is not.
    While it would be easy to say that one or more sentences of plain text is obvious a paragraph.

    What about if that same text is included via a <<display Passage_name>>, via a <<print $string_of_text>>, or even contained within a table cell.
    Is the wrapping done at the time of generating the HTML file, by the JS engine or both?

    A clear set of rules of when to wrap and how would need to be worked out, and also how to allow an Author to disable it all.
  • greyelf wrote:

    mth wrote:

    Is generating actual paragraphs (<p>) an option?


    Yes, but the devil is in the details and that would be what is a paragraph and what is not.
    While it would be easy to say that one or more sentences of plain text is obvious a paragraph.


    A paragraph would be a non-empty string preceding something that ends a paragraph. Things that end a paragraph would be end of passage and two or more consecuitive newlines. But also things that are mapped to HTML that is not valid inside <p> tags, such as lists (<ul> and <ol>).

    greyelf wrote:

    What about if that same text is included via a <<display Passage_name>>, via a <<print $string_of_text>>, or even contained within a table cell.
    Is the wrapping done at the time of generating the HTML file, by the JS engine or both?


    Doing it at compile time is inconsistent with how TiddlyWiki works; that would only be an option when redesigning the entire system. That is outside the scope of this discussion, but I am curious whether the runtime HTML generation is a historical coincidence (because TiddlyWiki happens to be written in JavaScript) or whether it was done this way because it has benefits over compile time HTML generation.

    When doing it at runtime, as you touched upon, the question is whether paragraph building would be done before or after the macro expansion. I think it should be done after, since it is not easy (and in the case of custom macros, not even possible) to know whether a macro will produce something that is not allowed inside a <p> element.

    I cannot really foresee the full impact of generating <p></p> pairs. I do think that this would make CSS customization simpler than when using line breaks.
  • TheMadExile wrote:

    Using only the white-space property will probably break copy-pasting text from the story (by which I mean that on paste the selected text will all be one line, not reflecting any line-breaks).
    >:(

    W-web programming... how could you do this to me...
Sign In or Register to comment.