vesta-web 1.2.1__py3-none-any.whl → 1.2.3__py3-none-any.whl

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.
@@ -0,0 +1,9 @@
1
+ export const fillTemplateLitteral = (template, vars = {}) => {
2
+ const handler = new Function('vars', [
3
+ 'const tagged = ( ' + Object.keys(vars).join(', ') + ' ) =>',
4
+ '`' + template + '`',
5
+ 'return tagged(...Object.values(vars))'
6
+ ].join('\n'));
7
+ const res = handler(vars)
8
+ return res;
9
+ };
@@ -1,5 +1,7 @@
1
1
  // This in absolutely no spec, it comes exclusively from my deranged mind
2
2
 
3
+ import {fillTemplateLitteral} from "../framework/utils.mjs";
4
+
3
5
  export class Markdown {
4
6
  constructor() {
5
7
  }
@@ -374,19 +376,18 @@ export class Markdown {
374
376
  return tokenList;
375
377
  }
376
378
 
377
- render(tokens) {
379
+ render(tokens, renderingSet = this.HTML_equiv) {
378
380
  let result = ""
379
381
  for(let token_id = 0; token_id < tokens.length; token_id+=1){
380
- const render = this.renderToken(tokens[token_id], token_id, tokens)
382
+ const render = this.renderToken(tokens[token_id], token_id, tokens, renderingSet)
381
383
  token_id = render[1]
382
384
  result = result.concat(render[0])
383
385
  }
384
386
  return result;
385
387
  }
386
388
 
387
- renderToken(token, token_id, tokens){
389
+ renderToken(token, token_id, tokens, renderingSet = this.HTML_equiv){
388
390
  // console.log("render token",token,token_id,tokens)
389
- const old_id = token_id
390
391
  let content = ""
391
392
  switch(token.type) {
392
393
  case ">":
@@ -398,7 +399,7 @@ export class Markdown {
398
399
  content = content.concat(render[0])
399
400
  }
400
401
  token.content = content
401
- return [fillTemplate(this.HTML_equiv[token.type], token), token_id]
402
+ return [fillTemplateLitteral(renderingSet[token.type], token), token_id]
402
403
  case "-#":
403
404
  let smallContent = token.content
404
405
  while (token_id + 1 < tokens.length && tokens[token_id + 1].type !== "endline") {
@@ -408,7 +409,7 @@ export class Markdown {
408
409
  smallContent = smallContent.concat(render[0])
409
410
  }
410
411
  token.content = smallContent
411
- return [fillTemplate(this.HTML_equiv[token.type], token), token_id]
412
+ return [fillTemplateLitteral(renderingSet[token.type], token), token_id]
412
413
  case "*":
413
414
  // this is suboptimal because we're looking for same size closing
414
415
  // smth like *** a ** b * will not work as intended
@@ -418,34 +419,35 @@ export class Markdown {
418
419
  token.content = content
419
420
  if (token.props.level % 2) {
420
421
  if (token.props.level === 3) {
421
- token.content = fillTemplate(this.HTML_equiv["**"], token)
422
+ token.content = fillTemplateLitteral(renderingSet["**"], token)
422
423
  }
423
- return [fillTemplate(this.HTML_equiv["*"], token), token_id]
424
+ return [fillTemplateLitteral(renderingSet["*"], token), token_id]
424
425
  } else {
425
- return [fillTemplate(this.HTML_equiv["**"], token), token_id]
426
+ return [fillTemplateLitteral(renderingSet["**"], token), token_id]
426
427
  }
427
428
  }
428
429
  const render = this.renderToken(tokens[token_id], token_id, tokens)
429
430
  token_id = render[1]
430
431
  content = content.concat(render[0])
431
432
  }
432
- token.content = "*".repeat(token.props.level)
433
- // should be optimized, because we just drop a part of the render here
434
- return [fillTemplate(this.HTML_equiv["text"], token), old_id]
433
+ // No closing * found, render as text and continue from current position
434
+ token.content = "*".repeat(token.props.level).concat(content)
435
+ return [fillTemplateLitteral(renderingSet["text"], token), token_id]
435
436
  case "~~":
436
437
  case "||":
437
438
  while (token_id + 1 < tokens.length) {
438
439
  token_id += 1
439
440
  if(tokens[token_id].type === token.type){
440
441
  token.content = content
441
- return [fillTemplate(this.HTML_equiv[token.type], token), token_id]
442
+ return [fillTemplateLitteral(renderingSet[token.type], token), token_id]
442
443
  }
443
444
  const render = this.renderToken(tokens[token_id], token_id, tokens)
444
445
  token_id = render[1]
445
446
  content = content.concat(render[0])
446
447
  }
447
- token.content = token.type
448
- return [fillTemplate(this.HTML_equiv["text"], token), old_id]
448
+ // No closing pair found, render as text and continue from current position
449
+ token.content = token.type.concat(content)
450
+ return [fillTemplateLitteral(renderingSet["text"], token), token_id]
449
451
  case "[":
450
452
  while (token_id + 1 < tokens.length) {
451
453
  token_id += 1
@@ -459,7 +461,7 @@ export class Markdown {
459
461
  tokens[token_id+3].type === ")"){
460
462
  token.content = content
461
463
  token.props.link = tokens[token_id+2].content
462
- return [fillTemplate(this.HTML_equiv["link"], token), token_id+3]
464
+ return [fillTemplateLitteral(renderingSet["link"], token), token_id+3]
463
465
  }else{
464
466
  break
465
467
  }
@@ -468,14 +470,15 @@ export class Markdown {
468
470
  token_id = render[1]
469
471
  content = content.concat(render[0])
470
472
  }
471
- token.content = token.type
472
- return [fillTemplate(this.HTML_equiv["text"], token), old_id]
473
+ // No closing ] or proper link syntax found, render as text and continue from current position
474
+ token.content = token.type.concat(content)
475
+ return [fillTemplateLitteral(renderingSet["text"], token), token_id]
473
476
  case "color":
474
477
  while (token_id + 1 < tokens.length) {
475
478
  token_id += 1
476
479
  if(tokens[token_id].type === "/>"){
477
480
  token.content = content
478
- return [fillTemplate(this.HTML_equiv[token.type], token), token_id]
481
+ return [fillTemplateLitteral(renderingSet[token.type], token), token_id]
479
482
  }
480
483
  const render = this.renderToken(tokens[token_id], token_id, tokens)
481
484
  token_id = render[1]
@@ -483,9 +486,9 @@ export class Markdown {
483
486
  }
484
487
  token.type="text"
485
488
  token.content = "<$"+token.props?.color
486
- return [fillTemplate(this.HTML_equiv[token.type], token), token_id]
489
+ return [fillTemplateLitteral(renderingSet[token.type], token), token_id]
487
490
  default:
488
- return [fillTemplate(this.HTML_equiv[token.type], token), token_id]
491
+ return [fillTemplateLitteral(renderingSet[token.type], token), token_id]
489
492
  }
490
493
  }
491
494
  }
@@ -497,13 +500,3 @@ class Token{
497
500
  this.props={}
498
501
  }
499
502
  }
500
-
501
- const fillTemplate = (template, vars = {}) => {
502
- const handler = new Function('vars', [
503
- 'const tagged = ( ' + Object.keys(vars).join(', ') + ' ) =>',
504
- '`' + template + '`',
505
- 'return tagged(...Object.values(vars))'
506
- ].join('\n'));
507
- const res = handler(vars)
508
- return res;
509
- };
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vesta-web
3
- Version: 1.2.1
3
+ Version: 1.2.3
4
4
  Summary: An extensive web framework adding every feature needed for Carbonlab
5
5
  Project-URL: Homepage, https://gitlab.com/Louciole/vesta
6
6
  Project-URL: Issues, https://gitlab.com/Louciole/vesta/-/issues
@@ -31,6 +31,7 @@ vesta/emptyProject/static/style.css,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG
31
31
  vesta/emptyProject/static/framework/global.mjs,sha256=Zr3F9E_DfyYzxqYfdeSBCTezf42VNUqkWR1zB3Py_Tw,124
32
32
  vesta/emptyProject/static/framework/navigation.mjs,sha256=EMI-bTJDp0XqTWxHQkZKyT-u5Q9cKA6QVkF4hJyKrRY,11119
33
33
  vesta/emptyProject/static/framework/templating.mjs,sha256=v0w-JtkOoSgHWAy7_A24jZzvBQ99f5FBii2RrykUAkU,3319
34
+ vesta/emptyProject/static/framework/utils.mjs,sha256=S6Ed6BoFY-OyS4jumQ3BMbyTBRXlIcgEriwz0Pv3VoM,321
34
35
  vesta/emptyProject/static/framework/vesta.mjs,sha256=0YrLyt4US22TIknO3OFWeOQuWimIWLBwMFCoKzBEHX4,5459
35
36
  vesta/emptyProject/static/framework/websockets.mjs,sha256=Ck0bdEj0mVU3PHZ1MtPPz2He47OYl2WmRxqE3NSKh-c,1349
36
37
  vesta/emptyProject/static/home/auth.css,sha256=Vw-wFyQJm1ydDVBHPdKWp4dvzrfFRry4-kgScVFleOM,1924
@@ -38,7 +39,7 @@ vesta/emptyProject/static/home/auth.html,sha256=sz-CC-B4NUqth8aSQqwQCvq2V46AnhaI
38
39
  vesta/emptyProject/static/home/auth.js,sha256=txMlUqr4A-15Czf4MYwaED35XXcaHI_zrc4SpnjItJU,4622
39
40
  vesta/emptyProject/static/home/reset.html,sha256=EcXfX2Vil3NrYhDvEptrIhW9QV9X_kDy59-TK2S_P4w,2655
40
41
  vesta/emptyProject/static/home/verif.html,sha256=tUw96l0FZ5-AXuE8s-7v1nM632onErq5swgCU53zP-s,2906
41
- vesta/emptyProject/static/markdown/markdown.mjs,sha256=eqSV-uzI1PcZS6eev8pqXv2UocDv2NHyFG6v91b-KAo,24105
42
+ vesta/emptyProject/static/markdown/markdown.mjs,sha256=s51IMYqoDznrcs23ByjL1PhtWlCMZj3kvxQAuhE30w8,24229
42
43
  vesta/emptyProject/static/markdown/utils.mjs,sha256=PGxhsJfub_lt-LEZVqYt8lKEp_RTRVGXuNhGmWxto-k,614
43
44
  vesta/emptyProject/static/translations/en.mjs,sha256=ouMluPVTgB4Q5vmb7zGE6YGTH4URruog5_a52sBDYNE,22
44
45
  vesta/emptyProject/static/translations/fr.mjs,sha256=ouMluPVTgB4Q5vmb7zGE6YGTH4URruog5_a52sBDYNE,22
@@ -55,8 +56,8 @@ vesta/scripts/initDB.py,sha256=4o_J3IK0vcil2oHvk_qmtqLSlWABcRPFBC3M61-oSF8,1842
55
56
  vesta/scripts/install.py,sha256=GvH_HHx5aU5_54RQ1_2vz4DaLCh42AHfUKy-m0q21vY,2125
56
57
  vesta/scripts/testsRun.py,sha256=bXJImdexKQUDW8CR8F9VIKTrgkd7QfnvHQPENEV4x38,2463
57
58
  vesta/scripts/utils.py,sha256=PR2XPonaoZEbegzV3QX1EHfyq67sU-cbDEUexCuJp9Q,6013
58
- vesta_web-1.2.1.dist-info/METADATA,sha256=wQBkA51DKVeEg3DQPWEqLFZ0D1JqXcvkC3mhekIbxlQ,1584
59
- vesta_web-1.2.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
60
- vesta_web-1.2.1.dist-info/entry_points.txt,sha256=MHMrWJwtkb4FmNz0CTpxZzwQ3LTqndXBh8YBPDfXlW4,49
61
- vesta_web-1.2.1.dist-info/licenses/LICENSE.md,sha256=zoPFEFUUoSgosmDBK5fGTWGRHHBaSVuuJT2ZQIYXuIk,177
62
- vesta_web-1.2.1.dist-info/RECORD,,
59
+ vesta_web-1.2.3.dist-info/METADATA,sha256=R_ENQZRuZmkJDpllpVoqnE3KC_ga3-Ol05LjktJxNio,1584
60
+ vesta_web-1.2.3.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
61
+ vesta_web-1.2.3.dist-info/entry_points.txt,sha256=MHMrWJwtkb4FmNz0CTpxZzwQ3LTqndXBh8YBPDfXlW4,49
62
+ vesta_web-1.2.3.dist-info/licenses/LICENSE.md,sha256=zoPFEFUUoSgosmDBK5fGTWGRHHBaSVuuJT2ZQIYXuIk,177
63
+ vesta_web-1.2.3.dist-info/RECORD,,