Support of MarkupLists for ListTree

View: New views
11 Messages — Rating Filter:   Alert me  

Support of MarkupLists for ListTree

by sch_max :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
I discovered the ListTree-Feature in FitLibrary, which is really cool. But it just works if HTML-Code is used. I think it would be great if Fitnesse-Markup-Language for creating lists could be used. This generates HTML-Code with linebreaks, what seems not to work with ListTree. Is there a way to make it working?

Regards,
Max


Re: Support of MarkupLists for ListTree

by Rick Mugridge :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

It only works with html for lists because, as far as I know, there's no
wiki syntax for creating lists within a cell.

Cheers, Rick

sch_max wrote:

>  
>
> Hi,
> I discovered the ListTree-Feature in FitLibrary, which is really cool.
> But it just works if HTML-Code is used. I think it would be great if
> Fitnesse-Markup-Language for creating lists could be used. This
> generates HTML-Code with linebreaks, what seems not to work with
> ListTree. Is there a way to make it working?
>
> Regards,
> Max
>
>

Re: Support of MarkupLists for ListTree

by sch_max :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



Hi Rick,

there is a Wiki-syntax to create lists in a cell.
It is just like creating nested tables:

!define inner_list ( *Root node
  *Child node
   *Node
 *Node
)

|A Table|
|${inner_list}|

The problem is that this creates html code with linebreaks/whitespaces. And ListTree/FitNesse seems to not correctly parsing this.

Max

--- In fitnesse@..., Rick Mugridge <rick@...> wrote:
>
> It only works with html for lists because, as far as I know, there's no
> wiki syntax for creating lists within a cell.
>
> Cheers, Rick
>


Re: Re: Support of MarkupLists for ListTree

by Rick Mugridge :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Max,

OK, thanks.

The code concerned is ListTree.parse(), a static method. It's quite
simple. If you wanted to fix this to handle the general case, along with
storytests/specifications, I'd be happy to include it in FitLibrary for
Java.

Cheers, Rick

sch_max wrote:

>  
>
>
>
> Hi Rick,
>
> there is a Wiki-syntax to create lists in a cell.
> It is just like creating nested tables:
>
> !define inner_list ( *Root node
> *Child node
> *Node
> *Node
> )
>
> |A Table|
> |${inner_list}|
>
> The problem is that this creates html code with
> linebreaks/whitespaces. And ListTree/FitNesse seems to not correctly
> parsing this.
>
> Max
>
> --- In fitnesse@... <mailto:fitnesse%40yahoogroups.com>,
> Rick Mugridge <rick@...> wrote:
> >
> > It only works with html for lists because, as far as I know, there's no
> > wiki syntax for creating lists within a cell.
> >
> > Cheers, Rick
> >
>
>

Re: Support of MarkupLists for ListTree

by sch_max :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Rick,

I'm using .NET-version of FitLibrary. The ListTree-class doesn't contain a parse()-method. TreeHandler has a method parse(), but isn't static. This method seems to use the Parse-class to parse the HTML code. So, maybe the problem is in Parse-class.

Max


--- In fitnesse@..., Rick Mugridge <rick@...> wrote:

>
> Hi Max,
>
> OK, thanks.
>
> The code concerned is ListTree.parse(), a static method. It's quite
> simple. If you wanted to fix this to handle the general case, along with
> storytests/specifications, I'd be happy to include it in FitLibrary for
> Java.
>
> Cheers, Rick
>
> sch_max wrote:
> >  
> >
> >
> >
> > Hi Rick,
> >
> > there is a Wiki-syntax to create lists in a cell.
> > It is just like creating nested tables:
> >
> > !define inner_list ( *Root node
> > *Child node
> > *Node
> > *Node
> > )
> >
> > |A Table|
> > |${inner_list}|
> >
> > The problem is that this creates html code with
> > linebreaks/whitespaces. And ListTree/FitNesse seems to not correctly
> > parsing this.
> >
> > Max
> >
> > --- In fitnesse@... <mailto:fitnesse%40yahoogroups.com>,
> > Rick Mugridge <rick@> wrote:
> > >
> > > It only works with html for lists because, as far as I know, there's no
> > > wiki syntax for creating lists within a cell.
> > >
> > > Cheers, Rick
> > >
> >
> >
>



