Skip to content

Instantly share code, notes, and snippets.

@dginev
Last active September 3, 2020 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dginev/be5029e8c4ecf095b9abacd78d81aa9a to your computer and use it in GitHub Desktop.
Save dginev/be5029e8c4ecf095b9abacd78d81aa9a to your computer and use it in GitHub Desktop.
Basic example of using HTML+RDFa for annotating MathML
<html>
<body vocab="http://purl.org/dc/terms/">
<math property="subject" content="linear-algebra" typeof="">
<mi property="description" content="prime-number" typeof="">n</mi>
<mo property="description" content="scalar-multiplication">⁢</mo>
<msup>
<mi property="description" content="matrix" typeof="">A</mi>
<mi property="description" content="transpose" typeof="">T</mi>
</msup>
</math>
</body>
</html>
[
{
"@id": "_:Nf768098632bd4b099f61b1f66cd8abbe",
"http://purl.org/dc/terms/description": [
{
"@value": "prime-number"
}
]
},
{
"@id": "_:N408a0e4f025045cc933c4a10f49e5de0",
"http://purl.org/dc/terms/description": [
{
"@value": "matrix"
}
]
},
{
"@id": "_:Ncdd1f89f11754343a3827bb4c7974faf",
"http://purl.org/dc/terms/description": [
{
"@value": "transpose"
}
]
},
{
"@id": "",
"http://www.w3.org/ns/rdfa#usesVocabulary": [
{
"@id": "http://purl.org/dc/terms/"
}
]
},
{
"@id": "_:N58dfa990909f4113ad6fe25f2a54f355",
"http://purl.org/dc/terms/description": [
{
"@value": "scalar-multiplication"
}
],
"http://purl.org/dc/terms/subject": [
{
"@value": "linear-algebra"
}
]
}
]
@dginev
Copy link
Author

dginev commented Sep 3, 2020

Rendered MathML+RDFa formula by Firefox:
image

  1. RDFa using the most basic Dublin Core vocabulary, opaquely marking all mathematical properties as a single "description" string.
  2. JSON-LD extracted through the official W3C pyRDFa showcase

Is this sufficient for baseline search-friendly markup? Are there additional markup needs on the MathML tree itself for search to be fully aided?

@dginev
Copy link
Author

dginev commented Sep 3, 2020

The annotations can be doubtlessly improved in multiple ways - better vocabulary, better use of the vocabulary, better granularity, better interop with existing browser indexing solutions... The main question this Gist wants to pose is whether RDFa is the right specification for this information to reside in.

@dginev
Copy link
Author

dginev commented Sep 3, 2020

Here are the current structured data policies of Google, which indicate focusing on using the schema.org vocabualry, and a preference to coarse-grained metadata via JSON-LD, rather than the fine-grained example I added here. Here is one example for a recipe webpage with structured annotations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment