Display note title even if first line is just an opening HTML tag

https://forums.zotero.org/discussion/28857/#Item_14
This commit is contained in:
Dan Stillman 2013-04-14 19:14:46 -04:00
parent d0d0f14edb
commit f7c3a29a57

View file

@ -36,9 +36,21 @@ Zotero.Notes = new function() {
* Return first line (or first MAX_LENGTH characters) of note content
**/
function noteToTitle(text) {
text = Zotero.Utilities.trim(text);
var origText = text;
text = text.trim();
text = Zotero.Utilities.unescapeHTML(text);
// If first line is just an opening HTML tag, remove it
//
// Example:
//
// <blockquote>
// <p>Foo</p>
// </blockquote>
if (/^<[^>\n]+[^\/]>\n/.test(origText)) {
text = text.trim();
}
var max = this.MAX_TITLE_LENGTH;
var t = text.substring(0, max);