Fixes #1619, Underline formatting isn't preserved in citation editor
Frank's patch
This commit is contained in:
parent
833ad915f5
commit
18c7e6728f
|
@ -56,8 +56,6 @@
|
||||||
"</strong>":"\\b0 ",
|
"</strong>":"\\b0 ",
|
||||||
"<b>":"\\b ",
|
"<b>":"\\b ",
|
||||||
"</b>":"\\b0 ",
|
"</b>":"\\b0 ",
|
||||||
"<u>":"\\ul ",
|
|
||||||
"</u>":"\\ul0 ",
|
|
||||||
"<br />":"\x0B",
|
"<br />":"\x0B",
|
||||||
"<sup>":"\\super ",
|
"<sup>":"\\super ",
|
||||||
"</sup>":"\\super0 ",
|
"</sup>":"\\super0 ",
|
||||||
|
@ -68,6 +66,19 @@
|
||||||
'<span class="tab"> </span>':"\t"
|
'<span class="tab"> </span>':"\t"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this._rtfRexMap = [
|
||||||
|
["<span style=\"font-variant:small-caps;\">",
|
||||||
|
/small-caps/,
|
||||||
|
"\\scaps ",
|
||||||
|
"\\scaps0 "
|
||||||
|
],
|
||||||
|
["<span style=\"text-decoration:underline;\">",
|
||||||
|
/underline/,
|
||||||
|
"\\ul ",
|
||||||
|
"\\ul0 "
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
this._constructed = true;
|
this._constructed = true;
|
||||||
|
|
||||||
if (this._loadOnConstruct) {
|
if (this._loadOnConstruct) {
|
||||||
|
@ -164,28 +175,29 @@
|
||||||
output = output.replace(needle, this._rtfMap[needle], "g");
|
output = output.replace(needle, this._rtfMap[needle], "g");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Preserve small caps
|
// Preserve small caps and underlining
|
||||||
var l = output.split(/(<\/?span[^>]*>)/);
|
for each (var tagspec in this._rtfRexMap){
|
||||||
var current_level = 0;
|
var l = output.split(/(<\/?span[^>]*>)/);
|
||||||
var tag_level = [];
|
var current_level = 0;
|
||||||
for (var pos=1; pos<l.length; pos+=2) {
|
var tag_level = [];
|
||||||
var tag = l[pos];
|
for (var pos=1; pos<l.length; pos+=2) {
|
||||||
if (tag[1] == "/") {
|
var tag = l[pos];
|
||||||
current_level--;
|
if (tag[1] == "/") {
|
||||||
if (current_level == tag_level[tag_level.length-1]) {
|
current_level--;
|
||||||
tag_level.pop();
|
if (current_level == tag_level[tag_level.length-1]) {
|
||||||
l[pos] = "\\scaps0 ";
|
tag_level.pop();
|
||||||
}
|
l[pos] = tagspec[3];
|
||||||
} else {
|
}
|
||||||
if (l[pos].match(/small-caps/)) {
|
} else {
|
||||||
l[pos] = "\\scaps ";
|
if (l[pos].match(tagspec[1])) {
|
||||||
tag_level.push(current_level);
|
l[pos] = tagspec[2];
|
||||||
}
|
tag_level.push(current_level);
|
||||||
current_level++;
|
}
|
||||||
|
current_level++;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
output = l.join("");
|
||||||
};
|
};
|
||||||
output = l.join("");
|
|
||||||
|
|
||||||
output = output.replace("<p>", "", "g");
|
output = output.replace("<p>", "", "g");
|
||||||
output = output.replace("</p>", "\\par ", "g");
|
output = output.replace("</p>", "\\par ", "g");
|
||||||
output = output.replace(/<\/?div[^>]*>/g, "");
|
output = output.replace(/<\/?div[^>]*>/g, "");
|
||||||
|
@ -258,10 +270,10 @@
|
||||||
html = html.replace(this._rtfMap[needle], needle, "g");
|
html = html.replace(this._rtfMap[needle], needle, "g");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for each (var tagspec in this._rtfRexMap){
|
||||||
html = html.replace("\\scaps ", "<span style=\"font-variant:small-caps\">", "g");
|
html = html.replace(tagspec[2], tagspec[0], "g");
|
||||||
html = html.replace("\\scaps0 ", "</span>", "g");
|
html = html.replace(tagspec[3], "</span>", "g");
|
||||||
|
}
|
||||||
html = '<div style="'+bodyStyle+'"><p>'+html.replace("\par ", "</p><p>")+"</p></div>";
|
html = '<div style="'+bodyStyle+'"><p>'+html.replace("\par ", "</p><p>")+"</p></div>";
|
||||||
Zotero.debug("setting content to "+html);
|
Zotero.debug("setting content to "+html);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user