Shlomi Fish avatar Shlomi Fish committed 9773cfd

Add the passthrough elements.

Comments (0)

Files changed (3)

perl/modules/XML-Grammar-Fiction/lib/XML/Grammar/Fiction/FromProto.pm

 
 use Data::Dumper;
 
+my %lookup = (map { $_ => 1 } qw( li ol ul ));
+
+sub _is_passthrough_elem
+{
+    my ($self, $name) = @_;
+
+    return exists($lookup{$name});
+}
+
 sub _output_tag
 {
     my ($self, $args) = @_;
 }
 
 
-sub _handle_elem_of_name_li
-{
-    my ($self, $elem) = @_;
-
-    $self->_output_tag_with_childs(
-        {
-            start => ['li'],
-            elem => $elem,
-        }
-    );
-
-    return;
-}
-
 sub _handle_elem_of_name_programlisting
 {
     my ($self, $elem) = @_;
     return;
 }
 
-sub _handle_elem_of_name_ol
-{
-    my ($self, $elem) = @_;
-
-    $self->_output_tag_with_childs(
-        {
-            start => ['ol'],
-            elem => $elem,
-        }
-    );
-
-    return;
-}
-
 sub _handle_elem_of_name_span
 {
     my ($self, $elem) = @_;
     return;
 }
 
-sub _handle_elem_of_name_ul
-{
-    my ($self, $elem) = @_;
-
-    $self->_output_tag_with_childs(
-        {
-            start => ['ul'],
-            elem => $elem,
-        }
-    );
-
-    return;
-}
-
 sub _handle_elem_of_name_title
 {
     my ($self, $elem) = @_;

perl/modules/XML-Grammar-Fiction/lib/XML/Grammar/FictionBase/TagsTree2XML.pm

 
 has "_writer" => ('isa' => "XML::Writer", 'is' => "rw");
 
+sub _is_passthrough_elem
+{
+    return;
+}
+
 sub _write_Element_elem
 {
     my ($self, $elem) = @_;
 
+    my $name = $elem->name();
+
     if ($elem->_short_isa("InnerDesc"))
     {
         $self->_output_tag_with_childs(
         );
         return;
     }
+    elsif ($self->_is_passthrough_elem($name))
+    {
+        return
+        $self->_output_tag_with_childs(
+            {
+                start => [$name],
+                elem => $elem,
+            }
+        );
+    }
     else
     {
-        my $method = "_handle_elem_of_name_" . $elem->name();
+        my $method = "_handle_elem_of_name_$name";
 
         $self->$method($elem);
 

perl/modules/XML-Grammar-Fiction/lib/XML/Grammar/Screenplay/FromProto.pm

 
 =cut
 
+
+my %lookup = (map { $_ => 1 } qw( li ol ul ));
+
+sub _is_passthrough_elem
+{
+    my ($self, $name) = @_;
+
+    return exists($lookup{$name});
+}
+
 sub _output_tag
 {
     my ($self, $args) = @_;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.