Changeset View
Changeset View
Standalone View
Standalone View
assets/src/bundles/webapp/readme-rendering.js
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | function showdownHighlight() { | ||||
}]; | }]; | ||||
} | } | ||||
$(document).ready(async() => { | $(document).ready(async() => { | ||||
const converter = new showdown.Converter({ | const converter = new showdown.Converter({ | ||||
tables: true, | tables: true, | ||||
extensions: [showdownHighlight] | extensions: [showdownHighlight] | ||||
}); | }); | ||||
const url = new URL(window.location.href); | |||||
if (url.searchParams.has('origin_url')) { | |||||
try { | |||||
const originUrl = new URL(url.searchParams.get('origin_url')); | |||||
if (originUrl.hostname === 'github.com') { | |||||
converter.setFlavor('github'); | |||||
} | |||||
} catch (TypeError) {} | |||||
} | |||||
try { | try { | ||||
const response = await fetch(markdownDocUrl); | const response = await fetch(markdownDocUrl); | ||||
handleFetchError(response); | handleFetchError(response); | ||||
const data = await response.text(); | const data = await response.text(); | ||||
$(domElt).addClass('swh-showdown'); | $(domElt).addClass('swh-showdown'); | ||||
$(domElt).html(swh.webapp.filterXSS(converter.makeHtml(data))); | $(domElt).html(swh.webapp.filterXSS(converter.makeHtml(data))); | ||||
} catch (_) { | } catch (_) { | ||||
▲ Show 20 Lines • Show All 56 Lines • Show Last 20 Lines |