When exporting to HTML, is there a way to change when a line is designated as a new paragraph and given the paragraph tags?
For example, if I have a note with the following text:
First paragraph line 1
First paragraph line 2
First paragraph line 3
Next paragraph line 1
Next paragraph line 2
Next paragraph line 3
It will export in HTML as:
<p>First paragraph line 1</p>
<p>First paragraph line 2</p>
<p>First paragraph line 3</p>
<p>Next paragraph line 1</p>
<p>Next paragraph line 2</p>
<p>Next paragraph line 3</p>
What I would like is:
<p>First paragraph line 1
First paragraph line 2
First paragraph line 3</p>
<p>Next paragraph line 1
Next paragraph line 2
Next paragraph line 3</p>
I did take a look at the documentation and I saw the $HTMLParagraphStart/End attributes that you mentioned. However, I donât think thatâs what needs to be modified, but I could be wrong since Iâm new to TBX.
I think what needs to be modified is where TBX designates a new paragraph. It looks like it designates a new paragraph at a single newline, but I would like to change it so it designates it at two newlines.
That was going to be my new question: how do we recognize where the paragraph starts?
Short answer: you canât change this.
Clever answer: you can, if you want! Three ways:
Quick and dirty: Search and replace double newlines with a place marker string â perhaps ââ˘â. Now, replace all remaining newlines with the empty string. Finally, replace your place marker string with a single newline \n.
Less quick, less dirty: Explode your text at double newlines. For the exploded notes, omit paragraph markup entirely, and insert <p> and </p> before and after the text in the template.
Less dirty, arguably: use ctrl-Return to obtain a line break in Tinderbox that is not treated as a paragraph ending for export.
The alternative approach is to use tags in HTML or Markdown. Using <br> over ctrl-return could give you more control down the road as you can use action code to easily remove them later
Exporting to HTML can be a bit finicky with how it handles paragraph breaks, especially if youâre trying to keep the code clean. If youâre seeing weird spacing or unwanted line breaks in the output, itâs often due to how the source text is structured before the export filters even touch it.
One thing that helps me is âflatteningâ the text first to make sure there arenât any hidden breaks causing issues. I usually just run it through Paragraph to Single Line Converter Online to get a clean block of text before I apply the HTML tags. Itâs much easier than hunting through the source code to find where a stray or tag is coming from!
Empty paragraphs are not exported to HTML, if using the likes of $Text. So a run of, for instance 3 line breaks (\n\n\n) is treated as if one (\n).
If the eye is offended by âmessyâ HTML output, time getting to know export code is recommended. In a template all line breaks are literal. A common misunderstanding re output is to put a line break after an^endIf^ rather than before it. This does mean the template looks a bit odd as the ^endIf^ now sitâin the templateâat the beginning of the next paragraph. It is certainly hard to get âprettyâ layout in all three of $Text, template and output HTML. For my 2¢, I put up with a messy looking template layout in order that the HTML layout is cleaner. Only I look at the template: others might need to look at (understand) the output code.