@hyperbook/markdown 0.21.0 → 0.22.0

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.
package/dist/index.js CHANGED
@@ -73148,7 +73148,7 @@ ${(code4.scripts ? [cdnLibraryUrl, ...code4.scripts] : []).map((src) => `<script
73148
73148
  type: "element",
73149
73149
  tagName: "code-input",
73150
73150
  properties: {
73151
- class: "editor",
73151
+ class: "editor line-numbers",
73152
73152
  language: "javascript"
73153
73153
  },
73154
73154
  children: [
@@ -73334,18 +73334,34 @@ var remarkDirectivePyide_default = (ctx) => () => {
73334
73334
  requestJS(file, ["code-input", "auto-close-brackets.min.js"]);
73335
73335
  requestJS(file, ["code-input", "indent.min.js"]);
73336
73336
  let srcFile = "";
73337
+ let tests = [];
73338
+ let input = "";
73337
73339
  if (src) {
73338
73340
  srcFile = fs3.readFileSync(
73339
73341
  path5.join(ctx.root, "public", String(src)),
73340
73342
  "utf8"
73341
73343
  );
73342
73344
  } else if (node3.children?.length > 0) {
73343
- srcFile = toText2(node3.children);
73345
+ tests = node3.children.filter((c) => c.type === "code").filter((c) => c.meta?.includes("test")).map((c, i) => ({
73346
+ code: c.value,
73347
+ name: `${i}`
73348
+ }));
73349
+ input = toText2(
73350
+ node3.children.find(
73351
+ (c) => c.type === "code" && c.lang === "input"
73352
+ )
73353
+ );
73354
+ srcFile = toText2(
73355
+ node3.children.find(
73356
+ (c) => c.type === "code" && c.lang === "python" && !c.meta?.includes("test")
73357
+ )
73358
+ );
73344
73359
  }
73345
73360
  data.hName = "div";
73346
73361
  data.hProperties = {
73347
73362
  class: "directive-pyide",
73348
- id: id || hash(node3)
73363
+ id: id || hash(node3),
73364
+ "data-tests": Buffer.from(JSON.stringify(tests)).toString("base64")
73349
73365
  };
73350
73366
  data.hChildren = [
73351
73367
  {
@@ -73355,6 +73371,41 @@ var remarkDirectivePyide_default = (ctx) => () => {
73355
73371
  class: "container"
73356
73372
  },
73357
73373
  children: [
73374
+ {
73375
+ type: "element",
73376
+ tagName: "div",
73377
+ properties: {
73378
+ class: "buttons"
73379
+ },
73380
+ children: [
73381
+ {
73382
+ type: "element",
73383
+ tagName: "button",
73384
+ properties: {
73385
+ class: "output-btn active"
73386
+ },
73387
+ children: [
73388
+ {
73389
+ type: "text",
73390
+ value: "Output"
73391
+ }
73392
+ ]
73393
+ },
73394
+ {
73395
+ type: "element",
73396
+ tagName: "button",
73397
+ properties: {
73398
+ class: "input-btn"
73399
+ },
73400
+ children: [
73401
+ {
73402
+ type: "text",
73403
+ value: "Input"
73404
+ }
73405
+ ]
73406
+ }
73407
+ ]
73408
+ },
73358
73409
  {
73359
73410
  type: "element",
73360
73411
  tagName: "pre",
@@ -73362,6 +73413,17 @@ var remarkDirectivePyide_default = (ctx) => () => {
73362
73413
  class: "output"
73363
73414
  },
73364
73415
  children: []
73416
+ },
73417
+ {
73418
+ type: "element",
73419
+ tagName: "code-input",
73420
+ properties: {
73421
+ class: "input hidden"
73422
+ },
73423
+ children: [{
73424
+ type: "raw",
73425
+ value: input || ""
73426
+ }]
73365
73427
  }
73366
73428
  ]
73367
73429
  },
@@ -73374,22 +73436,46 @@ var remarkDirectivePyide_default = (ctx) => () => {
73374
73436
  children: [
73375
73437
  {
73376
73438
  type: "element",
73377
- tagName: "button",
73439
+ tagName: "div",
73378
73440
  properties: {
73379
- class: "run"
73441
+ class: "buttons"
73380
73442
  },
73381
73443
  children: [
73382
73444
  {
73383
- type: "text",
73384
- value: "Run"
73385
- }
73445
+ type: "element",
73446
+ tagName: "button",
73447
+ properties: {
73448
+ class: "run"
73449
+ },
73450
+ children: [
73451
+ {
73452
+ type: "text",
73453
+ value: "Run"
73454
+ }
73455
+ ]
73456
+ },
73457
+ ...tests.length > 0 ? [
73458
+ {
73459
+ type: "element",
73460
+ tagName: "button",
73461
+ properties: {
73462
+ class: "test"
73463
+ },
73464
+ children: [
73465
+ {
73466
+ type: "text",
73467
+ value: "Test"
73468
+ }
73469
+ ]
73470
+ }
73471
+ ] : []
73386
73472
  ]
73387
73473
  },
73388
73474
  {
73389
73475
  type: "element",
73390
73476
  tagName: "code-input",
73391
73477
  properties: {
73392
- class: "editor",
73478
+ class: "editor line-numbers",
73393
73479
  language: "python",
73394
73480
  template: "pyide-highlighted"
73395
73481
  },