Skip to content

Commit

Permalink
Merge pull request #221 from acdh-oeaw/tei-styles
Browse files Browse the repository at this point in the history
Render TEI annotations
  • Loading branch information
gythaogg authored Dec 9, 2024
2 parents ef4ba9a + bcaf031 commit 191843d
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
62 changes: 62 additions & 0 deletions apis_ontology/static/scripts/show_popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,42 @@ let behaviors = {
}
return result;
},
// Handle the LG element
"lg": function(e) {
let result = document.createElement("quote"); // Use a <div> for segments
result.classList.add("lg");

// Process child nodes and append
for (let n of Array.from(e.childNodes)) {
// Call the appropriate behavior for each child node
let behavior = behaviors.tei[n.nodeName.toLowerCase()];
if (behavior) {
result.appendChild(behavior(n)); // Process child nodes based on their type
} else {
result.appendChild(n.cloneNode(true)); // Clone nodes that don't have specific behavior
}
}
return result;
},

// Handle the LG element
"l": function(e) {
let result = document.createElement("div"); // Use a <div> for segments
result.classList.add("l");

// Process child nodes and append
for (let n of Array.from(e.childNodes)) {
// Call the appropriate behavior for each child node
let behavior = behaviors.tei[n.nodeName.toLowerCase()];
if (behavior) {
result.appendChild(behavior(n)); // Process child nodes based on their type
} else {
result.appendChild(n.cloneNode(true)); // Clone nodes that don't have specific behavior
}
}
return result;
},

"lb": ["<span class=\"break\">$@n&nbsp;</span>"],

// Hyperlink the rs tag and include type and ref in its title
Expand Down Expand Up @@ -43,6 +79,32 @@ let behaviors = {
}
return result;
},

// Handle the unclear element
"unclear": function(e) {
let result = document.createElement("span");
result.classList.add("unclear");
result.textContent = e.textContent;
// using CSS instead
// result.textContent = `(${e.textContent})`;

return result;
},

// Show foreign tag in italics
"foreign": function(e) {
let result = document.createElement("span");
result.classList.add("foreign");
result.textContent = e.textContent;
result.title = e.getAttribute("xml:lang")
return result;
},

// Discard milestone
"milestone": function(e) {
return null;
},

}
};

Expand Down
11 changes: 11 additions & 0 deletions apis_ontology/static/styles/tei.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
.foreign{
font-style: italic;
}
.unclear::before {
content: "(";
}

.unclear::after {
content: ")";
}

.break {
font-family: Arial, Helvetica, sans-serif;
font-size: 80%;
Expand Down

0 comments on commit 191843d

Please sign in to comment.