Skip to content

Commit

Permalink
Merge pull request #617 from veraPDF/semantic_annot
Browse files Browse the repository at this point in the history
WCAG validation. Add SemanticAnnot
  • Loading branch information
MaximPlusov authored and Git User committed Dec 6, 2023
1 parent 6eb1389 commit a1788e1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,8 @@ protected void parseChildren() {
}
} else if (element instanceof PDOBJRDictionary) {
COSObject obj = ((PDOBJRDictionary)element).getReferencedObject();
if (obj != null && obj.getType() == COSObjType.COS_DICT &&
GFSAAnnotation.LINK.equals(obj.getNameKeyStringValue(ASAtom.SUBTYPE))) {
getNode().addChild(new GFSAAnnotationNode(new PDAnnotation(obj)));
if (obj != null && obj.getType() == COSObjType.COS_DICT) {
getNode().addChild(new SemanticAnnot(new GFSAAnnotationNode(new PDAnnotation(obj))));
}
} else if (element instanceof COSObject && ((COSObject)element).getType() == COSObjType.COS_INTEGER) {
chunks.addAll(getChunks(getPageObjectNumber(), (((COSObject)element).getDirectBase()).getInteger()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.verapdf.gf.model.impl.sa.*;
import org.verapdf.wcag.algorithms.entities.IAttributesDictionary;
import org.verapdf.wcag.algorithms.entities.INode;
import org.verapdf.wcag.algorithms.entities.SemanticAnnot;

import java.io.IOException;
import java.util.Objects;
Expand Down Expand Up @@ -34,7 +35,7 @@ public void serialize(GFSAStructElem elem, JsonGenerator jsonGenerator, Serializ
jsonGenerator.writeNumberField("rowSpan", AttributesDictionary.getRowSpan());
jsonGenerator.writeEndObject();
}
if (!elem.getChildren().isEmpty()) {
if (!elem.getChildren().isEmpty() || !elem.getNode().getChildren().isEmpty()) {
jsonGenerator.writeFieldName("children");
jsonGenerator.writeStartArray();
for (Object child : elem.getChildren()) {
Expand All @@ -49,8 +50,8 @@ public void serialize(GFSAStructElem elem, JsonGenerator jsonGenerator, Serializ
}
}
for (INode child : elem.getNode().getChildren()) {
if (child instanceof GFSAAnnotationNode) {
jsonGenerator.writeObject(child);
if (child instanceof SemanticAnnot) {
jsonGenerator.writeObject(((SemanticAnnot)child).getAnnots().get(0));
}
}
jsonGenerator.writeEndArray();
Expand Down

0 comments on commit a1788e1

Please sign in to comment.