Sorry, I’m encountering another issue with my plugin that communicates with an API.
I retrieve various information that I insert into a topic related to a search. My problem is that I receive my YouTube video link, but it is inserted as raw text and not as a onebox as I would like. I’ve tried several methods, but I’m stuck here, and naturally, I want it to be compatible with both Markdown and rich text.
Here is part of my code concerning video management:
const videoTags = Array.from(xmlDoc.getElementsByTagName("video"));
const frenchVideos = videoTags.filter(v => (v.getAttribute("language") || "").toLowerCase().includes("french"));
if (frenchVideos.length > 0) {
message += `<hr><h3>🎥 Rule Videos (FR) :</h3>`;
frenchVideos.slice(0, 3).forEach(video => {
let vTitle = (video.getAttribute("title") || "Video")
.replace(/How to play/gi, "Comment jouer")
.replace(/Rules/gi, "Règles");
const vLink = video.getAttribute("link");
// 1. The title in its paragraph
message += `<p><strong>📖 ${vTitle}</strong></p>`;
// 2. AN EMPTY PARAGRAPH (Simulates pressing 'Enter')
message += `<p></p>`;
// 3. THE LINK ONLY (This is the "single line" requested by Discourse)
// We do not put an <a> tag, we leave the raw text of the URL
message += `<p>${vLink}</p>`;
// 4. ANOTHER EMPTY PARAGRAPH (Simulates a second 'Enter')
message += `<p></p>`;
});
if (frenchVideos.length > 3) {
message += `<p><i>(+ ${frenchVideos.length - 3} other videos on BGG)</i></p>`;
}
}
And here is the result
