staticdash 2025.21__py3-none-any.whl → 2025.23__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.
staticdash/dashboard.py CHANGED
@@ -56,7 +56,7 @@ class Page(AbstractPage):
56
56
  self.page_width = page_width
57
57
  self.marking = marking # Page-specific marking
58
58
  self.children = []
59
- self.add_header(title, level=1)
59
+ # self.add_header(title, level=1)
60
60
 
61
61
  def add_subpage(self, page):
62
62
  self.children.append(page)
@@ -395,16 +395,42 @@ class Dashboard:
395
395
  self._outline_idx = 0
396
396
  super().__init__(*args, **kwargs)
397
397
 
398
+
398
399
  def afterFlowable(self, flowable):
399
- if hasattr(flowable, 'style') and hasattr(flowable, 'getPlainText'):
400
+ from reportlab.platypus import Paragraph
401
+ if isinstance(flowable, Paragraph):
400
402
  style_name = flowable.style.name
401
- if style_name.startswith("Heading"):
402
- level = int(style_name.replace("Heading", ""))
403
- text = flowable.getPlainText().strip()
404
- key = f"heading_{uuid.uuid4().hex}"
403
+ if style_name.startswith('Heading'):
404
+ try:
405
+ level = int(style_name.replace("Heading", ""))
406
+ except ValueError:
407
+ return # Not a valid heading style
408
+
409
+ # Convert to outline level (0 = H1, 1 = H2, etc.)
410
+ outline_level = level - 1
411
+
412
+ # Clamp max to 2 for PDF outline safety
413
+ outline_level = max(0, min(outline_level, 2))
414
+
415
+ # Prevent skipping levels: ensure intermediates exist
416
+ # Track previous levels (add this as a class attribute if needed)
417
+ if not hasattr(self, "_last_outline_level"):
418
+ self._last_outline_level = -1
419
+
420
+ if outline_level > self._last_outline_level + 1:
421
+ outline_level = self._last_outline_level + 1 # prevent jump
422
+
423
+ self._last_outline_level = outline_level
424
+
425
+ text = flowable.getPlainText()
426
+ key = 'heading_%s' % self.seq.nextf('heading')
405
427
  self.canv.bookmarkPage(key)
406
- self.canv.addOutlineEntry(text, key, level=level-1, closed=False)
407
- self.notify('TOCEntry', (level, text, self.page))
428
+ self.canv.addOutlineEntry(text, key, level=outline_level, closed=False)
429
+
430
+
431
+ self.notify('TOCEntry', (outline_level, text, self.page))
432
+
433
+
408
434
 
409
435
  def add_marking(canvas, doc, marking):
410
436
  if marking:
@@ -441,10 +467,18 @@ class Dashboard:
441
467
  story.append(PageBreak())
442
468
 
443
469
  def render_page(page, level=0, sec_prefix=[]):
470
+ heading_style = styles['Heading1'] if level == 0 else styles['Heading2']
471
+
472
+ # Only add the page.title as a real heading if it's a top-level page
473
+ # if level == 0:
474
+ # story.append(Paragraph(page.title, heading_style))
475
+ # story.append(Spacer(1, 12))
476
+
444
477
  heading_style = styles['Heading1'] if level == 0 else styles['Heading2']
445
478
  story.append(Paragraph(page.title, heading_style))
446
479
  story.append(Spacer(1, 12))
447
480
 
481
+
448
482
  for kind, content, _ in page.elements:
449
483
  if kind == "text":
450
484
  story.append(Paragraph(content, normal_style))
@@ -452,7 +486,8 @@ class Dashboard:
452
486
 
453
487
  elif kind == "header":
454
488
  text, lvl = content
455
- style = styles['Heading{}'.format(min(lvl + 1, 4))]
489
+ safe_lvl = max(1, min(lvl + 1, 4)) # Clamp to Heading1–Heading4
490
+ style = styles[f'Heading{safe_lvl}']
456
491
  story.append(Paragraph(text, style))
457
492
  story.append(Spacer(1, 8))
458
493
 
@@ -516,15 +551,18 @@ class Dashboard:
516
551
  elif kind == "minipage":
517
552
  render_page(content, level=level + 1, sec_prefix=sec_prefix)
518
553
 
519
- for child in getattr(page, "children", []):
554
+ for child in page.children:
520
555
  story.append(PageBreak())
521
556
  render_page(child, level=level + 1, sec_prefix=sec_prefix + [1])
522
557
 
558
+
523
559
  story.append(PageBreak())
524
560
 
525
561
  for page in self.pages:
526
562
  render_page(page)
527
563
 
564
+
565
+
528
566
  doc = MyDocTemplate(
529
567
  output_path,
530
568
  pagesize=page_size,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: staticdash
3
- Version: 2025.21
3
+ Version: 2025.23
4
4
  Summary: A lightweight static HTML dashboard generator with Plotly and pandas support.
5
5
  Author-email: Brian Day <brian.day1@gmail.com>
6
6
  License: CC0-1.0
@@ -0,0 +1,8 @@
1
+ staticdash/__init__.py,sha256=UN_-h8wFGfTPHYjnEb7N9CsxqXo-DQVo0cmREOtvRXE,244
2
+ staticdash/dashboard.py,sha256=pC1GI1lZ_8odSBItiZ2uJeeYKjlKLL67pNQlbMCuQNM,27296
3
+ staticdash/assets/css/style.css,sha256=RVqNdwBsaDv8izdOQjGmUZ4NROWF8uZhiq8DTNvUB1M,5962
4
+ staticdash/assets/js/script.js,sha256=7xBRlz_19wybbNVwAcfuKNXtDEojGB4EB0Yj4klsoTA,6998
5
+ staticdash-2025.23.dist-info/METADATA,sha256=zEz5tHigr_-tG10s_BFjPoaGvL1t8Umawj9Ajk-F3ww,1960
6
+ staticdash-2025.23.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
+ staticdash-2025.23.dist-info/top_level.txt,sha256=3MzZU6SptkUkjcHV1cvPji0H4aRzPphLHnpStgGEcxM,11
8
+ staticdash-2025.23.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- staticdash/__init__.py,sha256=UN_-h8wFGfTPHYjnEb7N9CsxqXo-DQVo0cmREOtvRXE,244
2
- staticdash/dashboard.py,sha256=b6xx5-zdSCzbcaBTe52flSXrK_cdAo3vzGfIeR2MsNQ,25950
3
- staticdash/assets/css/style.css,sha256=RVqNdwBsaDv8izdOQjGmUZ4NROWF8uZhiq8DTNvUB1M,5962
4
- staticdash/assets/js/script.js,sha256=7xBRlz_19wybbNVwAcfuKNXtDEojGB4EB0Yj4klsoTA,6998
5
- staticdash-2025.21.dist-info/METADATA,sha256=qKcshAi26kzpuRYjYpUppRTQW3F3ZsoKiKjHxIAbfWQ,1960
6
- staticdash-2025.21.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
- staticdash-2025.21.dist-info/top_level.txt,sha256=3MzZU6SptkUkjcHV1cvPji0H4aRzPphLHnpStgGEcxM,11
8
- staticdash-2025.21.dist-info/RECORD,,