Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YAPP ignores subscripts/superscripts, causing misleading required parts of answer #50

Closed
hftf opened this issue Mar 4, 2024 · 2 comments · Fixed by #51
Closed

YAPP ignores subscripts/superscripts, causing misleading required parts of answer #50

hftf opened this issue Mar 4, 2024 · 2 comments · Fixed by #51
Assignees
Labels
bug Something isn't working

Comments

@hftf
Copy link
Collaborator

hftf commented Mar 4, 2024

Here are 4 examples just from two adjacent packets:

  1. The 2 should be underlined in Packet 8, bonus 13
    Packet: N2O
    YAPP:   N2O (“N-2-O”) [or nitrous oxide] ⇐ <b><u>N</u>2<u>O</b></u> (“N-2-O”) [or <b><u>nitrous oxide</b></u>]
  2. But for some reason the 2 is underlined correctly here
    Packet: NO2
    YAPP:   NOx (“nox”) compounds [accept NO AND NO2<b><u>NOx</b></u> (“nox”) compounds [accept <b><u>NO</b></u> AND <b><u>NO2</b></u>
    Screen Shot 2024-03-04 at 05 52 57
  3. The 2 should be underlined in Packet 7, bonus 9
    Packet: CO2
    YAPP:   CO2 (“C-O-2”) [or carbon dioxide] ⇐ <b><u>CO</u>2</b> (“C-O-2”) [or <b><u>carbon dioxide</b></u>]
  4. The 2 should be underlined
    Packet: H2
    YAPP:   hydrogen [or H2 (“H-2”)] ⇐ <b><u>hydrogen</b></u> [or <b><u>H</u>2 </b>(“H-2”)]
    Screen Shot 2024-03-04 at 06 21 15

For what it's worth, I have strongly recommended against any use at all of subscripts/superscripts in quizbowl packets for many years, and this issue demonstrates two of the reasons: they mislead about the required parts of answers and interact poorly with underlining, and technology is often not designed to handle them correctly. Like #49, this issue should be classed high severity.

Note also that invalid tag nesting is produced throughout: <b><u>hydrogen</b></u>. Can file a separate issue for this if you want, but it's possibly the same root issue. See:

private static void WriteFormattedText(FormattedText node, StringBuilder builder)
{
Verify.IsNotNull(node, nameof(node));
if (!node.Segments.Any())
{
return;
}
bool previousBolded = false;
bool previousItalic = false;
bool previousUnderlined = false;
foreach (FormattedTextSegment segment in node.Segments)
{
if (previousBolded ^ segment.Bolded)
{
builder.Append(segment.Bolded ? "<b>" : "</b>");
previousBolded = segment.Bolded;
}
if (previousUnderlined ^ segment.Underlined)
{
builder.Append(segment.Underlined ? "<u>" : "</u>");
previousUnderlined = segment.Underlined;
}
if (previousItalic ^ segment.Italic)
{
builder.Append(segment.Italic ? "<em>" : "</em>");
previousItalic = segment.Italic;
}
builder.Append(segment.Text);
}
// Close any remaining tags
if (previousBolded)
{
builder.Append("</b>");
}
if (previousUnderlined)
{
builder.Append("</u>");
}
if (previousItalic)
{
builder.Append("</em>");
}
}
}
}

@alopezlago
Copy link
Owner

I've been meaning to file a bug and fix super/subscript issues for a while and never got around to it. We have to read the super/sub script tags from docx and from HTML to know that it exists, persist that information, and then write it later (and have MODAQ know about super and subscript tags). I don't really care that much about mixing the tag ordering that much, but I could fix it separately.

@alopezlago alopezlago added the bug Something isn't working label Mar 5, 2024
@alopezlago alopezlago self-assigned this Mar 10, 2024
@alopezlago
Copy link
Owner

This will be fixed in the next version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants