This question about Developing extensions (plugins skins etc.): Task filed

Display XML Source Code in table.

i,

I want to display xml source code in a table with the EditTablePlugin enabled. In our previus installation (with Twiki Cairo) whe were displaying the source code by using <pre> tags. But now if we use <pre> tag, the source code is not displayed correctly. We tried using <verbatim> , but show it all on one line.

Is there any way to paint correctly the source xml code using the plugin?

thanks in advance

-- AlbertoPazos - 18 Jan 2012

Could you provide an example table? And if you have a screenshot or a capture of the browser source? That would help better define the issue.

-- GeorgeClark - 19 Jan 2012

Yes, I have attached a document with the screenshots. Thanks

-- AlbertoPazos - 20 Jan 2012

It shows it all on one line in verbatim, because in your example you have put the code all on one line!

Try formatting the XML code using newlines within a verbatim block; it should display correctly, and the table should work too. For example:
<Here>
  <Is>
     <Some valid="XML" />
  </Is>
</Here>
-- CrawfordCurrie - 20 Jan 2012

I entered the code in several lines but the editor modified it putting it into just one....

-- AlbertoPazos - 20 Jan 2012

and if i use the verbatim tag It shows the code in one line and includes br tags. You can see that in the attackment.

-- AlbertoPazos - 23 Jan 2012

Alberto raised Tasks.Item11471 against EditTablePlugin.

-- PaulHarvey - 25 Jan 2012

Finally, I solved the issue by adding a function in the source code.

In this function we replaced characters

"<" , ">"

by their counterparts

"&lt;" , "&gt" 

, and with a regular expression we detected html tags and made the inverse change replacing
"&lt;" , "&gt" 

by their counterparts
"<" , ">"

This function parseHTMLinTextArea was created in the file EditTablePlugin / Core.pm

=begin TML

Inserting source code in html area
=cut

sub parseHTMLinTextArea {
     my ($text) = @_;
     return $text if $text eq '';

     $text = " $text ";
     $text =~ s/^ [[:space:]]+/ /;    # remove extra spaces
     $text =~ s/ [[:space:]]+$/ /;
     $text =~ s/</&lt;/g;
     $text =~ s/>/&gt;/g;

            my $patron    = qr(
         (                                       # i2: html tag
         &lt;(/*                                 # start of tag (optional closing tag)
         (?:$HTML_TAGS) (               # any of the html tags
         [[:space:]]+                  # any space
         .*?                                     # anything before the end of tag
         /* | /* ))&gt;                          # end of tag (optional closing tag)
         )                                       # /i2
         )x;

  $text =~ s/$patron//g;

     return $text;
}

This function was called from "handleTableRow" when the action is saved:

...
elsif ($doSave) {
                $cell = addSpaceToBothSides($cell);
                $cell = parseHTMLinTextArea($cell);
            # Item5217 Avoid that deleting content of cell creates unwanted span
                $cell = ' ' if $cell eq '';

                $text .= "$cell\|";
            }
...

-- AlbertoPazos - 20 Feb 2013

I have attached the Core.pm modified

-- AlbertoPazos - 20 Feb 2013
 

QuestionForm edit

Subject Developing extensions (plugins skins etc.)
Extension EditTablePlugin
Version Foswiki 1.1.3
Status Task filed
Related Topics Tasks.Item11471
I Attachment Action Size Date Who Comment
Core.pmpm Core.pm manage 65 K 20 Feb 2013 - 11:23 AlbertoPazos Source code of Core.pm modified.
example.pdfpdf example.pdf manage 98 K 20 Jan 2012 - 07:58 AlbertoPazos Example Displaying XML Source Code in table
Topic revision: r8 - 20 Feb 2013, AlbertoPazos
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy