FLM Feature flm.feature.numbering¶
Counter management and numbering for FLM document elements.
Provides counters for figures, equations, section headings, theorems, and other numbered elements. Supports hierarchical numbering (e.g. equations numbered within sections), counter aliases for shared numbering, and document-state-aware counter resets.
- class flm.feature.numbering.Counter(counter_formatter, initial_value=0)¶
Bases:
objectA basic counter that can be incremented, reset, and formatted using a
CounterFormatter.The counter holds an integer value starting at initial_value (default
0). Callingstep()increments the value by one and returns the new value.- set_value(value)¶
- step()¶
- reset()¶
- format_flm(value=None, **kwargs)¶
- step_and_format_flm()¶
- class flm.feature.numbering.CounterAlias(counter_formatter, alias_counter)¶
Bases:
objectA counter proxy that delegates stepping and resetting to another
Counterinstance while using its own formatter.This is useful when two different element types share the same underlying counter but need distinct display formatting.
- property value¶
- step()¶
- reset()¶
- format_flm(value=None, **kwargs)¶
- step_and_format_flm()¶
- flm.feature.numbering.get_document_render_counter(render_context, counter_name, counter_formatter, alias_counter=None, always_number_within=None)¶
Obtain or create a counter interface for the current render context.
When the
numberingfeature is enabled, the counter is registered throughFeatureNumbering.RenderManagerwhich supports hierarchical numbering and document-state resets. Otherwise a lightweightCounter(orCounterAlias) is created directly.- Parameters:
render_context – The active
FLMRenderContext.counter_name – A unique name identifying this counter (e.g.
'equation','section').counter_formatter – A
CounterFormatterfor displaying counter values.alias_counter – If provided, the returned counter shares its underlying value with alias_counter (a counter interface previously returned by this function or by
RenderManager.register_counter).always_number_within – A dict with keys
'reset_at'and'numprefix'that forces hierarchical numbering. Requires thenumberingfeature; raisesValueErrorotherwise.
- Returns:
A counter interface object with a
register_item()method.
- class flm.feature.numbering.FeatureNumbering(number_within: Mapping[str, TypeNumberWithinDef] | None = None)¶
Bases:
FeatureFeature that manages counters for numbered document elements. Supports hierarchical numbering via
number_withinconfiguration, which resets and prefixes counters based on parent counter values (e.g. equations numbered within sections).- feature_title: str | None = 'Numbering for figures, sections, equations, theorems, and more'¶
Descriptive name or title for this feature.
- class RenderManager(feature_document_manager, render_context, **kwargs)¶
Bases:
FeatureRenderManagerBase- register_counter(counter_name, counter_formatter, *, alias_counter=None, always_number_within=None, use_doc_state_keys=None, numprefix_for_doc_state_fn=None, value_for_doc_state_fn=None)¶
- compute_use_doc_state_keys(counter_name)¶
- set_render_doc_state(state_type, state_value, clear_self_upon_change=None)¶
- clear_render_doc_state(state_type)¶
- register_item(counter_name, custom_label=None)¶
- get_formatted_counter_value(counter_name, **kwargs)¶
- flm.feature.numbering.FeatureClass = <class 'flm.feature.numbering.FeatureNumbering'>¶
Feature that manages counters for numbered document elements. Supports hierarchical numbering via
number_withinconfiguration, which resets and prefixes counters based on parent counter values (e.g. equations numbered within sections).