forked from w3c/webref
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcss-json-to-ttl.js
28 lines (22 loc) · 914 Bytes
/
css-json-to-ttl.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Convert JSON on CVSS to Turtle for Css property namespace
const cssData = require( '../ed/css/CSS.json')
// console.log(JSON.stringify(cssData).slice(0,100))
function camelCasify (str) {
var result = str[0]
for (let i=1; i < str.length; i++) {
result += str[i-1] === '-' ? str[i].toUpperCase() : str[i]
}
return result.replace('-','')
}
console.log(`@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix css: <http://www.w3.org/ns/css#> .
<> rdfs:comment """This ontology allows CSS properties to be expressed in RDF.
The same camelcase convention is used as is used by the subproperties of the
style property in browser JS implementations.
""" .
`)
for (const dfn of cssData.properties) {
const camel = dfn.styleDeclaration.pop()
console.log(`css:${camel} a rdf:Property; rdfs:label "${dfn.name}"; spec:values`)
}