Re: Support of MarkupLists for ListTree

by jediwhale :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Didn't realize you were using .NET, I'll take a look.

Mike

--- In fitnesse@..., "sch_max" <sch_max@...> wrote:

>
> Hi Rick,
>
> I'm using .NET-version of FitLibrary. The ListTree-class doesn't contain a parse()-method. TreeHandler has a method parse(), but isn't static. This method seems to use the Parse-class to parse the HTML code. So, maybe the problem is in Parse-class.
>
> Max
>
>
> --- In fitnesse@..., Rick Mugridge <rick@> wrote:
> >
> > Hi Max,
> >
> > OK, thanks.
> >
> > The code concerned is ListTree.parse(), a static method. It's quite
> > simple. If you wanted to fix this to handle the general case, along with
> > storytests/specifications, I'd be happy to include it in FitLibrary for
> > Java.
> >
> > Cheers, Rick
> >
> > sch_max wrote:
> > >  
> > >
> > >
> > >
> > > Hi Rick,
> > >
> > > there is a Wiki-syntax to create lists in a cell.
> > > It is just like creating nested tables:
> > >
> > > !define inner_list ( *Root node
> > > *Child node
> > > *Node
> > > *Node
> > > )
> > >
> > > |A Table|
> > > |${inner_list}|
> > >
> > > The problem is that this creates html code with
> > > linebreaks/whitespaces. And ListTree/FitNesse seems to not correctly
> > > parsing this.
> > >
> > > Max
> > >
> > > --- In fitnesse@... <mailto:fitnesse%40yahoogroups.com>,
> > > Rick Mugridge <rick@> wrote:
> > > >
> > > > It only works with html for lists because, as far as I know, there's no
> > > > wiki syntax for creating lists within a cell.
> > > >
> > > > Cheers, Rick
> > > >
> > >
> > >
> >
>



Re: Support of MarkupLists for ListTree

by sch_max :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Oh, I'm sorry. I didn't wrote that.

Max

--- In fitnesse@..., "jediwhale" <jediwhale@...> wrote:

>
> Didn't realize you were using .NET, I'll take a look.
>
> Mike
>
> --- In fitnesse@..., "sch_max" <sch_max@> wrote:
> >
> > Hi Rick,
> >
> > I'm using .NET-version of FitLibrary. The ListTree-class doesn't contain a parse()-method. TreeHandler has a method parse(), but isn't static. This method seems to use the Parse-class to parse the HTML code. So, maybe the problem is in Parse-class.
> >
> > Max
> >
> >
> > --- In fitnesse@..., Rick Mugridge <rick@> wrote:
> > >
> > > Hi Max,
> > >
> > > OK, thanks.
> > >
> > > The code concerned is ListTree.parse(), a static method. It's quite
> > > simple. If you wanted to fix this to handle the general case, along with
> > > storytests/specifications, I'd be happy to include it in FitLibrary for
> > > Java.
> > >
> > > Cheers, Rick
> > >
> > > sch_max wrote:
> > > >  
> > > >
> > > >
> > > >
> > > > Hi Rick,
> > > >
> > > > there is a Wiki-syntax to create lists in a cell.
> > > > It is just like creating nested tables:
> > > >
> > > > !define inner_list ( *Root node
> > > > *Child node
> > > > *Node
> > > > *Node
> > > > )
> > > >
> > > > |A Table|
> > > > |${inner_list}|
> > > >
> > > > The problem is that this creates html code with
> > > > linebreaks/whitespaces. And ListTree/FitNesse seems to not correctly
> > > > parsing this.
> > > >
> > > > Max
> > > >
> > > > --- In fitnesse@... <mailto:fitnesse%40yahoogroups.com>,
> > > > Rick Mugridge <rick@> wrote:
> > > > >
> > > > > It only works with html for lists because, as far as I know, there's no
> > > > > wiki syntax for creating lists within a cell.
> > > > >
> > > > > Cheers, Rick
> > > > >
> > > >
> > > >
> > >
> >
>



