Skip to main content

Module inline_markup

Module inline_markup 

Source
Expand description

Inline markup parser for ChordPro lyrics text.

ChordPro lyrics can contain inline markup tags for formatting:

  • <bold>text</bold> or <b>text</b> — bold text
  • <italic>text</italic> or <i>text</i> — italic text
  • <highlight>text</highlight> — highlighted text
  • <comment>text</comment> — comment-styled text
  • <span font_family="..." size="..." foreground="...">text</span> — styled text

Tags may be nested: <b><i>text</i></b>.

Unclosed tags wrap all remaining text (per ChordPro spec). Unrecognized or malformed tags are treated as plain text (graceful degradation).

§Examples

use chordsketch_core::inline_markup::{TextSpan, parse_inline_markup};

let spans = parse_inline_markup("<b>Hello</b> world");
assert_eq!(spans, vec![
    TextSpan::Bold(vec![TextSpan::Plain("Hello".to_string())]),
    TextSpan::Plain(" world".to_string()),
]);

Structs§

SpanAttributes
Attributes for a <span> inline markup tag.

Enums§

TextSpan
A segment of text that may contain inline markup formatting.

Functions§

has_inline_markup
Returns true if the input text contains any inline markup tags.
parse_inline_markup
Parses inline markup tags from text and returns a list of TextSpans.
spans_to_plain_text
Extracts the plain text content from a list of spans, stripping all markup.