Making WordPress.org

Changeset 11244


Ignore:
Timestamp:
09/20/2021 11:53:48 PM (5 years ago)
Author:
dd32
Message:

Trac: GitHub: When importing GitHub code blocks, support/import the code format specifier.

This might not solve all of the differences, but should at least import it as a code block rather than as a broken block.

See #5855.

File:
1 edited

Legend:

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

    r10728 r11244  
    329329
    330330        // Convert Code blocks.
    331         $desc = preg_replace( '#```(.+?)```#s', '{{{$1}}}', $desc );
     331        $desc = preg_replace_callback(
     332                '#```(?P<format>[a-z]+$)?(?P<code>.+?)```#sm',
     333                function( $m ) {
     334                        return
     335                                "{{{\n" .
     336                                ( $m['format'] ? "#!" . trim( $m['format'] ) . "\n" : '' ) .
     337                                trim( $m['code'] ) . "\n" .
     338                                "}}}\n";
     339                },
     340                $desc
     341        );
    332342
    333343        // Convert Images (Must happen prior to Links, as the only difference is a preceeding !)
Note: See TracChangeset for help on using the changeset viewer.