-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Turn TEI elements with 'ref' attribute into links #20
Comments
We don't define a default behavior for this for the simple reason that CETEIcean behaviors are not the equivalent of a full transformation language like XSLT, but you could use them to do this—you'd need a separate behavior for each type of document.querySelectorAll('*[ref]').forEach(el) {
// Add a click event listener to the element
} and then use CSS to make it evident in the UI that they're clickable. One of the reasons for not attempting to turn behaviors into a fuller language is because it's so easy to do DOM manipulation in JS anyway. |
Thanks for the detailed reply!
That didn't stop you from handling ptr's @target :)
And that's a good thing!
To avoid code duplication I added the following at the end of if (newElement.hasAttribute("ref")) {
let link = document.createElement("a");
link.setAttribute("href", this.rw(newElement.getAttribute("ref")));
link.appendChild(newElement);
return link;
} else
return newElement;
}
Thanks! I'll try doing something like that after I learn some Javascript :). Thank you for developing CETEIcean! It is flexible enough for my purposes and is much easier than TEI-BP (at least for me) to integrate with the rest of the site (CSS, headers, footers etc.). |
I ended up adding behaviors specific to my application. |
I need TEI elements that have
ref
attribute (e.g.,persName
) to render as (clickable) HTML links.With TEI-BP, I added a custom XSLT template that wraps such elements in HTML
<a>
withhref
value copied from the TEI'sref
attribute:How do I achieve similar results using CETEIcean?
Do I need to tweak CETEI.js? Add some behavior? Use CSS?
Since neither TEI-BP nor CETEIcian perform this obviously useful transformation
out-of-the-box (as far as I know), maybe I am just encoding my documents incorrectly?
What is the idiomatic TEI way of achieving this result?
Thanks!
The text was updated successfully, but these errors were encountered: