From 41219a7d85cd7744228ccbefc0c45c25ad13bb37 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Fri, 14 Mar 2025 08:27:21 -0700 Subject: [PATCH] feat: Automatically parse transcript section to generate markers --- aider/website/_includes/recording.js | 37 ++++++++++++++++++++++++++++ aider/website/examples/recording.md | 4 --- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/aider/website/_includes/recording.js b/aider/website/_includes/recording.js index 95b76a6ea..3d8c07b5f 100644 --- a/aider/website/_includes/recording.js +++ b/aider/website/_includes/recording.js @@ -1,6 +1,43 @@ document.addEventListener('DOMContentLoaded', function() { + // Parse the transcript section to create markers + function parseTranscript() { + const markers = []; + // Find the Transcript heading + const transcriptHeading = Array.from(document.querySelectorAll('h1')).find(el => el.textContent.trim() === 'Transcript'); + + if (transcriptHeading) { + // Get all list items after the transcript heading + let currentElement = transcriptHeading.nextElementSibling; + + while (currentElement && currentElement.tagName === 'UL') { + const listItems = currentElement.querySelectorAll('li'); + + listItems.forEach(item => { + const text = item.textContent.trim(); + const match = text.match(/(\d+):(\d+)\s+(.*)/); + + if (match) { + const minutes = parseInt(match[1], 10); + const seconds = parseInt(match[2], 10); + const timeInSeconds = minutes * 60 + seconds; + const message = match[3].trim(); + + markers.push([timeInSeconds, message]); + } + }); + + currentElement = currentElement.nextElementSibling; + } + } + + return markers; + } + const url = "https://gist.githubusercontent.com/paul-gauthier/3011ab9455c2d28c0e5a60947202752f/raw/5a5b3dbf68a9c2b22b4954af287efedecdf79d52/tmp.redacted.cast"; + // Parse transcript and create markers + const markers = parseTranscript(); + // Create player with a single call const player = AsciinemaPlayer.create( url, diff --git a/aider/website/examples/recording.md b/aider/website/examples/recording.md index be876fe3e..6a9e25d9f 100644 --- a/aider/website/examples/recording.md +++ b/aider/website/examples/recording.md @@ -14,10 +14,6 @@ layout: minimal