Plugin Directory

Changeset 3276141


Ignore:
Timestamp:
04/17/2025 06:24:09 PM (10 months ago)
Author:
audiotyped
Message:

Version 1.0.4 - Further transcript optimization in keyword analysis

Location:
podcast-seo/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • podcast-seo/trunk/podcast-seo.php

    r3275485 r3276141  
    55Description: Converts podcast interview transcripts into styled HTML with speech bubbles and avatar support.
    66Author: Helmut Naber
    7 Version: 1.0.3
     7Version: 1.0.4
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    197197        }
    198198
     199        // Replace the backslashes in the highlighted transcript text
     200        $highlighted_text = str_replace("\\\\\\", "", $highlighted_text); // Entferne \\\' aus dem Transkript
     201
    199202        echo '<div style="border:1px solid #ccc; padding:10px; max-width:900px; background:#fefefe; margin-top:20px;">' . nl2br(html_entity_decode($highlighted_text)) . '</div>';
    200203        echo '<style>' . $css_styles . '</style>';
     
    241244// Function to generate HTML for the transcript
    242245function audiotyped_podcastseo_generate_html($transcript, $host_name, $guest_name, $host_img, $guest_img) {
    243     if (empty($transcript)) {
    244         return ''; // Return empty if transcript is empty
    245     }
    246 
    247246    $css = "<style>
    248247.transcriptHost .transcriptAvatar { background-image: url('$host_img'); }
     
    256255    $transcript = str_replace('[GAST_SPEAKER_TEMP]', $guest_name . ':', $transcript);
    257256
    258     $lines = explode("\n", trim($transcript));
    259     $html = "$css<div class='transcript'><ol class='transcriptInterview'>";
    260 
     257    $lines = explode("
     258", trim($transcript));
     259    $html = "$css<div class='transcript'><ol class='transcriptInterview'>
     260";
    261261    $current_speaker = '';
    262262    $current_class = '';
     
    265265    foreach ($lines as $line) {
    266266        $line = trim($line);
    267 
    268         // Match speakers and their dialogue
    269267        if (preg_match('/^(' . preg_quote($host_name, '/') . '|' . preg_quote($guest_name, '/') . '):\s*(.*)$/', $line, $matches)) {
    270             // Add a blank line before the speaker (if it's not the first speaker)
    271268            if ($current_speaker !== '') {
    272                 $html .= "<br>"; // Only add a line break before a new speaker, not after the previous speaker
     269                $buffer = nl2br(trim($buffer));
     270                $html .= "    <li class='$current_class'>
     271";
     272                $html .= "        <div class='transcriptAvatar'></div>
     273";
     274                $html .= "        <div class='transcriptSpeaking'><strong>$current_speaker:</strong><p>$buffer</p></div>
     275";
     276                $html .= "    </li>
     277";
    273278            }
    274 
    275             // Close the previous speaker's block (if any)
    276             if ($current_speaker !== '') {
    277                 $buffer = nl2br(trim($buffer)); // Ensure line breaks are preserved in the transcript
    278                 $html .= "<li class='$current_class'>
    279                             <div class='transcriptAvatar'></div>
    280                             <div class='transcriptSpeaking'><strong>$current_speaker:</strong><p>$buffer</p></div>
    281                           </li>";
    282             }
    283 
    284             // Set up the current speaker and their dialogue
    285279            $current_speaker = trim($matches[1]);
    286280            $current_class = ($current_speaker == $host_name) ? 'transcriptHost' : 'transcriptGuest';
    287281            $buffer = $matches[2];
    288 
    289282        } else {
    290             // Accumulate the text for the current speaker
    291283            if ($current_speaker !== '') {
    292                 $buffer .= "\n" . $line;
     284                $buffer .= "
     285" . $line;
    293286            } else {
    294                 $html .= "<p>$line</p>"; // Handle non-dialogue text
     287                $html .= "        <p>$line</p>
     288";
    295289            }
    296290        }
    297291    }
    298292
    299     // After the loop, close the last speaker's block
    300293    if ($current_speaker !== '') {
    301         $buffer = nl2br(trim($buffer)); // Make sure to preserve line breaks
    302         $html .= "<li class='$current_class'>
    303                     <div class='transcriptAvatar'></div>
    304                     <div class='transcriptSpeaking'><strong>$current_speaker:</strong><p>$buffer</p></div>
    305                   </li>";
    306     }
    307 
    308     $html .= "</ol></div>";
     294        $buffer = nl2br(trim($buffer));
     295        $html .= "    <li class='$current_class'>
     296";
     297        $html .= "        <div class='transcriptAvatar'></div>
     298";
     299        $html .= "        <div class='transcriptSpeaking'><strong>$current_speaker:</strong><p>$buffer</p></div>
     300";
     301        $html .= "    </li>
     302";
     303    }
     304
     305    $html .= "</ol></div>
     306";
    309307    $html = str_replace('[NO_SPEAKER_COLON]', ':', $html);
    310 
    311308    return $html;
    312309}
    313 
    314 
  • podcast-seo/trunk/readme.txt

    r3275485 r3276141  
    55Tested up to: 6.7
    66Requires PHP: 7.2
    7 Stable tag: 1.0.3
     7Stable tag: 1.0.4
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    5151* Optimized transcript in keyword analysis
    5252
     53= 1.0.4 =
     54* Further transcript optimization in keyword analysis
Note: See TracChangeset for help on using the changeset viewer.