Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(closes #131) Embed YAML-LD into HTML <script> tag #132

Merged
merged 6 commits into from
Apr 3, 2024

Conversation

anatoly-scherbakov
Copy link
Contributor

@anatoly-scherbakov anatoly-scherbakov commented Feb 3, 2024

We should be able to embed YAML-LD scripts into HTML documents, as described in #131.


Preview | Diff

Copy link
Member

@gkellogg gkellogg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note the comment about the need to unindent a stream. Probably not necessary for documents in general.

spec/index.html Show resolved Hide resolved
spec/index.html Outdated Show resolved Hide resolved
@anatoly-scherbakov
Copy link
Contributor Author

@gkellogg I do recall that we probably can't merge PRs to the spec right now. Should we keep these PRs open?

Or maybe we should discuss this on the upcoming CG meeting?

@gkellogg
Copy link
Member

gkellogg commented Feb 4, 2024

Yes, I think we need to keep this open. Let's discuss how we move forward on the next call, but I think it requires a WG action and probably needs to await the outcome of an updated WG charter.

Copy link
Contributor

@TallTed TallTed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merging this should trigger a run of PR-Preview, which should now succeed

spec/index.html Outdated Show resolved Hide resolved
@gkellogg
Copy link
Member

gkellogg commented Apr 3, 2024

The JSON-LD WG discussed this today and suggested that work on the YAML-LD editor's draft can proceed.

@gkellogg gkellogg merged commit 1165a89 into main Apr 3, 2024
2 checks passed
@gkellogg gkellogg deleted the 131-yaml-under-script-html-tag branch April 3, 2024 20:02
@VladimirAlexiev
Copy link
Contributor

@anatoly-scherbakov

YAML syntax is indentation based.

Can you make this more forceful to say something like "leave spaces and newlines alone" or "don't mangle spaces and newlines".

Before processing each <script> block with YAML-LD content, YAML-LD processor MUST dedent the body of the block using the following procedure:

Afaik, no such dedenting is needed. I loaded your example to YAML Playground and played with the global indentation. Look at the parse events in the "New Reference Parser (JS)" pane: they remain the same.

@VladimirAlexiev
Copy link
Contributor

@gkellogg (cc @TallTed)

Note the comment about the need to unindent a stream. Probably not necessary for documents in general.

Yes! See my comment above. More explicitly:

  • the stream separator --- must be at beginning of line
  • the global indentation of the docs does not matter.

This version of @anatoly-scherbakov's example returns the same parse events as the original version:

  "@context": https://json-ld.org/contexts/person.jsonld
  "@id": http://dbpedia.org/resource/John_Lennon
  name: John Lennon
  born: 1940-10-09
  spouse: http://dbpedia.org/resource/Cynthia_Lennon
---
  "@context": https://json-ld.org/contexts/person.jsonld
  "@id": http://dbpedia.org/resource/Cynthia_Lennon
  born: 1939-09-10

So @anatoly-scherbakov I don't think we should require HTML parsers to dedent scripts.
We should only:

  • require them to leave newlines and spaces alone
  • advise users that it's best for the global indent to be 0, and that is required for the stream separator ---

@VladimirAlexiev
Copy link
Contributor

@anatoly-scherbakov I have a silly concern, but let's honor the life of a great man:
John was married to Cynthia for just 6 years, then married Yoko for the rest of his life.

So can you change the spouse to:
http://dbpedia.org/resource/Yoko_Ono (born 1933-02-18)

@TallTed
Copy link
Contributor

TallTed commented Apr 4, 2024

YAML syntax is indentation based.

Syntactically-important, human-invisible whitespace is evil. I cannot tell you how long it has sometimes taken to clean up Oracle configuration files, when one person indented some lines with spaces, and another person indented with tabs.

I am glad that later comments suggest that whitespace is less important ("don't think we should require HTML parsers to dedent scripts"), but "[requiring] them to leave newlines and spaces alone" seem to say that some whitespace is important?

This is confusing. But maybe it's just this conversation that's confusing, and the docs will be clear, in the end?

@anatoly-scherbakov
Copy link
Contributor Author

Yes, I have revised my own https://github.com/iolanta-tech/python-yaml-ld implementation and it works without dedenting anything. I do not, by this moment, remember why I wanted to dedent 🤔

Creating new issues for these. Thank you for pointing them out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants