Skip to content

Commit

Permalink
Fixes regression noted in #36.
Browse files Browse the repository at this point in the history
  • Loading branch information
hcayless committed Jun 18, 2020
1 parent 86f2d27 commit af3ee68
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/CETEI.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ class CETEI {
}

this.dom = convertEl(XML_dom.documentElement);
this.utilities.dom = this.dom;

this.applyBehaviors();
this.done = true;
Expand Down Expand Up @@ -400,8 +401,8 @@ template(str, elt) {
let replacements;
while (replacements = re.exec(str)) {
if (elt.hasAttribute(replacements[2])) {
if (replacements[1] && utilities[replacements[1]]) {
result = result.replace(replacements[0], utilities[replacements[1]](elt.getAttribute(replacements[2])));
if (replacements[1] && this.utilities[replacements[1]]) {
result = result.replace(replacements[0], this.utilities[replacements[1]](elt.getAttribute(replacements[2])));
} else {
result = result.replace(replacements[0], elt.getAttribute(replacements[2]));
}
Expand Down
4 changes: 2 additions & 2 deletions src/defaultBehaviors.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ export default {
"eg": ["<pre>","</pre>"],
// inserts a link inside <ptr> using the @target; the link in the
// @href is piped through the rw (rewrite) function before insertion
"ptr": ["<a href=\"$rw$first@target\">$@target</a>"],
"ptr": ["<a href=\"$rw@target\">$@target</a>"],
// wraps the content of the <ref> in an HTML link
"ref": [
["[target]", ["<a href=\"$rw$first@target\">","</a>"]]
["[target]", ["<a href=\"$rw@target\">","</a>"]]
],
"graphic": function(elt) {
let content = new Image();
Expand Down
2 changes: 1 addition & 1 deletion src/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export function getPrefixDef(prefix) {
*/
export function rw(url) {
if (!url.match(/^(?:http|mailto|file|\/|#).*$/)) {
return this.base + url;
return this.base + this.utilities.first(url);
} else {
return url;
}
Expand Down
1 change: 0 additions & 1 deletion test/simpleTest.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
CETEIcean.getHTML5('testTEI.xml', function(data) {
document.getElementById("TEI").innerHTML = "";
document.getElementById("TEI").appendChild(data);
CETEIcean.addStyle(document, data);
});

// Alternatively, use then()
Expand Down
2 changes: 1 addition & 1 deletion test/testTEI.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<head>Review</head>
<p>
<title xml:id="foo" xml:lang="de">Die Leiden des jungen Werther</title>
<note place="foot">by <name>Goethe</name></note>
<note place="end">by <name>Goethe</name></note>
is an <emph>exceptionally</emph>
good example of a book full of <term rendition="#italic">Weltschmerz</term>.
Here is some <add>added</add> text.</p>
Expand Down

0 comments on commit af3ee68

Please sign in to comment.