Skip to content

Commit

Permalink
Set the aria attribute directly in SVG preview
Browse files Browse the repository at this point in the history
  • Loading branch information
iherman committed Aug 14, 2023
1 parent 896693f commit c157270
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
15 changes: 4 additions & 11 deletions previews/vcdm/vocabulary.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,14 @@
const p = sotd.getElementsByTagName('p')[0];
sotd.removeChild(p);
}

// Note: The vocabulary URL must be adapted for the given environment!!!!
// Note: The vocabulary URL must be adapted for the given environment!!!!
function massageSVGLinks(utils, content, url) {
const retval = content
.replace(/xlink:href/g, 'href')
.replace(/href="https:\/\/w3.org\/2018\/credentials#/g, 'href="#');
return retval;
}

// Add the ARIA attribute to the svg element.
function add_svg_aria() {
const svg = document.getElementsByTagName('svg')[0];
svg.setAttribute("aria-details","#vocabulary-diagram-alt");
}

</script>
<script class="remove">
var respecConfig = {
Expand Down Expand Up @@ -69,7 +62,7 @@
{uri: "vocabulary.ttl", label: "Turtle"},
{uri: "vocabulary.jsonld", label: "JSON-LD"}
],
postProcess : [remove_status_remark, add_svg_aria],
postProcess : [remove_status_remark],
inlineCSS: true,
doRDFa: false,
noIDLIn: true,
Expand Down Expand Up @@ -174,14 +167,14 @@ <h2>Specification of terms</h2>
The diagram is exported into SVG, and then the following editorial changes should be done (using any text editor):
- The "width" and "height" attributes in the top level <svg> element must be removed (to make the diagram rescale if
viewed directly)
- add the aria-details="#vocabulary-diagram-alt" attribute to the top level svg element
The exported SVG can also be viewed and edited inkscape. (The reason draw.io is used, instead of using
exclusively inkscape, is because the connecting line feature of inkscape is buggy.)
-->
<div data-include="vocabulary.svg" data-include-replace="true" data-oninclude="massageSVGLinks"></div>
<figcaption>Overview diagram of the vocabulary (without the deprecated items).<br>
A separate, stand-alone <a href="vocabulary.svg" target="_blank">SVG version</a> of the diagram,
as well as a <a href="#vocabulary-diagram-alt">textual description</a>,
A separate, stand-alone <a href="vocabulary.svg" target="_blank">SVG version</a> of the diagram, as well as a <a href="#vocabulary-diagram-alt">textual description</a>,
are also available.
</figcaption>
</figure>
Expand Down
3 changes: 2 additions & 1 deletion previews/vcdm/vocabulary.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c157270

Please sign in to comment.