Re: Support of MarkupLists for ListTree

by sch_max :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I think, I found the problem.
The Fitnesse-Wiki creates html-code for sub-lists after the "</li>"-tag. But TreeList expects sub-lists between the "<li>"-tags.
For example, Wiki creates:
<ul><li>Root node</li><ul><li>Child node</li></ul></ul>
but TreeList expects:
<ul><li>Root node<ul><li>Child node</li></ul></li></ul>

I think that isn't so easy to parse in TreeList. Maybe it would be better to change the generated html in Fitnesse-code.

Max


--- In fitnesse@..., "jediwhale" <jediwhale@...> wrote:

>
> Didn't realize you were using .NET, I'll take a look.
>
> Mike
>
> --- In fitnesse@..., "sch_max" <sch_max@> wrote:
> >
> > Hi Rick,
> >
> > I'm using .NET-version of FitLibrary. The ListTree-class doesn't contain a parse()-method. TreeHandler has a method parse(), but isn't static. This method seems to use the Parse-class to parse the HTML code. So, maybe the problem is in Parse-class.
> >
> > Max
> >
> >
> > --- In fitnesse@..., Rick Mugridge <rick@> wrote:
> > >
> > > Hi Max,
> > >
> > > OK, thanks.
> > >
> > > The code concerned is ListTree.parse(), a static method. It's quite
> > > simple. If you wanted to fix this to handle the general case, along with
> > > storytests/specifications, I'd be happy to include it in FitLibrary for
> > > Java.
> > >
> > > Cheers, Rick
> > >
> > > sch_max wrote:
> > > >  
> > > >
> > > >
> > > >
> > > > Hi Rick,
> > > >
> > > > there is a Wiki-syntax to create lists in a cell.
> > > > It is just like creating nested tables:
> > > >
> > > > !define inner_list ( *Root node
> > > > *Child node
> > > > *Node
> > > > *Node
> > > > )
> > > >
> > > > |A Table|
> > > > |${inner_list}|
> > > >
> > > > The problem is that this creates html code with
> > > > linebreaks/whitespaces. And ListTree/FitNesse seems to not correctly
> > > > parsing this.
> > > >
> > > > Max
> > > >
> > > > --- In fitnesse@... <mailto:fitnesse%40yahoogroups.com>,
> > > > Rick Mugridge <rick@> wrote:
> > > > >
> > > > > It only works with html for lists because, as far as I know, there's no
> > > > > wiki syntax for creating lists within a cell.
> > > > >
> > > > > Cheers, Rick
> > > > >
> > > >
> > > >
> > >
> >
>



Re: Re: Support of MarkupLists for ListTree

by ggramlich :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I think,

we should go with the HTML standards and that is the way TreeList expects it.

I have no good link but I just tried in the W3C Validator

http://validator.w3.org/check

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
   <title>nn</title>
</head>
<body>
<ul><li>a</li><ul><li>b</li></ul></ul>
</body>

Gives Line 7, Column 18: document type does not allow element "UL"
here; assuming missing "LI" start-tag

Whereas

<ul><li>a<ul><li>b</li></ul></li></ul>

validates.

So - yes the HTML generated by FitNesse should be changed.

Gregor


2009/11/3 sch_max <sch_max@...>

