mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-01 02:05:00 +00:00
feat: Automatically parse transcript section to generate markers
This commit is contained in:
parent
813a201b6a
commit
41219a7d85
2 changed files with 37 additions and 4 deletions
|
@ -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,
|
||||
|
|
|
@ -14,10 +14,6 @@ layout: minimal
|
|||
|
||||
<script src="/assets/asciinema/asciinema-player.min.js"></script>
|
||||
<script>
|
||||
var markers = [
|
||||
[1.0, "Hello!"],
|
||||
[5.0, "Hello, this is a test. This is only a test."],
|
||||
];
|
||||
{% include recording.js %}
|
||||
</script>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue