-
Notifications
You must be signed in to change notification settings - Fork 0
/
Specification.pod6
3278 lines (2389 loc) · 97.4 KB
/
Specification.pod6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
=begin pod :puburl('/specification') :pubdate('2023-11-15 18:14:00')
=comment
This file is deliberately specified in Podlite format
=TITLE Podlite - a lightweight markup language
=begin nested :notify<warning> :caption('Work on the next release continues!')
If you have any ideas to make it better, or if you have any questions,
you're welcome to suggest changes or start a conversation on
our L<GitHub page|https://github.com/podlite/podlite-specs/discussions>.
Looking forward to working on the next release with your valuable input.
=end nested
=toc head1, head2, head3
=begin AUTHORS
=item Damian Conway <L<C<[email protected]>|mailto:[email protected]>>
=item Aliaksandr Zahatski <L<C<[email protected]>|mailto:[email protected]>>
=end AUTHORS
=VERSION 1.0
=begin CHANGES
=head2 v1.0
=head3 New:
=item Notification blocks, C<:notify> attribute for C<=nested> blocks,
=item C<:folded> attribute,
=item C<:folded-levels> for C<=toc> block,
=item Refactor Named custom blocks and markup custom codes, C<M<>>,
=item embedding binary data into documents, C<=data>, C<:filename>, C<:encoding>,
=item C<:mime-type> attribute for C<=include> and C<=data> blocks,
=item introduce C<data:> schema for use in C<=picture> and C<=table>,
=item render tables from CSV files, C<=table>,
=item new markdown mode for parser,
=item C<M<>> - extends inline markup features,
=item add C<:id>, C<:caption>, C<:lang> attributes,
=item task lists, C<=item> and C<:checked> attribute,
=item intro Selectors,
=item table of contents, C<=toc>,
=item include block, C<=include>,
=item inserting pictures, C<=picture>, C<P<>>,
=item mathematical formulas, C<=formula>, C<F<>>,
=item Markdown support, C<=markdown>,
=item mistake marking, C<O<>>,
=item text positioning, C<J<>>, C<H<>>,
=item Emoji, C<E<>>,
=item contextual backlinks, C<W<>>,
=item advanced table format, C<=row>,C<=cell> blocks,
C<:header>, C<:rowspan>, C<:colspan> attributes.
=head3 Deprecated/removed:
=item Contextual aliases,
=item C<=finish>,
=item markers in comments,
=item C<:margin> attribute,
=item C<=encoding> directive,
=item C<P<toc:>> due to C<=toc> block,
=item C<P<man:>>, C<P<doc:>> due to C<=include> block,
=item C<P<>> - placement links,
=item Declarator block,
=item C<:formatted> attribute,
=item C<:like> attribute.
=end CHANGES
=head1 Podlite
D<Podlite> is an easy-to-use markup language with a simple, consistent
underlying document object model. Podlite can be used for writing language
documentation, for documenting programs and modules, as well as for
other types of document composition.
The Podlite is a purely descriptive mark-up notation, with no presentational
components.
=head2 General syntactic structure
Podlite documents are specified using D<directives|directive>, which are
used to declare configuration information and to delimit blocks of
textual content.
Every directive starts either with an equals sign (C<=>) followed
immediately by an identifier.
An D<identifier|Podlite identifiers> composed of an alphabetical character followed by
any combination of alphanumeric characters. Alphabetic and numeric
definitions encompass relevant Unicode characters. The underscore
is consistently treated as alphabetic. Additionally, an identifier
can include isolated apostrophes or hyphens, given that the subsequent
character is alphabetic.
Directives that start with C<=> can be indented like the code they
interleave, but their initial C<=> must still be the first non-whitespace
character on their line.
An indented Podlite block is considered to have a I<virtual left margin>,
determined by the indentation of its opening delimiter.
In other words, if a directive is indented from the left margin, the
column at which the first character of its opening delimiter appears is
thereafter considered the first column of the entire block's contents.
The virtual margin treats leading tabs as aligning to tabstops spaced
every C<($?TABSTOP // 8)> characters.
=head2 Podlite blocks
The content of a document is specified within one or more D<blocks|block>.
Every Podlite block may be declared in any of three forms:
I<L<delimited style|#Delimited blocks>>, I<L<paragraph style|#Paragraph
blocks>>, or I<L<abbreviated style|#Abbreviated blocks>>.
All of these forms are equivalent.
Anything in a document that is neither a Podlite directive nor contained
within a Podlite block is treated as "ambient" material. Typically this
would be the source code of the program that the Podlite is documenting.
Podlite parsers still parse this text into the internal representation of the
file, representing it as a "ambient" block. Renderers
will I<usually> ignore such blocks.
This is the D<default mode|Default mode; parser modes> of the parser.
All directives have a defined terminator and the Podlite parser always reverts to
D<"ambient"|Ambient mode; parser modes> at the end of each Podlite directive or
block.
The C<=pod> block puts the parser in D<"pod" mode|Pod mode; parser modes>,
treating all text between blocks as implicit paragraph Podlite, even if
it's not inside an explicit block.
To keep the parser in "pod" mode, enclose the desired Podlite region
in a C<=pod> block:
=begin code :allow<B>
B<=begin pod>
=head1 A heading
This is Podlite too. Specifically, this is a simple C<para> block
$this = pod('also'); # Specifically, a code block
B<=end pod>
=end code
The contents of files with the extensions C<.podlite> and C<.pod6> are
implicitly wrapped in a C<=pod> directive.
For C<.md> and C<.markdown> files, the parser operates in D<"Markdown"
mode|Markdown mode; parser modes> for the entire file, treating all
text as markdown even if it is not inside an C<=markdown> block.
Any other file extension puts the parser in default mode. The L<C<=include>
block|#Include block > has a mechanism to override this behavior by using
the C<:mime-type> attribute for the included files.
=head3 Delimited blocks
Delimited blocks are bounded by C<=begin> and C<=end> markers, both of
which are followed by a valid Podlite identifier, which is the
D<typename> of the block. Typenames that are entirely lowercase (for
example: C<=begin head1>) or entirely uppercase (for example: C<=begin
SYNOPSIS>) are reserved.
After the typename, the rest of the C<=begin> marker line is treated as
configuration information for the block. This information is used in
different ways by different types of blocks, but is always specified using
any of:
=for table :nested :caption("Configuration syntax options") :id<configuration_syntax>
Value is... Specify with... Or with... Or with...
=============== =================== ============== ======================
Boolean (true) C«:key» C«:key(1)» C«key => 1»
Boolean (false) C«:!key» C«:key(0)» C«key => 0»
String C«:key<str>» C«:key('str')» C«key => 'str'»
List C«:key<1 2 3>» C«:key[1,2,3]» C«key => [1,2,3]»
Hash C«:key{a=>1, b=>2}» C«key => {a=>1, b=>2}»
All option keys and values must, of course, be constants since Podlite is a
specification language, not a programming language. Specifically, option
values cannot be closures.
The configuration section may be extended over subsequent lines by
starting those lines with an C<=> in the first (virtual) column followed
by a whitespace character.
The lines following the opening delimiter and configuration are the
data or contents of the block, which continue until the block's matching
C<=end> marker line. For most block types, these contents may be
indented if you wish, without them being treated as L<code blocks|#Code
blocks>. Indented text is only treated as code within
C<=pod>, L<C<=nested>|#Nesting blocks>, L<C<=item>|#Lists>, C<=code>,
and L<semantic|#Semantic blocks> blocks.
The general syntax is:
=begin code :allow< R >
=begin R<BLOCK_TYPE> R<OPTIONAL CONFIG INFO>
= R<OPTIONAL EXTRA CONFIG INFO>
R<BLOCK CONTENTS>
=end R<BLOCK_TYPE>
=end code
For example:
=begin code
=begin table :caption<Table of Contents>
Constants 1
Variables 10
Subroutines 33
Everything else 57
=end table
=begin Name :required
= :width(50)
The applicant's full name
=end Name
=begin Contact :optional
The applicant's contact details
=end Contact
=end code
Note that no blank lines are required around the directives; blank
lines within the contents are always treated as part of the contents.
This is a universal feature of Podlite.
Note also that in the following specifications, a "blank line" is a line
that is either empty or that contains only whitespace characters. That
is, a blank line matches the following pattern: C</^^ \h* $$/>. Podlite uses
blank lines as delimiters, rather than empty lines, to minimize unpleasant
surprises when stray spaces or tabs mysteriously turn up in hitherto
empty lines.
=head3 Paragraph blocks
Paragraph blocks are introduced by a C<=for> marker and terminated by
the next Podlite directive or the first blank line (which is I<not>
considered to be part of the block's contents). The C<=for> marker is
followed by the name of the block and optional configuration
information. The general syntax is:
=begin code :allow< R >
=for R<BLOCK_TYPE> R<OPTIONAL CONFIG INFO>
= R<OPTIONAL EXTRA CONFIG INFO>
R<BLOCK DATA>
=end code
For example:
=begin code
=for table :caption<Table of Contents>
Constants 1
Variables 10
Subroutines 33
Everything else 57
=for Name :required
= :width(50)
The applicant's full name
=for Contact :optional
The applicant's contact details
=end code
=head3 Abbreviated blocks
Abbreviated blocks are introduced by an C<'='> sign in the
first column, which is followed immediately by the typename of the
block. The rest of the line is treated as block data, rather than as
configuration. The content terminates at the next Podlite directive or the
first blank line (which is not part of the block data). The general
syntax is:
=begin code :allow< R >
=R<BLOCK_TYPE> R<BLOCK DATA>
R<MORE BLOCK DATA>
=end code
For example:
=begin code
=table
Constants 1
Variables 10
Subroutines 33
Everything else 57
=Name The applicant's full name
=Contact The applicant's contact details
=end code
Note that abbreviated blocks cannot specify configuration information. If
configuration is required, use a C<=for> or C<=begin>/C<=end> instead.
=head3 Block equivalence
The underlying documentation model treats all block
specifications (delimited, paragraph, and abbreviated) the same way.
It is possible to choose the form is most convenient for a particular
documentation task. In the descriptions that follow, the abbreviated
form will generally be used, but should be read as standing for all
three forms equally.
For example, although L<#Headings> shows only:
=begin code
=head1 Top Level Heading
=end code
this automatically implies that you could also write that block as:
=begin code
=for head1
Top Level Heading
=end code
or:
=begin code
=begin head1
Top Level Heading
=end head1
=end code
=head3 Standard configuration options
Podlite predefines a small number of standard configuration options that can be
applied uniformly to any built-in block type. These include:
=begin defn
C<:caption>
This option assigns a title to the given block, which is typically used to create
a L<table of contents|#Table of contents>.
=end defn
=begin defn
C<:id>
This option enables the explicit definition of identifiers for blocks and use those
IDs for linking purposes (see L<#Links>).
=end defn
=begin defn
C<:nested>
This option specifies that the block is to be nested within its current
context. For example, nesting might be applied to block quotes, to textual
examples, or to commentaries. In addition the L<C<=code>|#Code blocks>,
L<C<=item>|#Lists>, L<C<=input>|#I/O blocks>, and L<C<=output>|#I/O blocks>
blocks all have implicit nesting.
Nesting of blocks is usually rendered by adding extra indentation to the
block contents, but may also be indicated in other ways:
by boxing the contents, by changing the font or size of the nested text,
or even by folding the text (so long as a visible placeholder is provided).
Occasionally it is desirable to nest content by more than one level:
=begin code
=begin para :nested
=begin para :nested
=begin para :nested
"We're going deep, deep, deep undercover!"
=end para
=end para
=end para
=end code
This can be simplified by giving the C<:nested> option a positive integer
value:
=begin code :allow<B>
=begin para B<:nested(3)>
"We're going deep, deep, deep undercover!"
=end para
=end code
You can also give the option a value of zero, to defeat any implicit
nesting that might normally be applied to a paragraph. For example, to
specify a block of code that should appear I<without> its usual
nesting:
=begin code :allow<B V>
=comment Don't nest this code block in the usual way...
B<=begin code :nested(0)>
1 2 3 4 5 6
123456789012345678901234567890123456789012345678901234567890
|------|-----------------------|---------------------------|
line instruction comments
number code
V<=end code>
=end code
Note that C<:!nested> could also be used for this purpose:
=begin code
=Z<>begin code :!nested
=end code
=end defn
=begin defn
C<:numbered>
This option specifies that the block is to be numbered. The most common
use of this option is to create L<numbered headings|#Numbered headings> and
L<ordered lists|#Ordered lists>, but it can be applied to any block.
The numbering conventions for headings and lists are specified in those
sections, but it is up to individual renderers to decide how to display
any numbering associated with other types of blocks.
Note that numbering is never explicit; it is always implied by context.
=end defn
=begin defn
C<:checked>
This attribute indicates that a checkbox should be added to that block.
It is possible to apply a C<:checked> attributes to any block.
The most common use of this option is to create L<task lists|#Task lists>.
For an unchecked checkbox the C<:!checked> is used.
The task list item marker (checkbox) is added to the output.
In HTML output, this would be represented as an
C<<input type="checkbox">> element.
The specification does not define how these checkboxes are interacted with.
Implementors are free to choose whether they render them as disabled,
unchangeable elements, or handle dynamic interactions like checking and unchecking
in the final rendered document.
=end defn
=begin defn
C<:folded>
This option specifies whether the block is foldable and, if specified,
whether it should be collapsed or expanded by default. This feature is
useful in managing the length of documents and focusing the reader's
attention on certain sections as needed.
A C<:!folded> or C<:folded(0)> expands the callout by default, and a
C<:folded> or C<:folded(1)> collapses it instead.
=begin code :allow<B>
=for table B<:folded> :caption('Culinary Techniques for Sustainability')
Sous-vide Low energy consumption
---------- -------------------------
Steaming Preserves nutrients
Baking Efficient for batch cooking
=end code
When applied to a block element, such as a heading, the attribute typically
affects all headings with lower-level content, creating a hierarchical
folding effect.
For example:
=begin code :allow<B>
=for B<head2 :folded>
Green Energy Overview
=end code
=begin comment
TODO: my be it may sense to add a C<:folded-caption> attribute to
define a custom title for the collapsed block.
The C<:folded-caption> attribute enables the definition of a custom title
for the collapsed block. If no caption is provided, rendering systems
may automatically use the C<:caption> attribute. In the absence of
the C<:caption> attribute, the first line or paragraph of the block
serves as the default title. For semantic blocks, the name of the block
may be used as the default title.
=begin code
=picture :folded(1) :folded-caption("Wind Turbine Fields")
Images/wind_turbines.jpg
Wind turbines stand tall against the sky, harnessing
the power of the wind to generate energy
=end code
=end comment
=end defn
=begin defn
C<:lang>
This option is used to L<provide information|#Assign programming language to
code blocks> about the programming language used in a specific code block.
This helps ensure that the code is displayed and interpreted correctly
by rendering engines or syntax highlighters.
Here's a table that lists a few programming languages along with their possible
values for the C<:lang> attribute:
=begin table :caption("Matching languages and lang attribute values")
Programming language Possible C<:lang> values
-------------------- -------------------------
C++ cpp
CSS css
HTML html
Java java
JavaScript javascript
Python python
Raku raku
=end table
If the language is not specified, the default language is used based
on the file extension or mime type of the current document.
=end defn
=begin defn
C<:allow>
This option expects a list of markup codes that are to be recognized
within any C<V<>> codes that appear in (or are implicitly applied to)
the current block. The option is most often used on C<=code> blocks to
allow mark-up within those otherwise verbatim blocks, though it can be
used in I<any> block that contains verbatim text. See L<#Formatting
within code blocks>.
=end defn
=head2 Selectors
Selectors consist of patterns that help identify and filter specific blocks
within documents. Each pattern contains optional source of blocks and block names.
The general syntax is:
=begin code :allow< R >
R<EXTERNAL_SOURCE>
or
[ R<EXTERNAL_SOURCE> | ] R<BLOCKS_SELECTOR>
=end code
...where
=item EXTERNAL_SOURCE - optional source of blocks for filtering, default current document,
=item BLOCK_SELECTOR - list of block names, filter for
For example:
=begin table :nested
Selector Description
_______________________________________ ___________________________________________________
head1, head2, item1 all head1, head2 and item1 blocks from document
file:article.pod6 | head1, head2 all head1 and head2 blocks from article.pod6 file
file:./includes/*.pod6 | head1, head2 all head1 and head2 blocks from pod6 files placed
in includes directory
doc:Data::Dumper | code all code blocks from a module documentation
file:/docs/**/*.md | head1 search headers with first level for all ".md" files
within the "docs" directory and its subdirectories.
=end table
Please note that while the Selector blocks provide a way to query and filter specific elements
within Markdown files, Markdown itself doesn't have formal named blocks like the Podlite syntax.
Instead, Markdown uses a lightweight markup to structure content. The above table provides a mapping
between Podlite block names and their corresponding Markdown elements.
=begin table :nested :caption("A table of correspondences for some Podlite blocks and markdown blocks")
Podlite Markdown Describtion
_______________________________________ ______________ _____________________________________
C<=head1>, C<=head2>, ... #, ##, ... Heading level 1,2...
C<=nested> ">" blockquote
C<=para> block of text paragraph
C<N<>> [^1]: footnote. footnote
C<=Html> <span>text<span> HTML block
C<O<text>> ~~text~~ Strikethrough, "O for Overstrike"
C<H<text>> ^text^ Superscript, "H for High text"
C<J<text>> ~text~ Subscript, "J for Junior text"
C<F<>>, C<=formula> $,$$, ```math Mathematical formulas
=end table
The most common use of Selectors is to create L<table of contents|#Table of contents> and
in L<include block|#Include block>.
=head2 Block types
Podlite offers notations for specifying a wide range of standard block types...
=head3 Headings
Podlite provides an unlimited number of levels of heading, specified by the
C<=head>R<N> block marker. For example:
=begin code
=head1 A Top Level Heading
=head2 A Second Level Heading
=head3 A third level heading
=head86 A "Missed it by I<that> much!" heading
=end code
While Podlite parsers are required to recognize and distinguish all levels
of heading, Podlite renderers are only required to provide distinct
I<renderings> of the first four levels of heading (though they may, of
course, provide more than that). Headings at levels without distinct
renderings would typically be rendered like the lowest distinctly
rendered level.
=head4 Numbered headings
You can specify that a heading is numbered using the C<:numbered> option. For
example:
=begin code
=for head1 :numbered
The Problem
=for head1 :numbered
The Solution
=for head2 :numbered
Analysis
=for head3
Overview
=for head3
Details
=for head2 :numbered
Design
=for head1 :numbered
The Implementation
=end code
which would produce:
=begin nested
1. The Problem
2. The Solution
=begin nested
2.1. Analysis
=begin nested
Overview
Details
=end nested
2.2: Design
=end nested
3. The Implementation
=end nested
It is usually better to preset a numbering scheme for each heading
level, in a series of L<configuration blocks|#Block pre-configuration>:
=begin code :allow<B Z>
B<=config head1 :numbered
Z<>=config head2 :numbered
Z<>=config head3 :!numbered>
=head1 The Problem
=head1 The Solution
=head2 Analysis
=head3 Overview
=head3 Details
=head2 Design
=head1 The Implementation
=end code
Alternatively, as a short-hand, if the first whitespace-delimited word
in a heading consists of a single literal C<#> character, the C<#> is
removed and the heading is treated as if it had a C<:numbered> option:
=begin code
=head1 # The Problem
=head1 # The Solution
=head2 # Analysis
=head3 Overview
=head3 Details
=head2 # Design
=head1 # The Implementation
=end code
Note that, even though renderers are not required to distinctly render
more than the first four levels of heading, they I<are> required to
correctly honour arbitrarily nested numberings. That is:
=begin code
=head6 # The Rescue of the Kobayashi Maru
=end code
should produce something like:
=nested
B<2.3.8.6.1.9. The Rescue of the Kobayashi Maru>
=head3 Ordinary paragraph blocks
Ordinary paragraph blocks consist of text that is to be formatted into
a document at the current level of nesting, with whitespace
squeezed, lines filled, and any special L<inline mark-up|#Markup codes>
applied.
Ordinary paragraphs consist of one or more consecutive lines of text,
each of which starts with a non-whitespace character at (virtual) column
1. The paragraph is terminated by the first blank line or block
directive. For example:
=begin code
=head1 This is a heading block
This is an ordinary paragraph.
Its text will be squeezed and
short lines filled. It is terminated by
the first blank line.
This is another ordinary paragraph.
Its text will also be squeezed and
short lines filled. It is terminated by
the trailing directive on the next line.
=head2 This is another heading block
This is yet another ordinary paragraph,
at the first virtual column set by the
previous directive
=end code
Within a C<=pod>, C<=item>, C<=defn>, C<=nested>, or
L<semantic|#Semantic blocks> block, ordinary paragraphs do not require
an explicit marker or delimiters, but there is also an explicit C<para>
marker (which may be used anywhere):
=begin code :allow<B>
B<=para>
This is an ordinary paragraph.
Its text will be squeezed and
short lines filled.
=end code
and likewise the longer C<=for> and C<=begin>/C<=end> forms. For example:
=begin code :allow<B>
B<=begin para>
This is an ordinary paragraph.
Its text will be squeezed and
short lines filled.
This is I<still> part of the same paragraph,
which continues until an...
B<=end para>
=end code
As the previous example implies, when any form of explicit C<=para> block
is used, any whitespace at the start of each line is removed during rendering.
In addition, within a delimited C<=begin para>/C<=end para> block, any
blank lines are preserved.
=head3 Code blocks
Code blocks are used to specify pre-formatted text (typically source
code), which should be rendered without rejustification, without
whitespace-squeezing, and without recognizing any inline markup
codes. Code blocks also have an implicit L<nesting|#Nesting blocks>
associated with them. Typically these blocks are used to show examples
of code, mark-up, or other textual specifications, and are rendered
using a fixed-width font.
A code block may be implicitly specified as one or more lines of text,
each of which starts with a whitespace character at the block's virtual
left margin. The implicit code block is then terminated by a blank line.
For example:
=begin code
This ordinary paragraph introduces a code block:
$this = 1 * code('block');
$which.is_specified(:by<indenting>);
=end code
Implicit code blocks may only be used within C<=pod>, C<=item>, C<=defn>,
C<=nested>, or L<semantic|#Semantic blocks> blocks.
There is also an explicit C<=code> block (which can be specified within
I<any> other block type, not just C<=pod>, C<=item>, etc.):
=begin code :allow<B>
The C<loud_update()> subroutine adds feedback:
B<=begin code>
sub loud_update ($who, $status) {
say "$who -> $status";
silent_update($who, $status);
}
B<=end code>
=end code
As the previous example demonstrates, within an explicit C<=code> block
the code can start at the (virtual) left margin. Furthermore, lines that
start with whitespace characters after that margin have subsequent
whitespace preserved exactly (in addition to the implicit nesting of the
code). Explicit C<=code> blocks may also contain empty lines.
=head4 Formatting within code blocks
Although C<=code> blocks automatically disregard all L<markup
codes|#Markup codes>, occasionally you may still need to specify
some formatting within a code block. For example, you may wish
to emphasize a particular keyword in an example (using a C<B<>> code). Or
you may want to indicate that part of the example is metasyntactic
(using the C<R<>> code). Or you might need to insert a non-ASCII
character (using the C<E<>> code).
You can specify a list of markup codes that should still be
recognized within a code block using the C<:allow> option. The value of
the C<:allow> option must be a list of the (single-letter) names of one
or more markup codes. Those codes will then remain active inside the
code block. For example:
=begin code
=begin code :allow<B R>
sub demo {
B<say> 'Hello R<name>';
}
=end code
=end code
would be rendered:
=begin code :allow<B R>
sub demo {
B<say> 'Hello R<name>';
}
=end code
Note that the use of the C<:allow> option also makes it possible
for verbatim L<markup codes|#Markup codes> (such as C<C<>>
and C<V<>>) to L<contain other codes as well|#Pre-configuring markup codes>.
=head4 Assign programming language to code blocks
The C<:lang> attribute will be used to provide information about the
programming language used in a particular block of code. This helps
in ensuring that the code is correctly rendered and interpreted by the
renderers or syntax highlighting tools.
For example:
=begin code :allow<B>
=begin code B<:lang<raku>>
sub demo {
say 'Hello R<name>';
}
=end code
=end code
=head3 I/O blocks
Podlite also provides blocks for specifying the input and output of programs.
The C<=input> block is used to specify pre-formatted keyboard input,
which should be rendered without rejustification or squeezing of whitespace.
The C<=output> block is used to specify pre-formatted terminal or file
output which should also be rendered without rejustification or
whitespace-squeezing.
Note that, like C<=code> blocks, both C<=input> and C<=output> blocks have an
implicit level of nesting. They are also like C<=code> blocks in that they
are typically rendered in a fixed-width font, though ideally all three blocks
would be rendered in distinct font/weight combinations (for example: regular
serifed for code, bold sans-serif for input, and regular sans-serif for
output).
Unlike C<=code> blocks, both C<=input> and C<=output> blocks honour any
nested markup codes. This is particularly useful since a sample of
input will often include prompts (which are, of course, output).
Likewise a sample of output may contain the occasional interactive
component. Podlite provides L<special markup codes|#Example specifiers>
(C<K<>> and C<T<>>) to indicate embedded input or output, so you can use
the block type that indicates the overall purpose of the sample (i.e. is
it demonstrating an input operation or an output sequence?) and then use
the "contrasting" markup code within the block.
For example, to include a small amount of input in a sample of output
you could use the C<K<>> markup code:
=begin code :allow<B>
=begin output
Name: Baracus, B.A.
Rank: Sgt
Serial: 1PTDF007
Do you want additional personnel details? B<K<y>>
Height: 180cm/5'11"
Weight: 104kg/230lb
Age: 49
Print? B<K<n>>
=end output
=end code
=head3 Lists
Lists in Podlite are specified as a series of contiguous C<=item> blocks. No
special "container" directives or other delimiters are required to
enclose the entire list. For example:
=begin code
The seven suspects are:
=item Happy
=item Dopey
=item Sleepy
=item Bashful
=item Sneezy
=item Grumpy
=item Keyser Soze
=end code
List items have one implicit level of nesting:
=begin nested
The seven suspects are:
=item Happy
=item Dopey
=item Sleepy
=item Bashful
=item Sneezy
=item Grumpy
=item Keyser Soze
=end nested
Lists may be multi-level, with items at each level specified using the
C<=item1>, C<=item2>, C<=item3>, etc. blocks. Note that C<=item> is just
an abbreviation for C<=item1>. For example:
=begin code
=item1 Animal
=item2 Vertebrate
=item2 Invertebrate
=item1 Phase
=item2 Solid
=item2 Liquid
=item2 Gas
=item2 Chocolate
=end code