Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
msaroufim committed Nov 26, 2024
1 parent e4121f9 commit 205e518
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

# Popcorn

Coming soon
[Our plan](https://gist.github.com/msaroufim/087c2a358c505e287a926e6a27b3e3b0)

More coming soon...
39 changes: 37 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,54 @@
margin: 0 auto;
line-height: 1.5;
}
a {
color: #0366d6;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<div id="content"></div>
<script>
function convertMarkdownLinks(text) {
// Match both [text](url) and bare URLs
const linkRegex = /\[([^\]]+)\]\(([^)]+)\)|(\b(?:https?:\/\/|www\.)[^\s<]+[\w/#])/g;
let lastIndex = 0;
let result = '';

let match;
while ((match = linkRegex.exec(text)) !== null) {
// Add text before the match
result += text.slice(lastIndex, match.index);

if (match[1] && match[2]) {
// [text](url) format
result += `<a href="${match[2]}" target="_blank">[${match[1]}](${match[2]})</a>`;
} else {
// bare URL format
const url = match[3];
result += `<a href="${url}" target="_blank">${url}</a>`;
}

lastIndex = linkRegex.lastIndex;
}

// Add remaining text
result += text.slice(lastIndex);
return result;
}

fetch('README.md')
.then(response => response.text())
.then(text => {
document.getElementById('content').textContent = text;
document.getElementById('content').innerHTML = convertMarkdownLinks(text);
})
.catch(err => {
document.getElementById('content').textContent = 'Error loading markdown: ' + err;
});
</script>
</body>
</html>
</html>

0 comments on commit 205e518

Please sign in to comment.