Skip to content

Commit 13063e4

Browse files
committed
Merge remote-tracking branch 'origin/master' into i18n
2 parents 9bb8b96 + 8753b91 commit 13063e4

File tree

20 files changed

+577
-385
lines changed

20 files changed

+577
-385
lines changed

src/compute/compute/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"cookie": "^0.5.0",
4343
"debug": "^4.3.2",
4444
"websocketfs": "^0.17.2",
45-
"ws": "^8.13.0"
45+
"ws": "^8.18.0"
4646
},
4747
"homepage": "https://github.com/sagemathinc/cocalc/tree/master/src/packages/compute",
4848
"repository": {

src/compute/pnpm-lock.yaml

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/packages/backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"@cocalc/util": "workspace:*",
3535
"@types/debug": "^4.1.12",
3636
"awaiting": "^3.0.0",
37-
"chokidar": "^3.5.3",
37+
"chokidar": "^3.6.0",
3838
"debug": "^4.3.2",
3939
"fs-extra": "^11.2.0",
4040
"lodash": "^4.17.21",

src/packages/frontend/editors/slate/elements/details/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
*/
55

66
import { CSSProperties } from "react";
7+
import { load } from "cheerio";
8+
79
import { register, SlateElement } from "../register";
810
import { dict } from "@cocalc/util/misc";
9-
import $ from "cheerio";
1011

1112
export const STYLE = {
1213
cursor: "pointer",
@@ -42,6 +43,7 @@ register({
4243

4344
toSlate: ({ children, state, token }) => {
4445
const attrs = dict(state.attrs as any);
46+
const $ = load("");
4547
const x = $(token.content);
4648
const summary = x.find("summary").text().trim();
4749
return {

src/packages/frontend/editors/slate/elements/image/index.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
* License: MS-RSL – see LICENSE.md for details
44
*/
55

6-
import { register, SlateElement } from "../register";
7-
import { dict } from "@cocalc/util/misc";
8-
import $ from "cheerio";
6+
import { load } from "cheerio";
7+
98
import { useFileContext } from "@cocalc/frontend/lib/file-context";
9+
import { dict } from "@cocalc/util/misc";
10+
import { register, SlateElement } from "../register";
1011

1112
export interface Image extends SlateElement {
1213
type: "image";
@@ -28,6 +29,7 @@ export function toSlate({ type, children, token }) {
2829
// token.content will be a string like this:
2930
// <img src='https://wstein.org/bella-and-william.jpg' width=200px title='my pup' />
3031
// easiest way to parse this is with jquery style api but via cheerio (not by hand).
32+
const $ = load("");
3133
const elt = $(token.content);
3234
const node = {
3335
type: "image",

src/packages/frontend/editors/slate/markdown-to-slate/util.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import $ from "cheerio";
1+
import { load } from "cheerio";
22

33
export function getAttrs(content: string, attrs: string[]): [string, string][] {
4+
const $ = load("");
45
const x = $(content);
56
const v: [string, string][] = [];
67
for (const attr of attrs) {

src/packages/frontend/misc/process-links/string.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ share server.
1414
TODO: this is NOT used anywhere yet.
1515
*/
1616

17-
import $ from "cheerio";
17+
import { load } from "cheerio";
18+
1819
import processLinks from "./generic";
1920

2021
interface Options {
@@ -25,8 +26,9 @@ interface Options {
2526

2627
export default function processLinksString(
2728
html: string,
28-
opts: Options
29+
opts: Options,
2930
): string {
31+
const $ = load("");
3032
const elt = $(`<div>${html}</div>`);
3133
processLinks(elt, { ...opts, $ });
3234
return elt.html() ?? "";

src/packages/frontend/package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"bootstrap": "=3.4.1",
7474
"bootstrap-colorpicker": "^2.5.3",
7575
"cat-names": "^3.1.0",
76-
"cheerio": "^1.0.0-rc.10",
76+
"cheerio": "1.0.0-rc.10",
7777
"codemirror": "^5.65.16",
7878
"color-map": "^2.0.6",
7979
"copy-to-clipboard": "^3.0.8",
@@ -151,7 +151,6 @@
151151
"react-redux": "^8.0.5",
152152
"react-timeago": "^7.2.0",
153153
"react-virtuoso": "^4.9.0",
154-
"requirejs": "^2.3.6",
155154
"resize-observer-polyfill": "^1.5.1",
156155
"sha1": "^1.1.1",
157156
"shallowequal": "^1.1.0",
@@ -187,9 +186,9 @@
187186
"@types/md5": "^2.2.0",
188187
"@types/mocha": "^10.0.0",
189188
"@types/pica": "^5.1.3",
190-
"@types/react": "^18.0.26",
189+
"@types/react": "^18.0.28",
191190
"@types/react-bootstrap": "^0.32.21",
192-
"@types/react-dom": "^18.0.10",
191+
"@types/react-dom": "^18.0.11",
193192
"@types/react-image-crop": "^8.1.3",
194193
"@types/react-redux": "^7.1.25",
195194
"coffeescript": "^2.5.1",

src/packages/hub/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"@types/express": "^4.17.13",
2424
"@types/formidable": "^3.4.5",
2525
"@types/primus": "^7.3.6",
26-
"@types/react": "^18.0.26",
26+
"@types/react": "^18.0.28",
2727
"@types/uuid": "^8.3.1",
2828
"async": "^1.5.2",
2929
"awaiting": "^3.0.0",
@@ -70,14 +70,14 @@
7070
"validator": "^13.6.0",
7171
"webpack-dev-middleware": "^6.1.2",
7272
"webpack-hot-middleware": "^2.25.4",
73-
"ws": "^8.13.0"
73+
"ws": "^8.18.0"
7474
},
7575
"devDependenicesNotes": "For license and size reasons, we make @cocalc/crm a dev dependency so it is NOT installed unless explicitly installed as a separate step.",
7676
"devDependencies": {
7777
"@types/http-proxy": "^1.17.9",
7878
"@types/node": "^18.16.14",
7979
"@types/passport": "^1.0.9",
80-
"@types/react-dom": "^18.0.10",
80+
"@types/react-dom": "^18.0.11",
8181
"coffee-coverage": "^3.0.1",
8282
"coffeescript": "^2.5.1",
8383
"expect": "^26.6.2",

src/packages/jupyter/redux/actions.ts

Lines changed: 4 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import {
4040
import { SyncDB } from "@cocalc/sync/editor/db/sync";
4141
import type { Client } from "@cocalc/sync/client/types";
4242
import { once } from "@cocalc/util/async-utils";
43+
import latexEnvs from "@cocalc/util/latex-envs";
4344

4445
const { close, required, defaults } = misc;
4546

@@ -2729,6 +2730,8 @@ export abstract class JupyterActions extends Actions<JupyterStoreState> {
27292730
};
27302731

27312732
processRenderedMarkdown = ({ value, id }: { value: string; id: string }) => {
2733+
value = latexEnvs(value);
2734+
27322735
const labelRegExp = /\s*\\label\{.*?\}\s*/g;
27332736
if (this.labels == null) {
27342737
const labels = (this.labels = {});
@@ -2778,94 +2781,10 @@ export abstract class JupyterActions extends Actions<JupyterStoreState> {
27782781
return `[${tag}](#id=${id})`;
27792782
});
27802783

2781-
const figures = transformFigures(noRefs);
2782-
2783-
return figures;
2784+
return noRefs;
27842785
};
27852786
}
27862787

2787-
/*
2788-
Turn this:
2789-
2790-
---
2791-
2792-
...
2793-
2794-
\begin{figure}
2795-
\centering
2796-
\centerline{\includegraphics[width=WIDTH]{URL}}
2797-
\caption{CAPTION}
2798-
\end{figure}
2799-
2800-
...
2801-
2802-
---
2803-
2804-
into this:
2805-
2806-
---
2807-
2808-
...
2809-
2810-
<div style="text-align:center"><img src="URL" style="width:WIDTH"/></div>
2811-
\begin{equation}
2812-
\text{CAPTION}
2813-
\end{equation}
2814-
2815-
...
2816-
2817-
---
2818-
2819-
There can be lots of figures.
2820-
2821-
*/
2822-
2823-
function transformFigures(content: string): string {
2824-
while (true) {
2825-
const i = content.indexOf("\\begin{figure}");
2826-
if (i == -1) {
2827-
return content;
2828-
}
2829-
const j = content.indexOf("\\end{figure}");
2830-
if (j == -1) {
2831-
return content;
2832-
}
2833-
const k = content.indexOf("\\includegraphics");
2834-
if (k == -1) {
2835-
return content;
2836-
}
2837-
const c = content.indexOf("\\caption{");
2838-
if (c == -1) {
2839-
return content;
2840-
}
2841-
const c2 = content.lastIndexOf("}", j);
2842-
if (c2 == -1) {
2843-
return content;
2844-
}
2845-
2846-
const w = content.indexOf("width=");
2847-
const w2 = content.indexOf("{", k);
2848-
const w3 = content.indexOf("}", k);
2849-
if (w2 == -1 || w3 == -1) {
2850-
return content;
2851-
}
2852-
let style = "";
2853-
if (w != -1) {
2854-
style = `width:${content.slice(w + "width=".length, w2 - 1)}`;
2855-
}
2856-
const url = content.slice(w2 + 1, w3);
2857-
const caption = content.slice(c + "\\caption{".length, c2);
2858-
2859-
const md = `\n\n<div style="text-align:center"><img src="${url}" style="${style}"/></div>\n\n
2860-
\\begin{equation}
2861-
\\text{${caption}}
2862-
\\end{equation}\n\n`;
2863-
2864-
content =
2865-
content.slice(0, i) + md + content.slice(j + "\\end{figure}".length);
2866-
}
2867-
}
2868-
28692788
function extractLabel(content: string): string {
28702789
const i = content.indexOf("{");
28712790
const j = content.lastIndexOf("}");

0 commit comments

Comments
 (0)