mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-02 10:45:00 +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 hash and turn into a raw url like this: `4fd2ac290d
`
ASSISTANT: To implement this change, we need to modify the `share/index.md` file. We will add a condition to check if the `mdurl` parameter is a non-raw GitHub gist URL. If it is, we will extract the gist ID and convert it into a raw URL.
Here is the proposed change:
```markdown
share/index.md
<<<<<<< ORIGINAL
var conv = urlParams.get('mdurl');
if (!conv) {
return;
}
fetch(conv)
=======
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] + '/raw';
}
fetch(conv)
>>>>>>> UPDATED
```
This change adds a regular expression to match non-raw GitHub gist URLs. If the `mdurl` parameter matches this pattern, the gist ID is extracted and used to construct a raw URL. The fetch operation then uses this raw URL instead of the original 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] + '/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>
|