tiddler content (paragraphs)

101 views
Skip to first unread message

FND

unread,
May 20, 2007, 5:36:09 AM5/20/07
to Tiddl...@googlegroups.com
Hey all,

I just noticed that extensive tiddler content (i.e. large chunks of
text) is not exactly easy on the eyes.
Playing around with the font settings (font-size, line-height) didn't
really help a lot.

Then I realized the problem was paragraphs; apparently, the wikifier
doesn't use P elements, but simply adds BRs.
This means that I can't define a bottom-margin for paragraphs, but will
have to manually insert a blank line.
However, that blank line is simply too much (roughly speaking, 1em
instead of the 0.2em margin I was aiming for) - not to mention the issue
of separating content from layout).

I realize that this is probably a complex issue with the wikifier, so I
assume the problem is not gonna be solved anytime soon!?
Has anyone encountered this issue before - and if so, how did you solve
it (short of having to manually insert P tags, which in turn would
require Eric's HTMLFormattingPlugin)?


-- F.

Eric Shulman

unread,
May 20, 2007, 6:23:54 AM5/20/07
to TiddlyWiki
> Has anyone encountered this issue before - and if so, how did you solve
> it (short of having to manually insert P tags, which in turn would
> require Eric's HTMLFormattingPlugin)?

To insert a non-matched <p> singleton, you don't need a plugin... the
TW core supports embedding of "pure" HTML syntax directly into your
tiddler content, simple by surrounding it with <html>...</html>

blah blah blah <html><p></html> blah blah blah

However, to get the full benefit of paragraph formatting, you would
want to use the properly-matched <p>...</p> block definition
surrounding your wiki-syntax content, in which case, you *would* need
to use the HTMLFormattingPlugin, since the content in between the
<p>...</p> would need additional "wikify()" processing to be rendered.

<html>
<p>
blah blah blah
etc.
blah blah blah foo.
</p>
</html>

Unfortunately, even with the plugin, bracketing your paragraphs with
<p>...</p> can be a bit of a tedious nuisance. Nonetheless, if you
are resigned to do that editing work to get your document to look just
right, you can still avoid using any HTML entirely by use a custom CSS
class wrapper instead:

First, in your [[StyleSheet]], write:
.paragraph { display:block; margin-top:.2em; margin-bottom:.2em; }

Then, in your tiddler content, you can write:

{{paragraph{
This is the first paragraph, blah blah blah...
etc.
...blah blah foo.}}}
{{paragraph{
This is the second paragraph, blah blah blah...
etc.
...blah blah foo.}}}

HTH,
-e
Eric Shulman
TiddlyTools / ELS Design Studios

FND

unread,
May 20, 2007, 6:42:26 AM5/20/07
to Tiddl...@googlegroups.com
> Unfortunately, even with the plugin, bracketing your paragraphs with
> <p>...</p> can be a bit of a tedious nuisance.

Exactly; in a way, having to use extra markup for such basic things also
defeats the purpose of having wiki markup at all.

> you can still avoid using any HTML entirely by use a custom CSS
> class wrapper instead

I hadn't thought of that; it's a good idea.
Unfortunately, the {{class{...}}} markup is even more tedious to use
than <p>...</p> (though the basic issue is having to remember using a
wrapper at all).

Just out of curiosity, am I the only one who thinks this is a big issue?
(I rarely used TiddlyWiki for large chunks of text before - mainly short
snippets, lists and code - but now that I've expanded the scope, this
issue feels like a serious nuisance.)*


-- F.


* I guess I don't have to mention it, but just for the record: I do
acknowledge how difficult it is to get this right, and I still admire JR
and the Dev Crew for their achievements with my favorite wiki engine!

Daniel Baird

unread,
May 20, 2007, 6:47:37 AM5/20/07
to Tiddl...@googlegroups.com
"TiddlyWiki should generate proper <P> paragraph tags" is ticket #34:
http://www.tiddlywiki.org/ticket/34

Looks like it's on the plan for version 2.3. If you were highly
motivated, you could work on a formatter for generating proper <p>
tags, and let the core team know about it. I'm sure they'd appreciate
the work..

;Daniel


--
Daniel Baird
http://tiddlyspot.com (free, effortless TiddlyWiki hosting)
http://danielbaird.com (TiddlyW;nks! :: Whiteboard Koala :: Blog ::
Things That Suck)

FND

unread,
May 20, 2007, 7:31:00 AM5/20/07
to Tiddl...@googlegroups.com
> Looks like it's on the plan for version 2.3.

That's sooner than I had hoped (theoretically, 2.3 is due in about three
months... )[1].

