Making WordPress.org

Changeset 12169


Ignore:
Timestamp:
10/31/2022 07:22:45 AM (20 months ago)
Author:
dd32
Message:

Trac: PRs: Convert GitHub tables to Trac tables.

This format conversion isn't perfect, but should hanel the majority of the bad formatting tables can generate.

See https://meta.trac.wordpress.org/ticket/3937#comment:16
See #6555.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/api.wordpress.org/public_html/dotorg/trac/pr/functions.php

    r11848 r12169  
    391391    $desc = preg_replace( '#\[(.+?)\]\((.+?)\)#', '[$2 $1]', $desc );
    392392
     393    // Convert Tables. This doesn't convert GitHub table headers to Trac headers.
     394    $desc = preg_replace_callback(
     395        '#^[|].+[|]$#m',
     396        function( $m ) {
     397            // Headers such as `| --- |---|`
     398            if ( preg_match( '#^[- |]+$#', $m[0] ) ) {
     399                return '|| ||'; // Empty row.
     400            }
     401
     402            // Replace singular |'s but not double ||'s
     403            return preg_replace( '#(?<![|])[|](?![|])#', '||', $m[0] );
     404        },
     405        $desc
     406    );
     407
    393408    return trim( $desc );
    394409}
Note: See TracChangeset for help on using the changeset viewer.