{% case node.type %} {% when 'xref' %} {% if node.text %} {{ node.text }} {% elsif node.document.references.refs[node.attributes.refid] %} {{ node.document.references.refs[node.attributes.refid].xreftext }} {% else %} [{{ node.attributes.refid }}] {% endif %} {% when 'ref' %} {% when 'link' %} {{ node.text }} {% when 'bibref' %} [{{ node.xreftext | default: node.id }}] {% endcase %}