> If you were highly motivated, you could work on a formatter for
> generating proper <p> tags, and let the core team know about it.

I am in fact highly motivated, but I'm afraid most of TiddlyWiki's code
is far beyond my humble capabilites.
I've already tried fiddling with the formatter/wikifier for fixing
nested lists (ticket #302)[2], as well as for headings (see [twdev],
"ignoring blank lines around headings")[3] - but to no avail...


-- F.


[1] http://www.tiddlywiki.org/roadmap
[2] http://www.tiddlywiki.org/ticket/302
[3] http://groups.google.com/group/TiddlyWikiDev/t/c61b072d5ed227b1

Daniel Baird

unread,
May 20, 2007, 8:23:00 AM5/20/07
to Tiddl...@googlegroups.com
On 20/05/07, FND <Ace_...@gmx.net> wrote:
> [...]

> I am in fact highly motivated, but I'm afraid most of TiddlyWiki's code
> is far beyond my humble capabilites.
> I've already tried fiddling with the formatter/wikifier for fixing
> nested lists (ticket #302)[2], as well as for headings (see [twdev],
> "ignoring blank lines around headings")[3] - but to no avail...

Yeah it's a big step in complexity from the current system.. the
current thing just sees a line break and outputs a <br> tag. To make
proper paragraphs, it would have to start a paragraph by skipping
forwards through the wiki markup, looking for a line break that wasn't
part of other markup (like the end of a heading etc). Once it finds
the right blank line, it needs to wikify all the content it skipped
over, and wrap the output in <p> </p>.

The hardest bit is that when it's skipping through looking for where
to put the end tag, it needs to allow for other nested paragraphs, as
well as paragraphs nested inside blocks, table cells and the like.

I think we should start a paragraph tag bounty, so we can buy Martin
and Jeremy something nice when paragraphs start working:
http://www.winedancer.com/index.html?lang=en-uk&target=p1548.html

Wotcha think?

;D

FND

unread,
May 20, 2007, 11:23:35 AM5/20/07
to Tiddl...@googlegroups.com
> I think we should start a paragraph tag bounty, so we can buy Martin
> and Jeremy something nice when paragraphs start working:
> http://www.winedancer.com/index.html?lang=en-uk&target=p1548.html

Hehe, that's a nice idea.
Though I guess they'd prefer us donating directly via PayPal
(http://tiddlywiki.com/#Donations) rather than waiting until, someday,
we can come up with 750 quid for "perishable goods"... ;)


-- F.

Jeremy Ruston

unread,
May 20, 2007, 7:29:27 PM5/20/07
to Tiddl...@googlegroups.com
> Though I guess they'd prefer us donating directly via PayPal
> (http://tiddlywiki.com/#Donations) rather than waiting until, someday,
> we can come up with 750 quid for "perishable goods"... ;)

You're really very kind, and quite right this is a bit of a humdinger.
Martin's implementations of the Mediawiki and Socialtext formatters do
handle <P> tags correctly thouugh (although I believe there are still
some issues in certain edge cases). So I think we're in good shape to
solve this; the problem when we do will no doubt be backwards
compatibility....

Cheers

Jeremy

>
>
> -- F.
>
> >
>


--
Jeremy Ruston
mailto:jer...@osmosoft.com
http://www.tiddlywiki.com

cflow

unread,
Jun 11, 2013, 8:15:18 PM6/11/13
to tiddl...@googlegroups.com, Tiddl...@googlegroups.com, jeremy...@gmail.com
Hi Jeremy, 

Was this ever resolved?
It seems like if it can place <br> in the correct positions then its smart enough to find the start of paragraphs and the end of paragraphs already. I have read a few of the group pages and anything I can find online but it isn't part of the latest TiddlyWiki version.

If its smart enough to find the start and end of paragraphs to place the <br> surely it is a minor mod to add the <p> at the start and </p> to the end?

