Skip to content

Commit

Permalink
[BUG] twitter widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
Viglino committed Nov 18, 2024
1 parent e8add0c commit 5e27837
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions md/md2html.js
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ md2html.rules = [
// Anchor links
[/\[([a-z,A-Z,0-9,\-,\_]+)\]\(#\)/g, '<a id="$1" class="anchor" href="#$1" tabindex="-1" aria-hidden="true"></a>'],
// Automatic links
[/([^\(])(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=()\u00E0-\u00FC$]*))/g, '$1<a href=\'$2\' target="_blank">$2</a>'],
[/([^\(])(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=()\u00E0-\u00FC$]*))/g, '$1<a href=\'$2\' target="_blank">$2</a>'],
// Mailto
[/([^\(])\bmailto\b\:(\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b)/gi, '$1<a href=\'mailto:$2\'>$2</a>'],

Expand Down Expand Up @@ -610,14 +610,14 @@ md2html.rules = [
'<iframe class="video" frameborder="0" width="300" height="180" style="width:$4px; height:$5px;" src="https://player.vimeo.com/video/$3" allowfullscreen></iframe>'],

// Audio
[/\!(\[([^\[\]]+)?\])?\((https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=\(\)]*)\.[mM][pP]3) ?(\d+)?x?(\d+)?( autoplay)?\)/g,
[/\!(\[([^\[\]]+)?\])?\((https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=\(\)]*)\.[mM][pP]3) ?(\d+)?x?(\d+)?( autoplay)?\)/g,
'<audio controls style="width:$6px; height:$7px;" $8 title="$2"><source src="$3" type="audio/mpeg">Your browser does not support the audio element.</audio>'],
// Video
[/\!(\[([^\[\]]+)?\])?\((https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=\(\)]*)\.[mM][pP]4) ?(\d+)?x?(\d+)?( autoplay)?\)/g,
[/\!(\[([^\[\]]+)?\])?\((https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=\(\)]*)\.[mM][pP]4) ?(\d+)?x?(\d+)?( autoplay)?\)/g,
'<video controls style="width:$6px; height:$7px;" $8 title="$2"><source src="$3" type="video/mp4">Your browser does not support the video tag.</video>'],

// Images
[/!(\[([^[\]]+)?\])?\((https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_+.~#?&/=\u00E0-\u00FC$]*)) ?(\d+)?x?(\d+)?\)/g,
[/!(\[([^[\]]+)?\])?\((https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_+.~#?&/=\u00E0-\u00FC$]*)) ?(\d+)?x?(\d+)?\)/g,
'<img style="width:$6px; height:$7px;" src="$3" title="$2" />'],
// Local images
[/!(\[([^[\]]+)?\])?\((file:\/\/\/([-a-zA-Z0-9@:%_+.~#?&/=]*)) ?(\d+)?x?(\d+)?\)/g,
Expand Down Expand Up @@ -764,6 +764,7 @@ function loadTwitter() {
script.type = "text/javascript";
script.src = "https://platform.twitter.com/widgets.js"
head.appendChild(script);
setTimeout(() => twitterLoaded = true)
}
}
let twitterLoaded = false;
Expand All @@ -781,10 +782,9 @@ md2html.renderWidget = function(element) {
}
if (window.twttr) {
window.twttr.widgets.load(element);
} else if (!twitterLoaded) {
} else if (twitterLoaded) {
console.error('Twitter is not loaded...')
}
twitterLoaded = true;
// Hightlight code
element.querySelectorAll('pre.code code').forEach(block => {
hljs.highlightBlock(block);
Expand Down

0 comments on commit 5e27837

Please sign in to comment.