项目作者: ozekik

项目描述 :
RDF Linked Data in Markdown
高级语言: JavaScript
项目地址: git://github.com/ozekik/markdown-ld.git
创建时间: 2021-02-10T18:24:18Z
项目社区:https://github.com/ozekik/markdown-ld

开源协议:MIT License

下载


Markdown-LD

npm

Markdown-LD is a simple syntax for humans to write RDF Linked Data in Markdown.
It is a kind of literate programming for Turtle/TriG, and useful to publish and maintain linked data along with documentation.

Playground

Try it online! https://ozekik.github.io/markdown-ld

Specification and Examples

See SPEC.md, which is compiled into SPEC.ttl (Turtle) and SPEC.json (JSON-LD).

For a more realistic example from the FOAF (Friend of a Friend) Vocabulary, see examples/foaf.md, examples/foaf.ttl (Turtle), and examples/foaf.json (JSON-LD).

Markdown-LD Compiler

A referential compiler to Turtle and other RDF formats is implemented as a unified/remark plugin and CLI.

Currently Turtle (default) and JSON-LD (with @frogcat/ttl2jsonld) are built-in formats for the output.
You can supply a Turtle output to N3.js, graphy.js, and other libraries to translate it to other formats.

CLI

Installation:

  1. npm install -g markdownld

Usage:

  1. markdownld input.md -o output.ttl
  2. markdownld input.md -o output.json --setting 'format: "jsonld"'

For more information, see unifiedjs/unified-args, on which Markdown-LD CLI is built.

Module

Installation:

  1. npm install markdownld --save

Usage:

  1. const unified = require('unified');
  2. const markdown = require('remark-parse');
  3. const markdownld = require('markdownld');
  4. const input =
  5. '# Example\n\n`<http://example.com></http:>`\n\n' +
  6. '## Alice\n\n`<#Alice>`\n\n' +
  7. '### Knows\n\n`foaf:knows`\n\n' +
  8. '* Bob `<#Bob>`\n';
  9. const processor = unified().use(markdown).use(markdownld);
  10. processor.process(input, (err, { contents }) => {
  11. console.log(contents); // <#Alice> foaf:knows <#Bob> .
  12. });

Todo

  • Publish playground
  • Make TriG default
  • Do input validation for better exception messages
  • Support compilation to more RDF formats