markdomansky/WebJEA

Nested link in a formatting span doesn't display correctly

Closed this issue · 4 comments

When placing an A link inside a CSS span the closing is placed incorrectly.

write-host "[[span|csstype|[[a|url|display text]]]]"

renders:
<span class='csstype'><a class='pslink' href='url'>display text</span></a>
when it should be:
<span class='csstype'><a class='pslink' href='url'>display text</a></span>

This is resolved in the next release. I plan to release in the next week or so.

not fixed. Not sure how you are going to fix it without some sort of closing format for spans, img, and As.
With the current regex change in the new release, outputting two links on a line totally breaks.
write-host "[[a|?cmdid=sample1|go to sample1]] [[a|?cmdid=sample2|go to sample2]]"
displays as
go to sample1]] [[a|?cmdid=sample2|go to sample2
because the first [[a matches the last ]] and everything after the second | is looked at as the display text.
Making the regex be lazy solves this particular case but not more complicated nesting. (see #17 (comment) )

While it will be disruptive to all current scripts, i think you will need to go to something like

[[a|url|display|a]]
[[span|cssclasses|content|span]]
[[img|cssclasses|url|img]]

Then you can know what ends an A and what ends a Span. My original problem would be outputed as
write-host "[[span|csstype|[[a|url|display text|a]]|span]]"

The PSWebHelper.vb EncodeOutputTags function could be changed to

        Const rexA1 As String = "\[\[a\|(.+?)\|"
        Const repA1 As String = "<a href='$1'>"
        Const rexA2 As String = "\|a\]\]"
        Const repA2 As String = "</a>"
        Const rexSpan1 As String = "\[\[span\|(.+?)\|"
        Const repSpan1 As String = "<span Class='$1'>"
        Const rexSpan2 As String = "\|span\]\]"
        Const repSpan2 As String = "</span>"
        Const rexImg As String = "\[\[img\|(.*?)\|(.+?)\|img\]\]"
        Const repImg As String = "<img class='$1' src='$2' />"
        input = Regex.Replace(input, rexImg, repImg, rexopt)
        input = Regex.Replace(input, rexA1, repA1, rexopt)
        input = Regex.Replace(input, rexA2, repA2, rexopt)
        input = Regex.Replace(input, rexSpan1, repSpan1, rexopt)
        input = Regex.Replace(input, rexSpan2, repSpan2, rexopt)

I think I've fixed this now. It addresses both nested and multiple tags. If this doesn't work for you, I'll probably revert to the previous non-regex, that was fixed as well.

The new method works but is really slow when working with very large tables built in spans as described in defect (#17 (comment))
One of my tables has 13043 span/a/img tags. It takes 9 seconds to discover all the data and parse it into the correct span table format and output it. It then takes 102 seconds to render that into html and display it.
Just trying to have pretty output of data in tables with links that populate other scripts to edit or delete the data. Without raw html output to build tables ourselves, using nested spans seems to be the option.