What am I missing? If someone can point me to the code that does the search for the start/end of paragraphs I will have a crack :)

cflow

unread,
Jun 11, 2013, 9:13:04 PM6/11/13
to tiddl...@googlegroups.com, Tiddl...@googlegroups.com, jeremy...@gmail.com
Had a quick look and this piece of code seemed to do the replace:
name: "lineBreak",
match: "\\n|<br ?/?>",
handler: function(w)
{
createTiddlyElement(w.output,"br");
}
Looks like the specific feature searched on is the "\\n" which would be the newline character to find, so the start/end of paragraph search I thought was happening, is not :(
 
So I changed:
createTiddlyElement(w.output,"br");
to:
createTiddlyElement(w.output,"hr");

Then applied some CSS to the ".viewer hr" as it is specifically where I want the "hr" tag formatting:
.viewer hr{border-style:none;padding-bottom:0.25em;color:#fff;background-color:transparent;}
 
which gave me the desired result of space between paragraphs.

If I want to add a horizontal rule, which I rarely do, I use can use the following:
.hrule hr{border-bottom:1px solid red;padding-bottom:0.25em; }
with inline use of the class:
{{hrule{
----
}}}
 
I still would prefer a better solution, but this workaround gets me the visible result. I haven't seen any issues so far... ;)

Jeremy Ruston

unread,
Jun 12, 2013, 3:25:23 AM6/12/13
to cflow, TiddlyWiki
Hi cflow

Firstly, that's an ingenious solution: as you probably discovered you can't usefully style the <br> element with CSS, but <hr> makes a lot of sense as a substitute.

Secondly, to answer your original question, the reason that it's not easy to change the TiddlyWiki wikifier to emit <p>'s instead of <br>'s is just to do with the way that the code is written: at the point where the parsing code encounters the newline it no longer knows the location of the previous one. It would be possible to fix this by rewriting the wikifier, but back in 2007/8 we concluded that this couldn't be done without breaking backwards compatibility.

TiddlyWiki5 does parse paragraphs properly as <p> tags, but is also not backwards compatible with classic TW syntax.

Best wishes

Jeremy


--
Jeremy Ruston
mailto:jeremy...@gmail.com

cflow

unread,
Jun 12, 2013, 8:39:17 PM6/12/13
to tiddl...@googlegroups.com, cflow, jeremy...@gmail.com
Found a better way I think. One of the problems with my solution is I now have to double handle "hr" in the CSS rules.

I can create my own HTML tag, but that requires changes, may not be exactly compatible and will definitely require a change to the base TW (I think). See here the solution from Timothy Perez:

So after a little research (thanks Google!) I found a list of ALL html tags (http://www.w3schools.com/tags/), and located ones that are not really used at all but they all require closing tags, which seems to cause some fatal issues with the display. It's a shame 'cos I would have loved to use <s> (cue Superman theme). 

Then I found <area> which solves the issue!

For the css display issues (extra spacing between elements) I found that when a <area> tag preceded a <ul>, <ol> or <blockquote> tag there was whatever formatting from the <ul>, <ol>, <blockquote> plus the formatting for <area>. It doesn't seem as visible an issue with headers for instance as they already require a bit of separation and the margin-bottom:0.5em I put on <area> doesn't seem to much. Because these three are usually inline paragraph text and follow a ":" in the copy. I added the following to address this:
ul, ol, blockquote{margin-top:0;}

There may be more tags, but I can add them as I find them. 

Now I don't have any issues resolve across the TW and I have a quality solution for my paragraph spacing.

Solution is now:
  1. In the TW html, find:

  1. name: "lineBreak",
    match: "\\n|<br ?/?>",
    handler: function(w)
    {
    createTiddlyElement(w.output,"br");
    }
  1. and change:
    createTiddlyElement(w.output,"br");
    to:
    createTiddlyElement(w.output,"area");
  2. Apply some CSS to the "area" tag:
    area{display:block;border-style:none;margin:0 0 0.5em 0;padding:0; }
  3. Apply some CSS to the ul, ol and blockquote tags to over-ride their defaults. The "~" ensures that the format change only happens where <area> directly precedes the <ul> tag etc. :
    area ~ ul, area ~ ol, area ~ blockquote{margin-top:0;}
Reply all
Reply to author
Forward
0 new messages