I am trying to make a simple text formatter using MigraDoc for actually typesetting the text. I'd like to specify formatting by marking up the text. For example, the input might look something like this:
"The \i{quick} brown fox jumps over the lazy dog^{note}"
which would denote "quick" being italicized and "note" being superscript.
To make the splits I have made a dictionary in my TextFormatter
:
internal static TextFormatter()
{
FormatDictionary = new Dictionary<string, TextFormats>()
{
{@"^", TextFormats.supersript},
{@"_",TextFormats.subscript},
{@"\i", TextFormats.italic}
};
}
I'm then hoping to split using some regexes that looks for the modifier strings and matches what is enclosed in braces.
But as multiple formats can exist in a string, I need to also keep track of which regex was matched. E.g. getting a List<string, TextFormats>
, (where string
is the enclosed string, TextFormats
is the TextFormats value corresponding to the appropriate special sequence and the items are sorted in order of appearance), which I could then iterate over applying formatting based on the TextFormats
.
Thank you for any suggestions.