>
>
>
> I think, I found the problem.
> The Fitnesse-Wiki creates html-code for sub-lists after the "</li>"-tag. But TreeList expects sub-lists between the "<li>"-tags.
> For example, Wiki creates:
> <ul><li>Root node</li><ul><li>Child node</li></ul></ul>
> but TreeList expects:
> <ul><li>Root node<ul><li>Child node</li></ul></li></ul>
>
> I think that isn't so easy to parse in TreeList. Maybe it would be better to change the generated html in Fitnesse-code.
>
> Max
>
> --- In fitnesse@..., "jediwhale" <jediwhale@...> wrote:
> >
> > Didn't realize you were using .NET, I'll take a look.
> >
> > Mike
> >
> > --- In fitnesse@..., "sch_max" <sch_max@> wrote:
> > >
> > > Hi Rick,
> > >
> > > I'm using .NET-version of FitLibrary. The ListTree-class doesn't contain a parse()-method. TreeHandler has a method parse(), but isn't static. This method seems to use the Parse-class to parse the HTML code. So, maybe the problem is in Parse-class.
> > >
> > > Max
> > >
> > >
> > > --- In fitnesse@..., Rick Mugridge <rick@> wrote:
> > > >
> > > > Hi Max,
> > > >
> > > > OK, thanks.
> > > >
> > > > The code concerned is ListTree.parse(), a static method. It's quite
> > > > simple. If you wanted to fix this to handle the general case, along with
> > > > storytests/specifications, I'd be happy to include it in FitLibrary for
> > > > Java.
> > > >
> > > > Cheers, Rick
> > > >
> > > > sch_max wrote:
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > Hi Rick,
> > > > >
> > > > > there is a Wiki-syntax to create lists in a cell.
> > > > > It is just like creating nested tables:
> > > > >
> > > > > !define inner_list ( *Root node
> > > > > *Child node
> > > > > *Node
> > > > > *Node
> > > > > )
> > > > >
> > > > > |A Table|
> > > > > |${inner_list}|
> > > > >
> > > > > The problem is that this creates html code with
> > > > > linebreaks/whitespaces. And ListTree/FitNesse seems to not correctly
> > > > > parsing this.
> > > > >
> > > > > Max
> > > > >
> > > > > --- In fitnesse@... <mailto:fitnesse%40yahoogroups.com>,
> > > > > Rick Mugridge <rick@> wrote:
> > > > > >
> > > > > > It only works with html for lists because, as far as I know, there's no
> > > > > > wiki syntax for creating lists within a cell.
> > > > > >
> > > > > > Cheers, Rick
> > > > > >
> > > > >
> > > > >
> > > >
> > >
> >
>
>

Re: Support of MarkupLists for ListTree

by sch_max :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message






Today, I spent some hours to look at the fitnesse-code and tried to change it. It wasn't as easy as I thought it would be. I added some lines in the ListWidget-Class in package fitnesse.wikitext.widgets. Now my buildList-method looks like this:
...
else {
  String listItemContent = match.group(3).trim();
  // the trim is real important.  It removes the starting
  // spaces that could cause the item to be recognized
  // as another list.
  Pattern mypat = Pattern.compile("((?s).*)([\\r\\n]+"+match.group(1)+"[\\*\\d])");
  Matcher mymatch = mypat.matcher(text.substring(match.end()));
  String mytest;
  if(mymatch.find())
  {
    mytest = mymatch.group(1).replaceAll("(^[\\r\\n]+)|([ \\r\\n]+$)", "");
  }else
  {
    mytest = text.substring(match.end()).replaceAll("(^[\\r\\n]+)|( [\\r\\n]+$)", "");
  }

  ListItemWidget item = new ListItemWidget(this, listItemContent, this.level + 1);

  if(!mytest.isEmpty())
  {
    new ListWidget(item, mytest);
  }

  return buildList(text.substring(match.end()+mytest.length()));
...

I know the code is ugly (especially the variable names :-)). I don't have much experience in parsing code. But it works. It creates the right HTML-Code. Just the tabs in front of the tags (to format HTML-Code) aren't correct anymore.
The idea was to get the text until the next item on same layer and add this text as a new ListWidget to the ListItemWidget.
It would be great if some of you could improve/test/comment this code.

Thanks
Max

--- In fitnesse@..., Gregor Gramlich <gramlich@...> wrote:

>
> I think,
>
> we should go with the HTML standards and that is the way TreeList expects it.
>
> I have no good link but I just tried in the W3C Validator
>
> http://validator.w3.org/check
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd">
> <html>
> <head>
>    <title>nn</title>
> </head>
> <body>
> <ul><li>a</li><ul><li>b</li></ul></ul>
> </body>
>
> Gives Line 7, Column 18: document type does not allow element "UL"
> here; assuming missing "LI" start-tag
>
> Whereas
>
> <ul><li>a<ul><li>b</li></ul></li></ul>
>
> validates.
>
> So - yes the HTML generated by FitNesse should be changed.
>
> Gregor
>


