markup library

Inline-markup rendering for Project Fluent.

Translators write HTML5-shaped tags inside messages (welcome = Hello, <bold>{ $name }</bold>!); this barrel turns a resolved message into a FluentSpan tree you can walk to build any UI. Importing it pulls in package:html (the Dart team's HTML5 parser); consumers that don't import it pay nothing.

import 'package:fluent_bundle/fluent_bundle.dart';
import 'package:fluent_bundle/markup.dart';

final spans = bundle.formatMessageAsSpans('welcome', args: {'name': 'Aria'});

Tag names are arbitrary — Fluent doesn't define them — with one carve-out from the HTML5 grammar this parser follows: VOID element names (link, br, img, meta, ...) parse as childless, so a <link>...</link> loses its children to sibling text. Pick non-void names (<a>, <cta>, <bold>).

The span tree is pure Dart. The Flutter adapter that maps it to TextSpan / WidgetSpan lives in the fluent_flutter satellite (package:fluent_flutter/markup.dart), not in this barrel.

Classes

FluentMarkupSpan
A markup tag wrapping zero or more child spans.
FluentSpan
A piece of a formatted message that may contain inline markup.
FluentTextSpan
A run of plain text in a message.

Extensions

FluentMarkupFormatting on FluentBundle
Adds span-tree rendering of inline markup to FluentBundle.

Functions

parseFluentMarkup(String resolvedText) List<FluentSpan>
Parse a resolved Fluent message string into a span tree.