mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-01 10:14:59 +00:00

# Aider chat conversation:
USER: if the mdurl is a non-raw github gist like this `https://gist.github.com/paul-gauthier/2a4ac695b77f6374c923b0b165a6872b` pull out the h
ash and turn into a raw url like this: `4fd2ac290d
64100e51206fb6874e9ac20644fcd`. Right now it's not including the username (paul-gauthier) portion in the raw url
ASSISTANT: To fix this issue, we need to modify the JavaScript code in the `share/index.md` file. The current code is not correctly forming the raw URL for a non-raw GitHub gist. It's missing the username in the raw URL.
Here is the step-by-step plan:
1. Modify the regular expression to capture the username and the gist hash.
2. Update the raw URL formation to include the captured username.
Here is the *edit block* for the change:
```markdown
share/index.md
<<<<<<< ORIGINAL
var gistRegex = /^https:\/\/gist\.github\.com\/[^\/]+\/([a-f0-9]+)$/;
var match = gistRegex.exec(conv);
if (match) {
// If it is, convert it into a raw URL
conv = 'https://gist.githubusercontent.com/' + match[1] + '/raw';
}
=======
var gistRegex = /^https:\/\/gist\.github\.com\/([^\/]+)\/([a-f0-9]+)$/;
var match = gistRegex.exec(conv);
if (match) {
// If it is, convert it into a raw URL
conv = 'https://gist.githubusercontent.com/' + match[1] + '/' + match[2] + '/raw';
}
>>>>>>> UPDATED
```
This change will correctly form the raw URL for a non-raw GitHub gist by including the username in the URL.
43 lines
1.4 KiB
Markdown
43 lines
1.4 KiB
Markdown
|
|
# Shared aider chat transcript
|
|
|
|
A user has shared the following transcript of a pair programming chat session
|
|
created using <a href="https://aider.chat">aider</a>.
|
|
|
|
<div class="chat-transcript">
|
|
</div>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
|
<script>
|
|
window.onload = function() {
|
|
var urlParams = new URLSearchParams(window.location.search);
|
|
var conv = urlParams.get('mdurl');
|
|
if (!conv) {
|
|
return;
|
|
}
|
|
// Check if the URL is a non-raw GitHub gist
|
|
var gistRegex = /^https:\/\/gist\.github\.com\/([^\/]+)\/([a-f0-9]+)$/;
|
|
var match = gistRegex.exec(conv);
|
|
if (match) {
|
|
// If it is, convert it into a raw URL
|
|
conv = 'https://gist.githubusercontent.com/' + match[1] + '/' + match[2] + '/raw';
|
|
}
|
|
fetch(conv)
|
|
.then(response => response.text())
|
|
.then(markdown => {
|
|
// Ensure every line that starts with '>' ends with exactly 2 spaces
|
|
markdown = markdown.split('\n').map(function(line) {
|
|
if (line.startsWith('>')) {
|
|
return line.trimEnd() + ' ';
|
|
}
|
|
return line;
|
|
}).join('\n');
|
|
var html = marked.parse(markdown);
|
|
var divElement = document.querySelector('.chat-transcript');
|
|
divElement.innerHTML = html;
|
|
})
|
|
.catch(error => {
|
|
console.error('Error fetching markdown:', error);
|
|
});
|
|
}
|
|
</script>
|