Skip to content

Commit

Permalink
Decode HTML in search result highlights and abstract comments
Browse files Browse the repository at this point in the history
  • Loading branch information
shinyichen committed May 20, 2021
1 parent ced0e1f commit 94a255e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/js/widgets/abstract/templates/abstract_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ <h4 class="sr-only">Abstract</h4>
{{/if}} {{#if comment}}
<dt>Comments:</dt>
<dd>
{{ comment }}
{{{ comment }}}
</dd>
{{/if}} {{#if pubnote}}
<dt>E-Print Comments:</dt>
Expand Down
13 changes: 13 additions & 0 deletions src/js/widgets/list_of_things/item_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ define([
},

render: function() {
// // a hacky way to decode html in highglights
// if (this.model.get('highlights')) {
// const highlights = this.model.get('highlights');
// this.model.set(
// 'highlights',
// highlights.map((h) =>
// $('<textarea/>')
// .html(h)
// .text()
// )
// );
// }

if (this.model.get('visible')) {
return Marionette.ItemView.prototype.render.apply(this, arguments);
}
Expand Down
7 changes: 7 additions & 0 deletions src/js/widgets/list_of_things/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,13 @@ define([
if (docs && docs.length) {
// make sure the new docs close highlights if they aren't there
var newDocs = _.map(docs, function(d) {
if (d.highlights) {
d.highlights = d.highlights.map((h) =>
$('<textarea/>')
.html(h)
.text()
);
}
return _.extend(d, {
showHighlights: typeof d.highlights !== 'undefined',
showCheckbox: !!self.model.get('showCheckboxes'),
Expand Down

0 comments on commit 94a255e

Please sign in to comment.