Broken HTML on Questions page when title contains latex

2.80K viewsIssuesHTML Latex math

We are trialling AnsPress for a Maths student Q&A forum.
Questions have Latex in their titles.
All works fine on the page displaying the question in full.
But on the Questions page where question titles are listed and have a hyperlink on them, the HTML breaks.
This is because the post title is passed to the title attribute of the <a> element.
The title contains an <img> element.
This comes through with its own attributes delimited with double quotes and that gets embedded in the double quotes delimiting the title attribute of the <a> element.
This is what the broken html looks like.

In anspress-question-answer\templates\question-list-item.php
on Line 44 the_title() is passed to the title attribute of the hyperlink.
I have tested this solution which replaces double quotes with single quotes in the_title().
Replace that line with the following:
$title = get_the_title(); // Ge the title as a variable
$title = str_replace(‘”‘, “‘”, $title); // Replace Quotes
<a class=”ap-questions-hyperlink” itemprop=”url” href=”<?php the_permalink(); ?>” rel=”bookmark” title=”<?php echo $title; ?>”><?php echo $title; ?></a>
Do you think you could add this to question-list-item.php as standard?

Asked question