Anonymous avatar Anonymous committed d3ad427

Extract _calc_info_field_processed_content .

Comments (0)

Files changed (1)

XML-Grammar-Fortune/module/lib/XML/Grammar/Fortune/ToText.pm

     return $info_fields_order_map{$field->localname()} || (-1);
 }
 
+sub _calc_info_field_processed_content
+{
+    my $self = shift;
+    my $field_node = shift;
+
+    my $content = $field_node->textContent();
+
+    # Squash whitespace including newlines into a single space.
+    $content =~ s{\s+}{ }g;
+
+    # Remove leading and trailing space - it is not desirable here
+    # because we want it formatted consistently.
+    $content =~ s{\A\s+}{};
+    $content =~ s{\s+\z}{};
+
+    return $content;
+}
+
 sub _render_info
 {
     my ($self) = @_;
     {
         my $name = $field_node->localname();
 
-        my $value = $field_node->textContent();
-
-        # Squash whitespace including newlines into a single space.
-        $value =~ s{\s+}{ }g;
-        
-        # Remove leading and trailing space - it is not desirable here
-        # because we want it formatted consistently.
-        $value =~ s{\A\s+}{};
-        $value =~ s{\s+\z}{};
+        my $value = $self->_calc_info_field_processed_content($field_node);
 
         if ($name eq "author")
         {
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.