Quiq/Confluence/Markup.pm

filter: Statementstmt 54.8% 90 / 164 Branchbran 31.3% 32 / 102 Conditioncond 66.6% 8 / 12 MC/DCmcdc 42.8% 3 / 7 Subroutinesub 90.0% 18 / 20 Podpod 100% 13 / 13 totaltotal 51.5% 164 / 318 CC 59 SCAR 38.8
CC
59
Cov
47%
tableOfContents
176.8
code
36.4
fmt
28.7
CRAP 48.2
« Quiq/Database/Api/Dbi/Connection.pm ↑ Summary Quiq/ImagePool/Sequence.pm »
1 # -----------------------------------------------------------------------------
2  
3 =encoding utf8
4  
5 =head1 NAME
6  
7 Quiq::Confluence::Markup - Confluence-Wiki Markup
8  
9 =head1 BASE CLASS
10  
11 L<Quiq::Hash>
12  
13 =head1 DESCRIPTION
14  
15 Ein Objekt der Klasse repräsentiert einen Generator für das
16 Wiki-Markup von Confluence. Die Methoden der Klasse erzeugen
17 dieses Markup, ohne dass man sich um die Details der Syntax
18 kümmern muss.
19  
20 Als Grundlage für die Implementierung dient die
21 Confluence-Dokumentation:
22  
23 =over 2
24  
25 =item *
26  
27 L<Allgemeine Syntax|https://confluence.atlassian.com/doc/confluence-wiki-markup-251003035.html>
28  
29 =item *
30  
31 L<Macros|https://confluence.atlassian.com/doc/macros-139387.html>
32  
33 =back
34  
35 Die Implementierung ist nicht vollständig, sondern wird nach Bedarf
36 erweitert.
37  
38 =cut
39  
40 # -----------------------------------------------------------------------------
41  
42 package Quiq::Confluence::Markup;
43 2 ▶use base qw/Quiq::Hash/;
Subroutine BEGIN: called CC=1 SCAR=0.0
44  
45 2 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
46 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
47 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
48 2 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
49  
50 2 our $VERSION = '1.240';
51  
52 2 ▶use Quiq::Unindent;
Subroutine BEGIN: called CC=1 SCAR=0.0
53  
54 # -----------------------------------------------------------------------------
55  
56 =head1 METHODS
57  
58 =head2 Konstruktor
59  
60 =head3 new() - Instantiiere Markup-Generator
61  
62 =head4 Synopsis
63  
64 $gen = $class->new;
65  
66 =head4 Description
67  
68 Instantiiere einen Confluence Wiki-Markup Generator und liefere
69 eine Referenz auf dieses Objekt zurück.
70  
71 =cut
72  
73 # -----------------------------------------------------------------------------
74  
75 9 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
76 9 my $class = shift;
77 # @_: @keyVal
78  
79 9 my $self = $class->SUPER::new(
80 # z.Zt. keine Attribute
81 );
82 9 $self->set(@_);
83  
84 9 return $self;
85 }
86  
87 # -----------------------------------------------------------------------------
88  
89 =head2 Allgemeine Syntax
90  
91 =head3 link() - Link
92  
93 =head4 Synopsis
94  
95 $markup = $gen->link($url);
96 $markup = $gen->link($url,$text);
97  
98 =head4 Description
99  
100 Confluence-Doku: L<Links|https://confluence.atlassian.com/doc/confluence-wiki-markup-251003035.html#ConfluenceWikiMarkup-Links>
101  
102 Erzeuge den Markup-Text für einen Link und liefere diesen zurück.
103  
104 =head4 Examples
105  
106 =over 2
107  
108 =item *
109  
110 URL:
111  
112 $gen->link('https://confluence.atlassian.com/');
113  
114 erzeugt
115  
116 [https://confluence.atlassian.com/]
117  
118 =item *
119  
120 Text über URL:
121  
122 $gen->link('https://confluence.atlassian.com/','Atlassian');
123  
124 erzeugt
125  
126 [Atlassian|https://confluence.atlassian.com/]
127  
128 =back
129  
130 =cut
131  
132 # -----------------------------------------------------------------------------
133  
134 2 ▶sub link {
Subroutine link: called CC=2 SCAR=6.9
Pod documented
135 2 my ($self,$url,$text) = @_;
136 2 ▶ return $text? "[$text|$url]": "[$url]";
Branch: 1 branch
BranchTrueFalseTotal
$text ? : 1 1 2
137 }
138  
139 # -----------------------------------------------------------------------------
140  
141 =head3 paragraph() - Paragraph
142  
143 =head4 Synopsis
144  
145 $markup = $gen->paragraph($text);
146  
147 =head4 Description
148  
149 Erzeuge einen Paragraph und liefere den resultierenden Wiki-Code
150 zurück. Ist $text nicht angegeben oder ein Leerstring, wird ein
151 Leerstring geliefert. Andernfalls wird $text per trim() von einer
152 etwaigen Einrückung befreit und Zeilenumbrüche durch Leerzeichen
153 ersetzt, da ein Paragraph in Confluence-Wiki Syntax einzeilig ist.
154  
155 =head4 Examples
156  
157 =over 2
158  
159 =item *
160  
161 Text:
162  
163 $gen->paragraph("Dies ist\nein Test.");
164  
165 erzeugt
166  
167 Dies ist ein Test.
168  
169 =item *
170  
171 Eine Einrückung wird automatisch entfernt:
172  
173 $gen->paragraph(q~
174 Dies ist
175 ein Test.
176 ~);
177  
178 erzeugt
179  
180 Dies ist ein Test.
181  
182 =back
183  
184 =cut
185  
186 # -----------------------------------------------------------------------------
187  
188 2 ▶sub paragraph {
Subroutine paragraph: called CC=3 SCAR=11.0
Pod documented
189 2 my $self = shift;
190 2 ▶ my $text = shift // '';
Condition50%1/2
shift() // ""
l!l
20
MC/DC0%0/1
shift() // ""
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
191  
192 2 $text = Quiq::Unindent->trim($text);
193 2 $text =~ s/\n+/ /g; # Zeilenumbrüche zu Leerzeichen
194 2 ▶ if ($text ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($text ne "") 1 1 2
195 1 $text .= "\n\n";
196 }
197  
198 2 return $text;
199 }
200  
201 # -----------------------------------------------------------------------------
202  
203 =head3 tableHeaderRow() - Tabellen-Kopfzeile
204  
205 =head4 Synopsis
206  
207 $markup = $gen->tableHeaderRow(@titles);
208  
209 =head4 Description
210  
211 Confluence-Doku: L<Tables|https://confluence.atlassian.com/doc/confluence-wiki-markup-251003035.html#ConfluenceWikiMarkup-Tables>
212  
213 Erzeuge den Markup-Text für die Kopfzeile einer Tabelle und
214 liefere diesen zurück.
215  
216 =head4 Examples
217  
218 =over 2
219  
220 =item *
221  
222 Tabellen-Kopfzeile:
223  
224 $gen->tableHeaderRow(qw/A B C D/);
225  
226 erzeugt
227  
228 ||A||B||C||D||\n
229  
230 =item *
231  
232 Tabellen-Kopfzeile mit leerem Kolumnentitel:
233  
234 $gen->tableHeaderRow('A','','B','C','D');
235  
236 erzeugt
237  
238 ||A|| ||B||C||D||\n
239  
240 =back
241  
242 =cut
243  
244 # -----------------------------------------------------------------------------
245  
246 2 ▶sub tableHeaderRow {
Subroutine tableHeaderRow: called CC=3 SCAR=11.0
Pod documented
247 2 my $self = shift;
248 # @_: @titles
249  
250 2 ▶ return '||'.join('||',map{!defined || $_ eq ''? ' ': $_} @_)."||\n";
Branch: 1 branch
BranchTrueFalseTotal
!defined($_) || $_ eq '' ? : 1 8 9
Condition66%2/3
not defined $_ or $_ eq ""
l!l&&r!l&&!r
018
MC/DC50%1/2
not defined $_ or $_ eq ""
not defined $_ $_ eq ""
Truth table66%2/3
not(A) or B
A= not defined $_B= $_ eq ""
ABresult
1X1
011
000
251 }
252  
253 # -----------------------------------------------------------------------------
254  
255 =head3 tableRow() - Tabellen-Zeile
256  
257 =head4 Synopsis
258  
259 $markup = $gen->tableRow(@data);
260  
261 =head4 Description
262  
263 Confluence-Doku: L<Tables|https://confluence.atlassian.com/doc/confluence-wiki-markup-251003035.html#ConfluenceWikiMarkup-Tables>
264  
265 Erzeuge den Markup-Text für die Zeile einer Tabelle und
266 liefere diesen zurück.
267  
268 =head4 Examples
269  
270 =over 2
271  
272 =item *
273  
274 Zeile:
275  
276 $gen->tableRow(1,2,3,4);
277  
278 erzeugt
279  
280 |1|2|3|4|\n
281  
282 =item *
283  
284 Zeile mit leerem Wert:
285  
286 $gen->tableRow(1,undef,2,3,4);
287  
288 erzeugt
289  
290 |1| |2|3|4\n
291  
292 =back
293  
294 =cut
295  
296 # -----------------------------------------------------------------------------
297  
298 2 ▶sub tableRow {
Subroutine tableRow: called CC=3 SCAR=11.0
Pod documented
299 2 my $self = shift;
300 # @_: @titles
301  
302 2 ▶ return '|'.join('|',map{!defined || $_ eq ''? ' ': $_} @_)."|\n";
Branch: 1 branch
BranchTrueFalseTotal
!defined($_) || $_ eq '' ? : 1 8 9
Condition66%2/3
not defined $_ or $_ eq ""
l!l&&r!l&&!r
108
MC/DC50%1/2
not defined $_ or $_ eq ""
not defined $_ $_ eq ""
Truth table66%2/3
not(A) or B
A= not defined $_B= $_ eq ""
ABresult
1X1
011
000
303 }
304  
305 # -----------------------------------------------------------------------------
306  
307 =head3 section() - Abschnitt
308  
309 =head4 Synopsis
310  
311 $markup = $gen->section($level,$title);
312 $markup = $gen->section($level,$title,$body);
313  
314 =head4 Alias
315  
316 heading()
317  
318 =head4 Description
319  
320 Confluence-Doku: L<Heading|https://confluence.atlassian.com/doc/confluence-wiki-markup-251003035.html#ConfluenceWikiMarkup-Headings>
321  
322 Erzeuge einen Abschnitt der Ebene $level mit dem Titel $title und
323 dem (optionalen) Abschnitts-Körper $body und liefere den
324 resultierenden Code zurück. Ist $body nicht angegeben oder ein
325 Leerstring, wird nur der Titel erzeugt. Andernfalls wird $body per
326 trim() von einer etwaigen Einrückung befreit.
327  
328 =head4 Examples
329  
330 =over 2
331  
332 =item *
333  
334 Ohne Body:
335  
336 $gen->section(1,'Test');
337  
338 erzeugt
339  
340 h1. Test
341  
342 =item *
343  
344 Mit Body:
345  
346 $gen->section(1,'Test',"Dies ist ein Test.");
347  
348 erzeugt
349  
350 h1. Test
351
352 Dies ist ein Test.
353  
354 =item *
355  
356 Eine Einrückung wird automatisch entfernt:
357  
358 $gen->section(1,'Test',q~
359 Dies ist ein Test.
360 ~);
361  
362 erzeugt
363  
364 h1. Test
365
366 Dies ist ein Test.
367  
368 =back
369  
370 =cut
371  
372 # -----------------------------------------------------------------------------
373  
374 2 ▶sub section {
Subroutine section: called CC=3 SCAR=11.0
Pod documented
375 2 my ($self,$level,$title,$body) = @_;
376  
377 2 my $markup = "h$level. $title\n\n";
378 2 ▶ if (defined $body) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $body) 1 1 2
379 1 $body = Quiq::Unindent->trim($body);
380 1 ▶ if ($body ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($body ne "") 1 0 1
381 1 $markup .= "$body\n\n";
382 }
383 }
384  
385 2 return $markup;
386 }
387  
388 {
389 2 ▶ no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
390 2 *heading = \&section;
391 }
392  
393 # -----------------------------------------------------------------------------
394  
395 =head2 Macros
396  
397 =head3 code() - Code-Block (code)
398  
399 =head4 Synopsis
400  
401 $markup = $gen->code($type,$code,@opts);
402  
403 =head4 Options
404  
405 =over 4
406  
407 =item -collapse => $bool (Confluence-Default: 0)
408  
409 Zeige den Code-Block zusammengeklappt an. Durch Betätigung eines
410 Link kann er aufgeklappt werden.
411  
412 =item -firstLine => $n (Confluence-Default: 1)
413  
414 Wenn Option C<-lineNumbers> gesetzt ist, die Nummer der ersten Zeile,
415 ggf. mit führenden Nullen. Z.B. C<0001>.
416  
417 =item -lineNumbers => $bool (Confluence-Default: 0)
418  
419 Nummeriere die Zeilen durch.
420  
421 =item -theme => $theme (Confluence-Default: 'Confluence')
422  
423 Das Farbschema für die Darstellungs des Code-Blocks. Mögliche
424 Werte siehe o.g. Confluence-Doku.
425  
426 =item -title => $title (Confluence-Default: kein Titel)
427  
428 Füge einen Titel zum Code-Block hinzu.
429  
430 =back
431  
432 =head4 Description
433  
434 Confluence Doku: L<Code Block Macro|https://confluence.atlassian.com/doc/code-block-macro-139390.html>
435  
436 Erzeuge ein Code-Macro für Code $code mit Syntax-Typ $type und
437 liefere den resultierenden Wiki-Code zurück. Die Liste der verfügbaren
438 Syntax-Typen findet sich in o.g. Confluence-Doku.
439  
440 =head4 Examples
441  
442 =over 2
443  
444 =item *
445  
446 Ein eingeklappter Code-Block:
447  
448 $gen->code('perl',"print 'Hello, world!';",
449 -collapse => 1,
450 );
451  
452 erzeugt
453  
454 {code:language=perl|collapse=true}
455 print 'Hello, world!';
456 {code}
457  
458 =back
459  
460 =cut
461  
462 # -----------------------------------------------------------------------------
463  
464 1 ▶sub code {
Subroutine code: called CC=9 SCAR=36.0
Pod documented
465 1 my ($self,$type,$code) = splice @_,0,3;
466 # @_: @opts
467  
468 1 my @opts = ("language=$type");
469 1 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 1 1
470 0 my $key = shift;
471 0 ▶ if ($key eq '-collapse') {
Branch: 5 branches
BranchTrueFalseTotal
if ($key eq '-collapse') { } 0 0 0
elsif ($key eq '-firstLine') { } 0 0 0
elsif ($key eq '-lineNumbers') { } 0 0 0
elsif ($key eq '-theme') { } 0 0 0
elsif ($key eq '-title') { } 0 0 0
472 0 ▶ if (shift) {
Branch: 1 branch
BranchTrueFalseTotal
if (shift()) 0 0 0
473 0 push @opts,'collapse=true';
474 }
475 }
476 elsif ($key eq '-firstLine') {
477 0 push @opts,'firstline='.shift;
478 }
479 elsif ($key eq '-lineNumbers') {
480 0 push @opts,'linenumbers='.shift;
481 }
482 elsif ($key eq '-theme') {
483 0 push @opts,'theme='.shift;
484 }
485 elsif ($key eq '-title') {
486 0 push @opts,'title='.shift;
487 }
488 else {
489 0 $self->throw(
490 'CONFLUENCE-00001: Unknown code macro option',
491 Option => $key,
492 );
493 }
494 }
495  
496 1 $code =~ s/^\n+//;
497 1 $code =~ s/\n+$//;
498 1 ▶ if ($code) {
Branch: 1 branch
BranchTrueFalseTotal
if ($code) 1 0 1
499 1 $code .= "\n";
500 }
501  
502 1 return sprintf "\{code:%s\}\n$code\{code\}\n\n",join('|',@opts);
503 }
504  
505 # -----------------------------------------------------------------------------
506  
507 =head3 noFormat() - Text-Block ohne Formatierung (noformat)
508  
509 =head4 Synopsis
510  
511 $markup = $gen->noFormat($text,@opts);
512  
513 =head4 Options
514  
515 =over 4
516  
517 =item -noPanel => $bool (Confluence-Default: 0)
518  
519 Kein Panel um den Inhalt herum.
520  
521 =back
522  
523 =head4 Description
524  
525 Confluence Doku: L<Noformat Macro|https://confluence.atlassian.com/doc/noformat-macro-139545.html>
526  
527 Zeige einen Text-Block monospaced ohne weitere Formatierung an.
528  
529 Anmerkung: Dieses Makro ist nicht geeignet, um eine Formatierung
530 innerhalb eines Paragraphen zu verhindern, da der Text als
531 eigenständiger Block (mit oder ohne Umrandung) dargestellt wird.
532 Es entspricht einem Code-Block-Makro ohne Syntax-Highlighting,
533 bei dem zusätzlich die Umrandung unterdrückt werden kann.
534  
535 =head4 Examples
536  
537 =over 2
538  
539 =item *
540  
541 Anzeige eines regulären Ausdrucks:
542  
543 $gen->noFormat('m|/([^/]+)xxx{5}$|',
544 -noPanel => 1,
545 );
546  
547 erzeugt
548  
549 {noformat:nopanel=true}m|/([^/]+)xxx{5}$|{noformat}
550  
551 =back
552  
553 =cut
554  
555 # -----------------------------------------------------------------------------
556  
557 1 ▶sub noFormat {
Subroutine noFormat: called CC=5 SCAR=22.7
Pod documented
558 1 my ($self,$text) = splice @_,0,2;
559 # @_: @opts
560  
561 1 my @opts;
562 1 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 1 1
563 0 my $key = shift;
564 0 ▶ if ($key eq '-noPanel') {
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq '-noPanel') { } 0 0 0
565 0 ▶ if (shift) {
Branch: 1 branch
BranchTrueFalseTotal
if (shift()) 0 0 0
566 0 push @opts,'nopanel=true';
567 }
568 }
569 else {
570 0 $self->throw(
571 'CONFLUENCE-00001: Unknown noformat macro option',
572 Option => $key,
573 );
574 }
575 }
576  
577 1 $text =~ s/^\n+//;
578 1 $text =~ s/\n+$//;
579 1 ▶ if ($text =~ /\n/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($text =~ /\n/) 0 1 1
580 0 $text = "\n$text\n";
581 }
582  
583 1 return sprintf "{noformat:%s}${text}{noformat}\n\n",join('|',@opts);
584 }
585  
586 # -----------------------------------------------------------------------------
587  
588 =head3 panel() - Umrandung mit optionalem Titel (panel)
589  
590 =head4 Synopsis
591  
592 $markup = $gen->panel($body,@opts);
593  
594 =head4 Options
595  
596 =over 4
597  
598 =item -title => $title (Confluence-Default: none)
599  
600 Titel des Panel.
601  
602 =item -borderStyle => $style (Confluence-Default: 'solid')
603  
604 Stil der Umrandung. Wert: solid, dashed und andere CSS
605 Umrandungs-Stile.
606  
607 =item -borderColor => $color
608  
609 Farbe der Umrandung. Wert: wie HTML.
610  
611 =item -borderWidth => $n
612  
613 Breite der Umrandung in Pixeln.
614  
615 =item -backgroundColor => $color.
616  
617 Hintergrundfarbe. Wert: wie HTML.
618  
619 =item -titleBackgroundColor => $color
620  
621 Farbe Titel-Hintergrund. Wert: wie HTML.
622  
623 =item -titleTextColor => $color
624  
625 Farbe des Titel-Textes. Wert: wie HTML.
626  
627 =back
628  
629 =head4 Description
630  
631 Confluence-Doku: L<Panel Macro|https://confluence.atlassian.com/doc/panel-macro-51872380.html>
632  
633 Erzeuge ein Panel-Macro mit Inhalt $body und liefere den
634 resultierenden Wiki-Code zurück.
635  
636 =cut
637  
638 # -----------------------------------------------------------------------------
639  
640 2 ▶sub panel {
Subroutine panel: called CC=11 SCAR=33.1
Pod documented
641 2 my $self = shift;
642 2 ▶ my $body = shift // '';
Condition100%2/2
shift() // ""
l!l
11
MC/DC100%1/1
shift() // ""
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
643 # @_: @opts
644  
645 2 my @opts;
646 2 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 1 2 3
647 1 my $key = shift;
648 1 ▶ if ($key eq '-title') {
Branch: 7 branches
BranchTrueFalseTotal
if ($key eq '-title') { } 1 0 1
elsif ($key eq '-borderStyle') { } 0 0 0
elsif ($key eq '-borderColor') { } 0 0 0
elsif ($key eq '-borderWidth') { } 0 0 0
elsif ($key eq '-backgroundColor') { } 0 0 0
elsif ($key eq '-titleBGColor') { } 0 0 0
elsif ($key eq '-titleColor') { } 0 0 0
649 1 push @opts,'title='.shift;
650 }
651 elsif ($key eq '-borderStyle') {
652 0 push @opts,'borderStyle='.shift;
653 }
654 elsif ($key eq '-borderColor') {
655 0 push @opts,'borderColor='.shift;
656 }
657 elsif ($key eq '-borderWidth') {
658 0 push @opts,'borderWidth='.shift;
659 }
660 elsif ($key eq '-backgroundColor') {
661 0 push @opts,'bgColor='.shift;
662 }
663 elsif ($key eq '-titleBGColor') {
664 0 push @opts,'titleBGColor='.shift;
665 }
666 elsif ($key eq '-titleColor') {
667 0 push @opts,'titleColor='.shift;
668 }
669 else {
670 0 $self->throw(
671 'CONFLUENCE-00001: Unknown panel option',
672 Option => $key,
673 );
674 }
675 }
676  
677 2 $body =~ s/^\n+//;
678 2 $body =~ s/\n+$//;
679 2 ▶ if ($body) {
Branch: 1 branch
BranchTrueFalseTotal
if ($body) 1 1 2
680 1 $body .= "\n";
681 }
682  
683 2 return sprintf "\{panel:%s\}\n$body\{panel\}\n\n",join('|',@opts);
684 }
685  
686 # -----------------------------------------------------------------------------
687  
688 =head3 tableOfContents() - Inhaltsverzeichnis (toc)
689  
690 =head4 Synopsis
691  
692 $markup = $gen->tableOfContents(@opts);
693  
694 =head4 Options
695  
696 =over 4
697  
698 =item -type => 'list'|'flat' (Confluence-Default: 'list')
699  
700 Listenartiges oder horizontales Menü.
701  
702 =item -outline => $bool (Confluence-Default: 0)
703  
704 Outline-Numbering ((1.1, 1.2, usw.) aus oder ein.
705  
706 =item -style => $style (Confluence-Default: 'disc')
707  
708 Style der Bullet-Points. Wert: Wie CSS (none, circle, disc,
709 square, decimal, lower-alpha, lower-roman, upper-roman).
710  
711 =item -indent => $indent
712  
713 Einrücktiefe zwischen den Ebenen (nur Liste). Wert: CSS-Einheit
714 (z.B. 10px).
715  
716 =item -separator => $separator (Confluence-Default: 'brackets')
717  
718 Separator bei horizontalem Inhaltsverzeichnis: Wert: brackets,
719 braces, parens, pipe, I<anything>.
720  
721 =item -minLevel => $n (Confluence-Default: 1)
722  
723 Die niedrigste Ebene, die in das Inhaltsverzeichnis aufgenommen wird.
724  
725 =item -maxLevel => $n (Confluence-Default: 7)
726  
727 Die höchste Ebene, die in das Inhaltsverzeichnis aufgenommen wird.
728  
729 =item -include => $regex
730  
731 Regulärer Ausdruck, der die Abschnittstitel matcht, die in das
732 Inhaltsverzweichnis aufgenommen werden.
733  
734 =item -exclude => $regex
735  
736 Regulärer Ausdruck, der die Abschnittstitel matcht, die I<nicht>
737 in das Inhaltsverzweichnis aufgenommen werden.
738  
739 =item -printable => $bool (Confluence-Default: 1)
740  
741 Das Inhaltsverzeichnis wird mit ausgegeben, wenn die Seite
742 gedruckt wird.
743  
744 =item -class => $class
745  
746 Inhaltsverzeichnis wird in <div class="$class">...</div> eingefasst.
747  
748 =item -absoluteUrl => $bool
749  
750 Verwende absolute URLs.
751  
752 =back
753  
754 =head4 Description
755  
756 Confluence-Doku: L<Table of Contents Macro|https://confluence.atlassian.com/doc/table-of-contents-macro-182682099.html>
757  
758 Erzeuge ein Inhaltsverzeichnis-Macro und liefere den
759 resultierenden Wiki-Code zurück.
760  
761 =cut
762  
763 # -----------------------------------------------------------------------------
764  
765 1 ▶sub tableOfContents {
Subroutine tableOfContents: called CC=15 SCAR=51.7
Pod documented
766 1 my $self = shift;
767 # @_: @opts
768  
769 1 my @opts;
770 1 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 1 1
771 0 my $key = shift;
772 0 ▶ if ($key eq '-') {
Branch: 13 branches
BranchTrueFalseTotal
if ($key eq '-') { } 0 0 0
elsif ($key eq '-type') { } 0 0 0
elsif ($key eq '-outline') { } 0 0 0
elsif ($key eq '-style') { } 0 0 0
elsif ($key eq '-indent') { } 0 0 0
elsif ($key eq '-separator') { } 0 0 0
elsif ($key eq '-minLevel') { } 0 0 0
elsif ($key eq '-maxLevel') { } 0 0 0
elsif ($key eq '-include') { } 0 0 0
elsif ($key eq '-exclude') { } 0 0 0
elsif ($key eq '-printable') { } 0 0 0
elsif ($key eq '-class') { } 0 0 0
elsif ($key eq '-absoluteUrl') { } 0 0 0
773 0 push @opts,'='.shift;
774 }
775 elsif ($key eq '-type') {
776 0 push @opts,'type='.shift;
777 }
778 elsif ($key eq '-outline') {
779 0 push @opts,'outline='.shift;
780 }
781 elsif ($key eq '-style') {
782 0 push @opts,'style='.shift;
783 }
784 elsif ($key eq '-indent') {
785 0 push @opts,'indent='.shift;
786 }
787 elsif ($key eq '-separator') {
788 0 push @opts,'separator='.shift;
789 }
790 elsif ($key eq '-minLevel') {
791 0 push @opts,'minLevel='.shift;
792 }
793 elsif ($key eq '-maxLevel') {
794 0 push @opts,'maxLevel='.shift;
795 }
796 elsif ($key eq '-include') {
797 0 push @opts,'include='.shift;
798 }
799 elsif ($key eq '-exclude') {
800 0 push @opts,'exclude='.shift;
801 }
802 elsif ($key eq '-printable') {
803 0 push @opts,'printable='.shift;
804 }
805 elsif ($key eq '-class') {
806 0 push @opts,'class='.shift;
807 }
808 elsif ($key eq '-absoluteUrl') {
809 0 push @opts,'absoluteUrl='.shift;
810 }
811 else {
812 0 $self->throw(
813 'CONFLUENCE-00001: Unknown panel option',
814 Option => $key,
815 );
816 }
817 }
818  
819 # FIXME: Weitere Optionen
820  
821 1 return sprintf "\{toc:%s\}\n\n",join '|',@opts;
822 }
823  
824 # -----------------------------------------------------------------------------
825  
826 =head2 Text-Formatierung
827  
828 =head3 fmt() - Text-Formatierung
829  
830 =head4 Synopsis
831  
832 $str = $this->fmt($format,$text);
833 $str = $this->fmt($color,$text);
834  
835 =head4 Description
836  
837 Confluence-Doku: L<Text Effects|https://confluence.atlassian.com/doc/confluence-wiki-markup-251003035.html#ConfluenceWikiMarkup-TextEffects>
838  
839 Erzeuge Formatierung $format für Text $text und liefere den
840 resultierenden Wiki-Code zurück.
841  
842 Es existieren die Formatierungen:
843  
844 =over 2
845  
846 =item *
847  
848 bold
849  
850 =item *
851  
852 italic
853  
854 =item *
855  
856 citation
857  
858 =item *
859  
860 deleted
861  
862 =item *
863  
864 inserted
865  
866 =item *
867  
868 superscript
869  
870 =item *
871  
872 subscript
873  
874 =item *
875  
876 monospace
877  
878 =item *
879  
880 blockquote
881  
882 =item *
883  
884 $color
885  
886 =item *
887  
888 protect
889  
890 =back
891  
892 Das Format 'protect' ist eine Erweiterung der
893 Confluence-Formatierungen. Es schützt die Zeichen in $text, so
894 dass diese formatierungsfrei dargestellt werden. Geschützt werden
895 die Zeichen:
896  
897 - * _ + ^ ~ [ ] { }
898  
899 Die Interpretation als Metazeichen wird durch das Voranstellen
900 eines Backslash (\) verhindert.
901  
902 =cut
903  
904 # -----------------------------------------------------------------------------
905  
906 2 ▶sub fmt {
Subroutine fmt: called CC=12 SCAR=33.6
Pod documented
907 2 my $this = shift;
908 2 my $format = shift;
909 2 ▶ my $text = shift // '';
Condition50%1/2
shift() // ""
l!l
20
MC/DC0%0/1
shift() // ""
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
910  
911 2 $text = Quiq::Unindent->trim($text);
912 2 $text =~ s/\n+/ /g;
913  
914 2 ▶ if ($format eq 'bold') {
Branch: 10 branches
BranchTrueFalseTotal
if ($format eq 'bold') { } 1 1 2
elsif ($format eq 'italic') { } 0 1 1
elsif ($format eq 'citation') { } 0 1 1
elsif ($format eq 'deleted') { } 0 1 1
elsif ($format eq 'inserted') { } 0 1 1
elsif ($format eq 'superscript') { } 0 1 1
elsif ($format eq 'subscript') { } 0 1 1
elsif ($format eq 'monospace') { } 0 1 1
elsif ($format eq 'blockquaote') { } 0 1 1
elsif ($format eq 'protect') { } 0 1 1
915 1 $text = "*$text*";
916 }
917 elsif ($format eq 'italic') {
918 0 $text = "_$text\_";
919 }
920 elsif ($format eq 'citation') {
921 0 $text = "??$text??";
922 }
923 elsif ($format eq 'deleted') {
924 0 $text = "-$text-";
925 }
926 elsif ($format eq 'inserted') {
927 0 $text = "+$text+";
928 }
929 elsif ($format eq 'superscript') {
930 0 $text = "^$text^";
931 }
932 elsif ($format eq 'subscript') {
933 0 $text = "~$text~";
934 }
935 elsif ($format eq 'monospace') {
936 0 $text = "{{$text}}";
937 }
938 elsif ($format eq 'blockquaote') {
939 0 $text = "bq. $text";
940 }
941 elsif ($format eq 'protect') {
942 # $text =~ s/((?<!\\)[-[\]{}*_+^~])/\\$1/g;
943 # $text =~ s/([-[\]{}*_+^~])/\\$1/g;
944 0 $text =~ s/([^ A-Za-z0-9.,])/'&#'.ord($1).';'/eg;
945 }
946 else {
947 1 $text = "{color:$format}$text\{color}";
948 }
949  
950 2 return $text;
951 }
952  
953 # -----------------------------------------------------------------------------
954  
955 =head3 lineBreak() - Zeilenumbruch
956  
957 =head4 Synopsis
958  
959 $str = $gen->lineBreak;
960  
961 =cut
962  
963 # -----------------------------------------------------------------------------
964  
965 0 ▶sub lineBreak {
Subroutine lineBreak: not called CC=1 SCAR=6.9
Pod documented
966 0 my $self = shift;
967 0 return ' \\\\ ';
968 }
969  
970 # -----------------------------------------------------------------------------
971  
972 =head2 Test
973  
974 =head3 testPage() - Generiere Test-Seite
975  
976 =head4 Synopsis
977  
978 $str = $this->testPage;
979  
980 =head4 Description
981  
982 Generiere eine Seite mit Wiki-Markup. Das Markup kann nach Confluence
983 übertragen und dort optisch begutachtet werden.
984  
985 =head4 Examples
986  
987 =over 2
988  
989 =item *
990  
991 Test-Seite von der Kommandozeile ins Wiki übertragen:
992  
993 $ quiq-confluence test-page | quiq-confluence update-page PAGE_ID
994  
995 =item *
996  
997 Manuelle Übertragung:
998  
999 =over 4
1000  
1001 =item 1.
1002  
1003 Markup generieren:
1004  
1005 $ quiq-confluence test-page
1006  
1007 =item 2.
1008  
1009 In Confluence die Zielseite zum Editieren öffnen und Option
1010 "Markup {}" wählen. Ausgabe aus 1. per copy-and-paste in den
1011 Dialog übertragen und diesen speichern.
1012  
1013 =back
1014  
1015 =back
1016  
1017 =cut
1018  
1019 # -----------------------------------------------------------------------------
1020  
1021 0 ▶sub testPage {
Subroutine testPage: not called CC=3 SCAR=24.8
Pod documented
1022 0 my $class = shift;
1023  
1024 0 my $gen = $class->new;
1025  
1026 0 my $str = $gen->heading(1,'Inhaltsverzeichnis');
1027 0 $str =~ s/\n+$/\n/;
1028  
1029 0 $str .= $gen->panel(
1030 $gen->tableOfContents,
1031 );
1032  
1033 0 for my $i (1 .. 6) {
1034 0 $str .= $gen->heading($i,"Überschrift $i");
1035 }
1036  
1037 0 $str .= $gen->heading(1,'Paragraph');
1038  
1039 0 $str .= $gen->paragraph(q~
1040 Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam
1041 nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam
1042 erat, sed diam voluptua. At vero eos et accusam et justo duo
1043 dolores et ea rebum. Stet clita kasd gubergren, no sea takimata
1044 sanctus est Lorem ipsum dolor sit amet.
1045 ~);
1046  
1047 0 $str .= $gen->heading(1,'Code Block');
1048  
1049 0 $str .= $gen->code('perl',"print 'Hello, world';");
1050  
1051 0 $str .= $gen->code('perl',"print 'Hello, world';",
1052 -title => 'Code Block',
1053 );
1054  
1055 0 $str .= $gen->code('perl',"print 'Hello, world';",
1056 -title => 'Code Block, collapse=true',
1057 -collapse => 1,
1058 );
1059  
1060 0 $str .= $gen->heading(1,'Text-Formatierung');
1061  
1062 0 for my $format (qw/bold italic citation deleted inserted superscript
1063 subscript monospace blockquote red green navy/) {
1064 0 $str .= sprintf "%s: %s\n\n",
1065 $gen->fmt('bold',$format),
1066 $gen->fmt($format,q~
1067 Lorem ipsum dolor sit amet, consetetur sadipscing elitr,
1068 sed diam
1069 ~);
1070 }
1071  
1072 0 $str .= $gen->paragraph(
1073 $gen->fmt('bold','Dies').' '.
1074 $gen->fmt('italic','ist').' '.
1075 $gen->fmt('red','ein').' '.
1076 $gen->fmt('green','Test').'.'
1077 );
1078  
1079 0 $str .= $gen->heading(1,'No Format');
1080  
1081 0 $str .= $gen->noFormat('m|/([^/]+)xxx{5}$|');
1082  
1083 0 $str .= $gen->noFormat('m|/([^/]+)xxx{5}$|',
1084 -noPanel => 1,
1085 );
1086  
1087 0 $str .= $gen->heading(1,'Protect');
1088  
1089 0 $str .= $gen->paragraph(
1090 'Die Zeichenkette "'.
1091 $gen->fmt('green',
1092 $gen->fmt('monospace',
1093 $gen->fmt('bold',
1094 $gen->fmt('protect','m|/([^/]+)xxx{5}$|'),
1095 ),
1096 ),
1097 ).
1098 '" ist ein Regex.'
1099 );
1100  
1101 0 $str .= $gen->paragraph(
1102 $gen->fmt('protect','_Hallo Welt_'),
1103 );
1104  
1105 0 return $str;
1106 }
1107  
1108 # -----------------------------------------------------------------------------
1109  
1110 =head1 VERSION
1111  
1112 1.240
1113  
1114 =head1 AUTHOR
1115  
1116 Frank Seitz, L<http://fseitz.de/>
1117  
1118 =head1 COPYRIGHT
1119  
1120 Copyright (C) 2026 Frank Seitz
1121  
1122 =head1 LICENSE
1123  
1124 This code is free software; you can redistribute it and/or modify
1125 it under the same terms as Perl itself.
1126  
1127 =cut
1128  
1129 # -----------------------------------------------------------------------------
1130  
1131 2 1;
1132  
1133 # eof
« Quiq/Database/Api/Dbi/Connection.pm ↑ Summary Quiq/ImagePool/Sequence.pm »