create new tag
, view all tags
At PeterThoeny's request, this was moved from FeatureEnhancementRequests / FeatureDone to here.

-- DavidLeBlanc - 30 Jul 2001

Where are paragraphs parsed/generated in the twiki code.

I want to know this in support of a TWiki project i'm working on, and I have looked in the code for the answer already. In particular, I can't figure out how TWiki deals with newlines in structured text to go from that to html.

-- DavidLeBlanc - 18 Jul 2001

The only special processing that I'm aware of is that TWiki convert empty lines into html <p> entries. Otherwise things are much like HTML.

-- JohnTalintyre - 18 Jul 2001

It's not clear to me what markup is used for empty lines. Naturally, that was the point of the enhancement suggestion. Heh.

Let's try the question again, since the enhancement doesn't seem to be worth considering. Looking at TWiki.pm in getRenderedText starting at approximately line 1741, the first thing that's done with the $text is to remove all \\r characters and then join lines ending in \\. Then, at line 1767 begins a loop that processes each line. After processing much markup, at line 1903, empty lines are removed (a bit late?). At the last, if one was in a table or pre section the requisite closeing tags are emitted. At no place in that routine is a <p> tag emitted except for starting a list (for some reason). I'm tryin g to find out where twiki emits a starting <p> tag so I can figure out how to get it to emit the closing &lt/p> tag so that stylesheet styles will work for paragraphs. (I don't think lists are closed either from the look of this code either.)

-- DavidLeBlanc - 18 Jul 2001

The emission of <p> is in the section with a comment about lists etc, but this is where a blank line is converted to a paragraph tag (this is not list specific). I don't believe a paragraph start is produced at the top of the topic. I'd be interested to know what you need to do with the stylesheet that requires this.

On lists:

  • item

produces the following HTML:

<LI> item

so end of list is closed correctly, but possibly you meant that <li> wasn't closed.

-- JohnTalintyre - 19 Jul 2001

TWiki puts out HTML that CSS doesn't get along with due to taking advantage of optional tag endings - see BadHTML, a FeatureToDo. I'm interested in getting this to work to some extent so that I can do more work on adding stylesheets.

-- DavidLeBlanc - 19 Jul 2001

David, you still haven't said what you can't do. We use style sheets with TWiki without any problem. However, I'm sure Peter will gradually want to address this as TWiki moves get more XHTML compliant.

-- JohnTalintyre - 20 Jul 2001

John, My initial tests with stylesheets identified some problems with how TWiki renders HTML. This prompted me to write BadHTML. Peter responded, agreed that TWiki HTML output could be better and started topic ConvertToXHTML10 in FeatureUnderConstruction. Working with the 20010717 beta i've seen at least one additional glitch: The initial paragraph of a topic does not get a <p> tag at all, let alone a closing tag. I don't know if this happens only if it starts right at the beginning, or if it also happens when the first line(s) are blank too.

Although not an experienced perl programmer, I am, after 30 years at it, reasonably competent to wrangle bits. Rather then being a consumer of the fruits of the TWiki tree, i'd rather help grow it. I want to start on the task of normalizing TWiki's HTML output. Now that i've unearthed my "Programming Perl 2nd Ed." book, i'm now armed and dangerous ;-).

My first intention is to clean up the rendering of paragraphs and list items to generate closing tags. Questions about this have been the example DeveloperQuestions question that i've posed, but it's a real one.

After that, I want to remove all attribute generation (i.e. color= #0f0f0f) from twiki code if possible or at least work off a user preference flag so that such attributes are conditionally generated inline on a per user basis. I don't think that a full xhtml conformance is feasible given a need to generate HTML 3.2 conforming HTML that works for all. (One reason: Per css, the closer an attribute/style is to a tag, the more precedence it has, so inline attribute/styles overcome stylesheet styles.)

What I see needing done for twiki.pm:getRenderedVersion at first is:

  • Insert some "is first line" logic to get a p tag generated for the very first paragraph.
  • Add an $insidePara predicate that gets set when a p tag is generated.
  • Have that predicate queried at appropriate places in the code to generate a p end tag and clear the predicate.

The same general scheme is needed for list items ($insideLI, check predicate, etc.) since they can span lines in structured text (as the last bullet I just did does).

Sooo, that's what i'm intent on: journeyman TWikiTweaker and this is the first (reasonably simple I hope) task I want to do.

Hope that answers your question John.

Belated note: I know see that the place where the p tag is generated is the place where p tags are generated - I was confused by the preceding comment. I also see why the lines are joined further down and that it's not a check for blank lines (not sure where those vanish yet).

-- DavidLeBlanc - 23 Jul 2001

Ok, working on this again and some more specific questions re. this topic have come up:

  1. What does $code do, especially in emitCode? I'm particularly curious to know what is getting done in the list processing statements around line 1867 of TWiki::getRenderedVersion.
  2. What does emitCode do? Why all the pushing and popping?

-- DavidLeBlanc - 30 Jul 2001

This is inherited code from JosWiki. emitCode opens and closes lists, e.g. changes the nesting level. The number of tabs (aka triple spaces) determine the nesting level. The global @code keeps track of the list type of all levels, i.e. if you shift out you need to continue with the list type of that level (OL or UL or DL). There is a pending XHTML problem, see BetterLists.

In regards to paragraphs, they are now XHTML conform. However, TWiki simply adds <p /> tags for empty lines, e.g. there is no leading <p> tag. This could be fixed at some time.

-- PeterThoeny - 20 Nov 2001

Since when does TWiki emit vertical space between paragraphs which relates to the number of blank lines in the plain text? Example:

One blank line above

Two blank lines above. Up to the last release, the spacing would be equal... Bug or feature? Or is this a doctype / XHTML issue?

-- PeterKlausner - 31 May 2005

Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r3 - 2005-05-31 - PeterKlausner
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2015 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.