pxt-core 13.0.3 → 13.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -131,6 +131,7 @@ declare namespace pxt.docs {
131
131
  parse?: (src: string, options?: any) => string;
132
132
  }
133
133
  export function htmlQuote(s: string): string;
134
+ export function normalizeStaticMarkdown(markdown: string): string;
134
135
  export function html2Quote(s: string): string;
135
136
  export interface BreadcrumbEntry {
136
137
  name: string;
@@ -509,6 +509,35 @@ var pxt;
509
509
  return s;
510
510
  }
511
511
  docs.htmlQuote = htmlQuote;
512
+ function normalizeStaticMarkdown(markdown) {
513
+ const lines = markdown.split(/\r?\n/);
514
+ let codeFenceMarker = "";
515
+ for (let i = 0; i < lines.length; i++) {
516
+ const fenceMatch = /^ {0,3}(`{3,}|~{3,})(.*)$/.exec(lines[i]);
517
+ if (fenceMatch) {
518
+ const marker = fenceMatch[1];
519
+ const trailingText = fenceMatch[2];
520
+ const closesCodeFence = !!codeFenceMarker
521
+ && marker[0] === codeFenceMarker[0]
522
+ && marker.length >= codeFenceMarker.length
523
+ && !trailingText.trim();
524
+ if (closesCodeFence) {
525
+ codeFenceMarker = "";
526
+ }
527
+ else if (!codeFenceMarker) {
528
+ codeFenceMarker = marker;
529
+ }
530
+ continue;
531
+ }
532
+ if (!codeFenceMarker && /^ {0,3}<br\s*\/?>\s*$/i.test(lines[i])) {
533
+ // Marked treats a standalone break as inline content, which can extend a
534
+ // preceding table or keep the following Markdown in the same paragraph.
535
+ lines[i] = "\n<p><br/></p>\n";
536
+ }
537
+ }
538
+ return lines.join("\n");
539
+ }
540
+ docs.normalizeStaticMarkdown = normalizeStaticMarkdown;
512
541
  // the input already should be HTML-quoted but we want to make sure, and also quote quotes
513
542
  function html2Quote(s) {
514
543
  if (!s)
package/built/cli.js CHANGED
@@ -41,7 +41,7 @@ pxt.docs.requireDOMSanitizer = () => {
41
41
  const existing = baseAllowedAttrs[tag] || [];
42
42
  return Array.from(new Set([...existing, "class", ...otherAttributes]));
43
43
  };
44
- const options = Object.assign(Object.assign({}, defaults), { allowedTags: [...allowedTags, "img"], allowedAttributes: Object.assign(Object.assign({}, baseAllowedAttrs), { code: mergeClassAttribute("code"), pre: mergeClassAttribute("pre"), div: mergeClassAttribute("div", "data-youtube", "title") }) });
44
+ const options = Object.assign(Object.assign({}, defaults), { allowedTags: [...allowedTags, "img"], allowedAttributes: Object.assign(Object.assign({}, baseAllowedAttrs), { code: mergeClassAttribute("code"), pre: mergeClassAttribute("pre"), div: mergeClassAttribute("div", "data-youtube", "title"), img: mergeClassAttribute("img") }) });
45
45
  return (html) => sanitizeHtml(html, options);
46
46
  };
47
47
  let forceCloudBuild = process.env["KS_FORCE_CLOUD"] !== "no";
@@ -2653,7 +2653,7 @@ function renderDocs(builtPackaged, localDir) {
2653
2653
  nodeutil.writeFileSync(outputFile, patchedMd, { encoding: "utf8" });
2654
2654
  html = pxt.docs.renderMarkdown({
2655
2655
  template: docsTemplate,
2656
- markdown: patchedMd,
2656
+ markdown: pxt.docs.normalizeStaticMarkdown(patchedMd),
2657
2657
  theme: pxt.appTarget.appTheme,
2658
2658
  filepath: path.join("docs", pathUnderDocs),
2659
2659
  });
package/built/pxt.js CHANGED
@@ -106820,6 +106820,35 @@ var pxt;
106820
106820
  return s;
106821
106821
  }
106822
106822
  docs.htmlQuote = htmlQuote;
106823
+ function normalizeStaticMarkdown(markdown) {
106824
+ const lines = markdown.split(/\r?\n/);
106825
+ let codeFenceMarker = "";
106826
+ for (let i = 0; i < lines.length; i++) {
106827
+ const fenceMatch = /^ {0,3}(`{3,}|~{3,})(.*)$/.exec(lines[i]);
106828
+ if (fenceMatch) {
106829
+ const marker = fenceMatch[1];
106830
+ const trailingText = fenceMatch[2];
106831
+ const closesCodeFence = !!codeFenceMarker
106832
+ && marker[0] === codeFenceMarker[0]
106833
+ && marker.length >= codeFenceMarker.length
106834
+ && !trailingText.trim();
106835
+ if (closesCodeFence) {
106836
+ codeFenceMarker = "";
106837
+ }
106838
+ else if (!codeFenceMarker) {
106839
+ codeFenceMarker = marker;
106840
+ }
106841
+ continue;
106842
+ }
106843
+ if (!codeFenceMarker && /^ {0,3}<br\s*\/?>\s*$/i.test(lines[i])) {
106844
+ // Marked treats a standalone break as inline content, which can extend a
106845
+ // preceding table or keep the following Markdown in the same paragraph.
106846
+ lines[i] = "\n<p><br/></p>\n";
106847
+ }
106848
+ }
106849
+ return lines.join("\n");
106850
+ }
106851
+ docs.normalizeStaticMarkdown = normalizeStaticMarkdown;
106823
106852
  // the input already should be HTML-quoted but we want to make sure, and also quote quotes
