Changeset 3276141
- Timestamp:
- 04/17/2025 06:24:09 PM (10 months ago)
- Location:
- podcast-seo/trunk
- Files:
-
- 2 edited
-
podcast-seo.php (modified) (5 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
podcast-seo/trunk/podcast-seo.php
r3275485 r3276141 5 5 Description: Converts podcast interview transcripts into styled HTML with speech bubbles and avatar support. 6 6 Author: Helmut Naber 7 Version: 1.0. 37 Version: 1.0.4 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 197 197 } 198 198 199 // Replace the backslashes in the highlighted transcript text 200 $highlighted_text = str_replace("\\\\\\", "", $highlighted_text); // Entferne \\\' aus dem Transkript 201 199 202 echo '<div style="border:1px solid #ccc; padding:10px; max-width:900px; background:#fefefe; margin-top:20px;">' . nl2br(html_entity_decode($highlighted_text)) . '</div>'; 200 203 echo '<style>' . $css_styles . '</style>'; … … 241 244 // Function to generate HTML for the transcript 242 245 function audiotyped_podcastseo_generate_html($transcript, $host_name, $guest_name, $host_img, $guest_img) { 243 if (empty($transcript)) {244 return ''; // Return empty if transcript is empty245 }246 247 246 $css = "<style> 248 247 .transcriptHost .transcriptAvatar { background-image: url('$host_img'); } … … 256 255 $transcript = str_replace('[GAST_SPEAKER_TEMP]', $guest_name . ':', $transcript); 257 256 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 "; 261 261 $current_speaker = ''; 262 262 $current_class = ''; … … 265 265 foreach ($lines as $line) { 266 266 $line = trim($line); 267 268 // Match speakers and their dialogue269 267 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)271 268 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 "; 273 278 } 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 transcript278 $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 dialogue285 279 $current_speaker = trim($matches[1]); 286 280 $current_class = ($current_speaker == $host_name) ? 'transcriptHost' : 'transcriptGuest'; 287 281 $buffer = $matches[2]; 288 289 282 } else { 290 // Accumulate the text for the current speaker291 283 if ($current_speaker !== '') { 292 $buffer .= "\n" . $line; 284 $buffer .= " 285 " . $line; 293 286 } else { 294 $html .= "<p>$line</p>"; // Handle non-dialogue text 287 $html .= " <p>$line</p> 288 "; 295 289 } 296 290 } 297 291 } 298 292 299 // After the loop, close the last speaker's block300 293 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 "; 309 307 $html = str_replace('[NO_SPEAKER_COLON]', ':', $html); 310 311 308 return $html; 312 309 } 313 314 -
podcast-seo/trunk/readme.txt
r3275485 r3276141 5 5 Tested up to: 6.7 6 6 Requires PHP: 7.2 7 Stable tag: 1.0. 37 Stable tag: 1.0.4 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 51 51 * Optimized transcript in keyword analysis 52 52 53 = 1.0.4 = 54 * Further transcript optimization in keyword analysis
Note: See TracChangeset
for help on using the changeset viewer.