Documentation
¶
Index ¶
- func GetInitialConfigSelections(markdown string) map[string]string
- func MatchesTCPPattern(tcp, pattern string) bool
- func ProcessConfigSelections(markdown string, selectedConfig func(group string) string, ...) string
- type AnnotatedVertex
- type AnnotationType
- type ConfigOption
- type ConfigurationsNode
- type DocMapExtension
- type DocMapNode
- type ErrorNode
- type MapAnnotation
- type ParseOptions
- type ParsedMarkdown
- type TableCaption
- type VideoMapBlock
- type WaypointAnnotation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetInitialConfigSelections ¶
GetInitialConfigSelections parses the brief to discover its configurations blocks and returns a map from each group name to its default (first) option name.
func MatchesTCPPattern ¶
MatchesTCPPattern reports whether a controller TCP matches a pattern. Patterns may end in '*' for a prefix wildcard ("5*" matches "5A", "5B", etc.); otherwise the pattern matches the TCP exactly. Exported so callers can implement ParseOptions.MatchesUserTCP with consistent semantics.
func ProcessConfigSelections ¶
func ProcessConfigSelections(markdown string, selectedConfig func(group string) string, isActiveAirport func(string) bool, matchesUserTCP func(string) bool) string
ProcessConfigSelections preprocesses markdown by removing the contents of `::: if NAME[,NAME...]` blocks whose condition does not match. Match logic (OR across the comma-separated names):
- NAME is `group:tag` and `selectedConfig(group) == tag`
- NAME is an ICAO code for which `isActiveAirport(NAME)` returns true
- NAME is `tcp:PATTERN` and `matchesUserTCP(PATTERN)` returns true
Any callback may be nil; nil treats that branch as a non-match. When all callbacks are nil, the input is returned unchanged.
Types ¶
type AnnotatedVertex ¶
type AnnotatedVertex struct {
Point math.Point2LL
Annotation *WaypointAnnotation // nil if there is no annotation
}
AnnotatedVertex holds a coordinate point and its optional annotation.
type AnnotationType ¶
type AnnotationType int
AnnotationType specifies the type of map annotation.
const ( AnnotationLine AnnotationType = iota AnnotationArrow AnnotationPolygon AnnotationFix AnnotationPoint AnnotationAirspace // Per-controller airspace boundaries )
type ConfigOption ¶
type ConfigOption struct {
Name string // Option tag (the part after "group:" in `::: if group:tag`)
Label string // Display label shown in UI
}
ConfigOption represents a single configuration option with internal name and display label.
type ConfigurationsNode ¶
type ConfigurationsNode struct {
ast.BaseBlock
Name string // Name identifier for this configuration block
Options []ConfigOption // Configuration options
}
ConfigurationsNode represents a list of configuration options. Rendered as radio buttons. Names must be unique within a brief.
func NewConfigurationsNode ¶
func NewConfigurationsNode(name string, options []ConfigOption) *ConfigurationsNode
NewConfigurationsNode creates a new ConfigurationsNode.
func (*ConfigurationsNode) Dump ¶
func (n *ConfigurationsNode) Dump(source []byte, level int)
func (*ConfigurationsNode) Kind ¶
func (n *ConfigurationsNode) Kind() ast.NodeKind
type DocMapExtension ¶
type DocMapExtension struct {
// contains filtered or unexported fields
}
DocMapExtension is a goldmark extension that transforms links with VideoMapBlock targets into custom AST nodes.
func NewDocMapExtension ¶
func NewDocMapExtension() *DocMapExtension
NewDocMapExtension creates a new DocMapExtension.
func (*DocMapExtension) Extend ¶
func (e *DocMapExtension) Extend(m goldmark.Markdown)
Extend implements goldmark.Extender.
type DocMapNode ¶
type DocMapNode struct {
ast.BaseBlock
DocMap *VideoMapBlock
Label string
}
DocMapNode is a custom AST node representing a VideoMapBlock. It's a block-level node that replaces inline link syntax.
func (*DocMapNode) Dump ¶
func (n *DocMapNode) Dump(source []byte, level int)
func (*DocMapNode) Kind ¶
func (n *DocMapNode) Kind() ast.NodeKind
type ErrorNode ¶
ErrorNode carries a parse-time error message that is inserted into the AST at the point of discovery so it can be rendered inline next to the offending block instead of in a separate top-of-document list.
type MapAnnotation ¶
type MapAnnotation struct {
Type AnnotationType // Type of annotation (line, arrow, polygon, fix, point, airspace)
Vertices []AnnotatedVertex // Coordinates with optional annotations (single vertex for fix/point)
Label []string // Multi-line text label
AirspaceTCPs []string // For AnnotationAirspace; empty = user's consolidated positions
}
MapAnnotation represents a drawable element on a video map.
type ParseOptions ¶
type ParseOptions struct {
// SelectedConfig returns the currently-selected option tag for the given
// configurations group (e.g. "13" for group "dep"). An empty return value
// means no option is selected, which never matches a `::: if dep:tag`
// condition. nil treats no group as selected.
SelectedConfig func(group string) string
// IsActiveAirport reports whether the given ICAO is an airport with
// non-VFR traffic in the current scenario. Used to match `::: if KJFK`
// blocks. nil treats no airports as active.
IsActiveAirport func(icao string) bool
// MatchesUserTCP reports whether any TCP the user covers matches the
// supplied pattern (e.g. "1*", "2A"). Used to match `::: if tcp:1*`
// blocks. nil treats no patterns as matching.
MatchesUserTCP func(tcpPattern string) bool
}
ParseOptions configures the validation and filtering passes ParseMarkdown runs. Every field is optional; a nil callback disables the corresponding check or match. Selection state, airport activity, and TCP coverage are all supplied as caller-defined callbacks so the brief package never needs to know how the client tracks them.
type ParsedMarkdown ¶
type ParsedMarkdown struct {
// contains filtered or unexported fields
}
ParsedMarkdown holds a parsed markdown AST and any errors collected during parsing and validation.
func ParseMarkdown ¶
func ParseMarkdown(content []byte, o ParseOptions) *ParsedMarkdown
ParseMarkdown parses markdown content, runs the line-based ::: if/endif preprocessor with the supplied selection state, and parses the result with goldmark. Block-scoped errors are embedded as *ErrorNode siblings of the offending block in the returned AST so they can be rendered inline. Preprocessor-level errors (those produced before goldmark sees the source, where no AST node exists yet) are returned by ParseErrors().
func (*ParsedMarkdown) ParseErrors ¶
func (p *ParsedMarkdown) ParseErrors() []string
ParseErrors returns preprocessor-level errors that have no AST representation (malformed ::: if/endif structure, undefined config references, etc.). Block-scoped errors are embedded in the AST as *ErrorNode siblings of the offending block; walk the AST to surface those.
func (*ParsedMarkdown) Source ¶
func (p *ParsedMarkdown) Source() []byte
Source returns the (possibly preprocessed) markdown content the AST was built from.
func (*ParsedMarkdown) VideoMapFiles ¶
func (p *ParsedMarkdown) VideoMapFiles() []string
VideoMapFiles returns the distinct video map file paths referenced by videomap blocks in the (selection-filtered) brief, in source order.
type TableCaption ¶
TableCaption represents a caption for a table.
func (*TableCaption) Dump ¶
func (n *TableCaption) Dump(source []byte, level int)
func (*TableCaption) Kind ¶
func (n *TableCaption) Kind() ast.NodeKind
type VideoMapBlock ¶
type VideoMapBlock struct {
File string
Maps []string
Annotations []MapAnnotation
Extent [2]math.Point2LL // Optional extent (upper-left, lower-right)
Width int // Width as percentage (1-100), default 100
}
VideoMapBlock represents an annotated video map embedded in scenario brief markdown using a fenced "videomap" code block.
func (*VideoMapBlock) Validate ¶
func (m *VideoMapBlock) Validate() []string
Validate runs structural checks that do not depend on caller-side state: file present, at least one map specified, and per-annotation vertex counts. Cross-reference checks (map existence in the named file, airspace TCP existence) are driven by callbacks at ParseMarkdown time; see HasMap and HasAirspaceTCP on ParseOptions.
type WaypointAnnotation ¶
type WaypointAnnotation struct {
ClimbAltitude int // Altitude to climb to (0 if not specified)
DescentAltitude int // Altitude to descend to (0 if not specified)
}
WaypointAnnotation holds an annotation associated with a waypoint.