Skip to content

Commit 8e4569c

Browse files
authored
fix render of youtube links and images in docs pages (#11105)
1 parent 3a52f5c commit 8e4569c

3 files changed

Lines changed: 26 additions & 1 deletion

File tree

.vscode/launch.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,29 @@
219219
"sourceMaps": false,
220220
"outFiles": []
221221
},
222+
{
223+
"name": "pxt serve (core)",
224+
"type": "node",
225+
"request": "launch",
226+
"program": "${workspaceRoot}/built/pxt.js",
227+
"stopOnEntry": false,
228+
"args": [
229+
"serve",
230+
"--rebundle",
231+
"--noauth"
232+
],
233+
"cwd": "${workspaceRoot}",
234+
"runtimeExecutable": null,
235+
"runtimeArgs": [
236+
"--nolazy"
237+
],
238+
"env": {
239+
"NODE_ENV": "development"
240+
},
241+
"console": "integratedTerminal",
242+
"sourceMaps": false,
243+
"outFiles": []
244+
},
222245
{
223246
"name": "pxt serve (bedrock)",
224247
"type": "node",

cli/cli.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ pxt.docs.requireDOMSanitizer = () => {
4141
const sanitizeHtml = require("sanitize-html");
4242
const defaults = sanitizeHtml.defaults || {};
4343
const baseAllowedAttrs = defaults.allowedAttributes || {};
44+
const allowedTags = defaults.allowedTags || [];
4445

4546
const mergeClassAttribute = (tag: string, ...otherAttributes: string[]) => {
4647
const existing: string[] = baseAllowedAttrs[tag] || [];
@@ -49,6 +50,7 @@ pxt.docs.requireDOMSanitizer = () => {
4950

5051
const options = {
5152
...defaults,
53+
allowedTags: [...allowedTags, "img"],
5254
allowedAttributes: {
5355
...baseAllowedAttrs,
5456
code: mergeClassAttribute("code"),

pxtlib/docsrender.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ ${opts.repo.name.replace(/^pxt-/, '')}=github:${opts.repo.fullName}#${opts.repo.
728728
return r;
729729
}
730730

731-
html = html.replace(/<h(\d)[^>]+>\s*([~@])?\s*(.*?)<\/h\d>/g, (full: string, lvl: string, tp: string | undefined, body: string) => {
731+
html = html.replace(/<h(\d)[^>]*>\s*([~@])?\s*(.*?)<\/h\d>/g, (full: string, lvl: string, tp: string | undefined, body: string) => {
732732
let m = /^(\w+)\s+(.*)/.exec(body)
733733
let cmd = m ? m[1] : body
734734
let args = m ? m[2] : ""

0 commit comments

Comments
 (0)