format

fun format(location: SectionLocation, allowMismatchingLength: Boolean = true): String

Converts the numbering format into a string. For example, the NumberingFormat 1.A.a would format the levels 1, 1, 0 as 2.B.a.

In case SectionLocation.levels and symbols have different lengths, (i.e. SectionLocation.depth is different from accuracy), the output will be truncated to the shortest of the two: for example, 1.A.a formats the levels 1, 1, 0, 0 as 2.B.a, and the levels 1, 1 as 2.B.

In case depth is less than accuracy, trailing fixed symbols are ignored. For example, the format (1.1) will format correctly the levels 1, 2 as (1.2), but 1 will be wrongly truncated to (1.

Return

the formatted string

Parameters

location

location to format. For example, when it comes to numbering headings, the level [1, 1, 0] correspond to:

# A
## A.A
# B
## B.A
## B.B
### B.B.A <-- This is the target level!
# C
allowMismatchingLength

if false, the result string is empty if the current format's length is too short to cover the nesting level of location. If true, the result is truncated to the format's length.


fun format(level: Int): String

Formats a single level of numbering. Use case: footnotes, which don't expect a nested structure.

Parameters

level

level to format

See also