Michał T. Krawczyk
Michał T. Krawczyk

Reputation: 103

JSON-LD: HTML code examples in the articleBody

In the article, I have a couple of examples of an HTML code (text not images). Should I skipped them and include content without the code examples? I'm using TechArticle and the article content is placed in articleBody.

Upvotes: 1

Views: 1185

Answers (1)

unor
unor

Reputation: 96607

You can include the HTML examples in the articleBody property.

In JSON-LD values, the characters < and > have no special meaning, so the HTML won’t get interpreted, it’s just plain text.

Alternative

If you want to provide metadata about the code examples, or if they are more like attachments instead of inlined, you can use the hasPart property (on Article) to provide SoftwareSourceCode items (bold emphasis mine):

Computer programming source code. Example: Full (compile ready) solutions, code snippet samples, scripts, templates.

While HTML is not a programming language, I think it should be fine to use it for HTML, too. The programmingLanguage property expects a ComputerLanguage value, which says (bold emphasis mine):

This type covers computer programming languages such as Scheme and Lisp, as well as other language-like computer representations.

Upvotes: 2

Related Questions