Re: Support of MarkupLists for ListTree

by sch_max :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



I overworked my code a little bit and also did some refactoring. The part looks now like this:
...
        // Find next tree item on same layer to get the child items.
        Pattern nextPattern = Pattern.compile("([\\r\\n]+"+match.group(1)+"[\\*\\d])");
       
        Matcher nextMatch = nextPattern.matcher(text.substring(match.end()));
       
        String childItems;
        if(nextMatch.find())
        {
          // If there is a item on same layer, get text until this position -> child items.
          childItems = text.substring(match.end()).substring(0, nextMatch.start()).replaceAll("(^[\\r\\n]+)|([ \\r\\n]+$)", ""); //mymatch.group(1).replaceAll("(^[\\r\\n]+)|([ \\r\\n]+$)", "");
        }else
        {
          // If there is no item on same layer, the text to the end are child items.
          childItems = text.substring(match.end()).replaceAll("(^[\\r\\n]+)|( [\\r\\n]+$)", "");
        }
       
        ListItemWidget item = new ListItemWidget(this, listItemContent, this.level + 1);
       
        // Add the child items as a new list to the list item.
        if(!childItems.isEmpty())
        {
          new ListWidget(item, childItems);
        }
       
        // Go on with building list after all child items.
        return buildList(text.substring(match.end()+childItems.length()));
...


--- In fitnesse@..., "sch_max" <sch_max@...> wrote:

>
>
>
>
>
>
> Today, I spent some hours to look at the fitnesse-code and tried to change it. It wasn't as easy as I thought it would be. I added some lines in the ListWidget-Class in package fitnesse.wikitext.widgets. Now my buildList-method looks like this:
> ...
> else {
>   String listItemContent = match.group(3).trim();
>   // the trim is real important.  It removes the starting
>   // spaces that could cause the item to be recognized
>   // as another list.
>   Pattern mypat = Pattern.compile("((?s).*)([\\r\\n]+"+match.group(1)+"[\\*\\d])");
>   Matcher mymatch = mypat.matcher(text.substring(match.end()));
>   String mytest;
>   if(mymatch.find())
>   {
>     mytest = mymatch.group(1).replaceAll("(^[\\r\\n]+)|([ \\r\\n]+$)", "");
>   }else
>   {
>     mytest = text.substring(match.end()).replaceAll("(^[\\r\\n]+)|( [\\r\\n]+$)", "");
>   }
>
>   ListItemWidget item = new ListItemWidget(this, listItemContent, this.level + 1);
>
>   if(!mytest.isEmpty())
>   {
>     new ListWidget(item, mytest);
>   }
>
>   return buildList(text.substring(match.end()+mytest.length()));
> ...
>
> I know the code is ugly (especially the variable names :-)). I don't have much experience in parsing code. But it works. It creates the right HTML-Code. Just the tabs in front of the tags (to format HTML-Code) aren't correct anymore.
> The idea was to get the text until the next item on same layer and add this text as a new ListWidget to the ListItemWidget.
> It would be great if some of you could improve/test/comment this code.
>
> Thanks
> Max
>
> --- In fitnesse@..., Gregor Gramlich <gramlich@> wrote:
> >
> > I think,
> >
> > we should go with the HTML standards and that is the way TreeList expects it.
> >
> > I have no good link but I just tried in the W3C Validator
> >
> > http://validator.w3.org/check
> >
> > <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> > "http://www.w3.org/TR/html4/loose.dtd">
> > <html>
> > <head>
> >    <title>nn</title>
> > </head>
> > <body>
> > <ul><li>a</li><ul><li>b</li></ul></ul>
> > </body>
> >
> > Gives Line 7, Column 18: document type does not allow element "UL"
> > here; assuming missing "LI" start-tag
> >
> > Whereas
> >
> > <ul><li>a<ul><li>b</li></ul></li></ul>
> >
> > validates.
> >
> > So - yes the HTML generated by FitNesse should be changed.
> >
> > Gregor
> >
>