106824
106853
  function html2Quote(s) {
106825
106854
  if (!s)
@@ -164202,7 +164231,7 @@ pxt.docs.requireDOMSanitizer = () => {
164202
164231
  const existing = baseAllowedAttrs[tag] || [];
164203
164232
  return Array.from(new Set([...existing, "class", ...otherAttributes]));
164204
164233
  };
164205
- const options = Object.assign(Object.assign({}, defaults), { allowedTags: [...allowedTags, "img"], allowedAttributes: Object.assign(Object.assign({}, baseAllowedAttrs), { code: mergeClassAttribute("code"), pre: mergeClassAttribute("pre"), div: mergeClassAttribute("div", "data-youtube", "title") }) });
164234
+ const options = Object.assign(Object.assign({}, defaults), { allowedTags: [...allowedTags, "img"], allowedAttributes: Object.assign(Object.assign({}, baseAllowedAttrs), { code: mergeClassAttribute("code"), pre: mergeClassAttribute("pre"), div: mergeClassAttribute("div", "data-youtube", "title"), img: mergeClassAttribute("img") }) });
164206
164235
  return (html) => sanitizeHtml(html, options);
164207
164236
  };
164208
164237
  let forceCloudBuild = process.env["KS_FORCE_CLOUD"] !== "no";
@@ -166814,7 +166843,7 @@ function renderDocs(builtPackaged, localDir) {
166814
166843
  nodeutil.writeFileSync(outputFile, patchedMd, { encoding: "utf8" });
166815
166844
  html = pxt.docs.renderMarkdown({
166816
166845
  template: docsTemplate,
166817
- markdown: patchedMd,
166846
+ markdown: pxt.docs.normalizeStaticMarkdown(patchedMd),
166818
166847
  theme: pxt.appTarget.appTheme,
166819
166848
  filepath: path.join("docs", pathUnderDocs),
166820
166849
  });
@@ -80,6 +80,7 @@ export declare class FieldColorNumber extends FieldGridDropdown implements Field
80
80
  * @returns Height and width.
81
81
  */
82
82
  getSize(): Blockly.utils.Size;
83
+ getScaledBBox(): Blockly.utils.Rect;
83
84
  /**
84
85
  * Updates the colour of the block to reflect whether this is a full
85
86
  * block field or not.
package/built/pxtlib.d.ts CHANGED
@@ -1267,6 +1267,7 @@ declare namespace pxt.docs {
1267
1267
  parse?: (src: string, options?: any) => string;
1268
1268
  }
1269
1269
  export function htmlQuote(s: string): string;
1270
+ export function normalizeStaticMarkdown(markdown: string): string;
1270
1271
  export function html2Quote(s: string): string;
1271
1272
  export interface BreadcrumbEntry {
1272
1273
  name: string;
package/built/pxtlib.js CHANGED
@@ -9099,6 +9099,35 @@ var pxt;
9099
9099
  return s;
9100
9100
  }
9101
9101
  docs.htmlQuote = htmlQuote;
9102
+ function normalizeStaticMarkdown(markdown) {
9103
+ const lines = markdown.split(/\r?\n/);
9104
+ let codeFenceMarker = "";
9105
+ for (let i = 0; i < lines.length; i++) {
9106
+ const fenceMatch = /^ {0,3}(`{3,}|~{3,})(.*)$/.exec(lines[i]);
9107
+ if (fenceMatch) {
9108
+ const marker = fenceMatch[1];
9109
+ const trailingText = fenceMatch[2];
9110
+ const closesCodeFence = !!codeFenceMarker
9111
+ && marker[0] === codeFenceMarker[0]
9112
+ && marker.length >= codeFenceMarker.length
9113
+ && !trailingText.trim();
9114
+ if (closesCodeFence) {
9115
+ codeFenceMarker = "";
9116
+ }
9117
+ else if (!codeFenceMarker) {
9118
+ codeFenceMarker = marker;
9119
+ }
9120
+ continue;
9121
+ }
9122
+ if (!codeFenceMarker && /^ {0,3}<br\s*\/?>\s*$/i.test(lines[i])) {
9123
+ // Marked treats a standalone break as inline content, which can extend a
9124
+ // preceding table or keep the following Markdown in the same paragraph.
9125
+ lines[i] = "\n<p><br/></p>\n";
9126
+ }
9127
+ }
9128
+ return lines.join("\n");
9129
+ }
9130
+ docs.normalizeStaticMarkdown = normalizeStaticMarkdown;
9102
9131
  // the input already should be HTML-quoted but we want to make sure, and also quote quotes
9103
9132
  function html2Quote(s) {
9104
9133
  if (!s)