Making WordPress.org

Changeset 13119


Ignore:
Timestamp:
01/16/2024 08:22:47 PM (2 years ago)
Author:
ryelle
Message:

Markdown Importer: Generate export after parsing markdown content.

This prevents markdown from being saved in the excerpt, by parsing the content into HTML first, then stripping out the tags.

See https://github.com/WordPress/wporg-developer/pull/467#issuecomment-1885987842.
Fixes https://github.com/WordPress/wporg-developer/issues/465.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-markdown/inc/class-importer.php

    r13090 r13119  
    487487        $markdown = trim( $markdown );
    488488
    489         // Use the first sentence as the excerpt.
    490         $excerpt = '';
    491         if ( preg_match( '/^(.+)/', $markdown, $matches ) ) {
    492             $excerpt = $matches[1];
    493         }
    494 
    495489        // Transform to HTML and save the post
    496490        $parser = new WPCom_GHF_Markdown_Parser();
     
    499493
    500494        $html = apply_filters( 'wporg_markdown_after_transform', $html, $this->get_post_type() );
     495
     496        // Use the first line as the excerpt, but first strip any HTML.
     497        $excerpt = '';
     498        if ( preg_match( '/^(.+)/', wp_strip_all_tags( $html ), $matches ) ) {
     499            $excerpt = $matches[1];
     500        }
    501501
    502502        add_filter( 'wp_kses_allowed_html', [ $this, 'wp_kses_allow_links' ], 10, 2 );
Note: See TracChangeset for help on using the changeset viewer.