GeertvanGeest / addbioschemas

1 stars 0 forks source link

incorrect HTML tags are created around the script tag which contains the JSON-LD object #5

Open abotzki opened 2 months ago

abotzki commented 2 months ago

for an example see the documentation at

https://github.com/elixir-europe-training/ELIXIR-TrP-Bioschemas/issues/1

GeertvanGeest commented 2 months ago

For some reasons I don't understand everything that gets inserted before the first heading gets incorrectly html opening, body opening and head tags around it:

<html><head>insert</head><body>

It kind of treats is as it were the first html but there's usually head content above it.

Setting priority to 1 results in:

<div><p><script type="application/ld+json">
{
    &ldquo;@context&rdquo;: &ldquo;https://schema.org/&rdquo;,
    &ldquo;@type&rdquo;: &ldquo;LearningResource&rdquo;,
    &ldquo;@id&rdquo;: &ldquo;https://elixir-europe-training.github.io/ELIXIR-TrP-LessonTemplate-MkDocs/&rdquo;,
    &ldquo;http://purl.org/dc/terms/conformsTo&rdquo;: {
        &ldquo;@type&rdquo;: &ldquo;CreativeWork&rdquo;,
        &ldquo;@id&rdquo;: &ldquo;https://bioschemas.org/profiles/TrainingMaterial/1.0-RELEASE&rdquo;
    },
    &ldquo;description&rdquo;: &ldquo;Template for ELIXIR lessons&rdquo;,
    &ldquo;keywords&rdquo;: &ldquo;FAIR, OPEN, Bioinformatics, Teaching&rdquo;,
    &ldquo;name&rdquo;: &ldquo;ELIXIR Training Lesson template&rdquo;,
    &ldquo;license&rdquo;: &ldquo;CC-BY-4.0&rdquo;,
    &ldquo;author&rdquo;: [
        {
            &ldquo;@type&rdquo;: &ldquo;Person&rdquo;,
            &ldquo;name&rdquo;: &ldquo;Geert van Geest&rdquo;,
            &ldquo;email&rdquo;: &ldquo;geert.vangeest@sib.swiss&rdquo;,
            &ldquo;github&rdquo;: &ldquo;GeertvanGeest&rdquo;,
            &ldquo;orcid&rdquo;: &ldquo;0000-0002-1561-078X&rdquo;
        },
        {
            &ldquo;@type&rdquo;: &ldquo;Person&rdquo;,
            &ldquo;name&rdquo;: &ldquo;Elin Kronander&rdquo;,
            &ldquo;github&rdquo;: &ldquo;elinkronander&rdquo;,
            &ldquo;orcid&rdquo;: &ldquo;0000-0003-0280-6318&rdquo;
        }
    ]
}
</script></p>

While we expect:

<script type="application/ld+json">
{
    "@context": "https://schema.org/",
    "@type": "LearningResource",
    "@id": "https://elixir-europe-training.github.io/ELIXIR-TrP-LessonTemplate-MkDocs/",
    "http://purl.org/dc/terms/conformsTo": {
        "@type": "CreativeWork",
        "@id": "https://bioschemas.org/profiles/TrainingMaterial/1.0-RELEASE"
    },
    "description": "Template for ELIXIR lessons",
    "keywords": "FAIR, OPEN, Bioinformatics, Teaching",
    "name": "ELIXIR Training Lesson template",
    "license": "CC-BY-4.0",
    "author": [
        {
            "@type": "Person",
            "name": "Geert van Geest",
            "email": "geert.vangeest@sib.swiss",
            "github": "GeertvanGeest",
            "orcid": "0000-0002-1561-078X"
        },
        {
            "@type": "Person",
            "name": "Elin Kronander",
            "github": "elinkronander",
            "orcid": "0000-0003-0280-6318"
        }
    ]
}
</script>
GeertvanGeest commented 2 months ago

BTW: quick fix would be adding the bioschemas insert after any markdown, so e.g.:

# ELIXIR Lesson Title 

[add-bioschemas file='./docs/training-material.yaml']
GeertvanGeest commented 2 months ago

It seems to be a mkdocs-material issue. Everything works as expected with mkdocs.

GeertvanGeest commented 2 months ago

We might be able to fix it with a postprocessor. However, in that case it is only possible to add one json-LD to a page. I think this covers most (if not all) use-cases.