A labeled span for annotating source code in diagnostics.
Labels combine a span with a message and visual priority. They are used to
highlight specific regions of source code and explain what's happening there.
Priority
Labels have two priority levels:
:primary - The main error location, highlighted prominently (typically red):secondary - Supporting context, highlighted less prominently (typically yellow)
Multi-file Diagnostics
For diagnostics that span multiple files, set the :source field to identify
which file this label refers to. The rich formatter renders such labels as
continuation frames (├─[file:line:col]) against their own file, inside the
same diagnostic frame — provide content for every labeled file in the sources
passed to Pentiment.format/3, or the foreign group renders header-only.
A label whose :source equals the report's source behaves exactly as if it
were nil.
Examples
# Primary label at the error site
Label.primary(span, "expected `integer`, found `float`")
# Secondary label showing related context
Label.secondary(decl_span, "declared as `integer` here")
# Label in a different file
Label.primary(span, "error here", source: "lib/other.ex")