Making WordPress.org

Ticket #1810: 1810.diff

File 1810.diff, 1.5 KB (added by obenland, 9 years ago)
  • readme/class-parser.php

     
    334334                        unset( $this->sections['screenshots'] );
    335335                }
    336336
     337                // Display FAQs as a definition list.
     338                if ( isset( $this->sections['faq'] ) ) {
     339                        $lines      = explode( "\n", $this->sections['faq'] );
     340                        $definition = false;
     341
     342                        $this->sections['faq'] = "<dl>\n";
     343                        while ( ( $line = array_shift( $lines ) ) !== null ) {
     344                                $trimmed = trim( $line );
     345                                if ( empty( $trimmed ) ) {
     346                                        continue;
     347                                }
     348
     349                                if ( 0 === strpos( $trimmed, '<h4>' ) ) {
     350                                        if ( $definition ) {
     351                                                $this->sections['faq'] .= "</dd>\n";
     352                                                $definition             = false;
     353                                        }
     354
     355                                        $this->sections['faq'] .= '<dt>' . $this->sanitize_text( strip_tags( $line ) ) . "</dt>\n";
     356                                        continue;
     357                                }
     358
     359                                if ( ! $definition ) {
     360                                        $this->sections['faq'] .= '<dd>' . $line;
     361                                        $definition             = true;
     362                                        continue;
     363                                }
     364
     365                                $this->sections['faq'] .= "\n" . $line;
     366                        }
     367
     368                        $this->sections['faq'] .= "</dd>\n</dl>";
     369                }
     370
    337371                // Filter the HTML.
    338372                $this->sections = array_map( array( $this, 'filter_text' ), $this->sections );
    339373
     
    413447                        'strong'     => true,
    414448                        'ul'         => true,
    415449                        'ol'         => true,
     450                        'dl'         => true,
     451                        'dt'         => true,
     452                        'dd'         => true,
    416453                        'li'         => true,
    417454                        'h3'         => true,
    418455                        'h4'         => true,