-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
more tests, add configurable well known prefix
- Loading branch information
Showing
15 changed files
with
277 additions
and
110 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,58 @@ | ||
# graph-rdfa-processor | ||
# RDFa processor library (WIP) | ||
|
||
### RDFa processor library (WIP) | ||
Rust and wasm library to extract rdf statements (in n-triples format) from an html file | ||
based on rdfa annotations. | ||
|
||
- covers [RDFa 1.1 Primer - Third Edition](https://www.w3.org/TR/rdfa-primer/). | ||
- used [RDFa/Play](https://rdfa.info/play/) for comparing. | ||
- WIP: | ||
## Examples | ||
|
||
```rust | ||
use graph_rdfa_processor::RdfaGraph; | ||
let html = r#" | ||
<div prefix="foaf: http://xmlns.com/foaf/0.1/" about="http://www.example.org/#somebody" rel="foaf:knows"> | ||
<p about="http://danbri.org/foaf.rdf#danbri" typeof="foaf:Person" property="foaf:name">Dan Brickley</p> | ||
</div> | ||
"#; | ||
let base = "http://example.com" | ||
let well_known_prefix = Some("http://example.org/.well_known"); | ||
|
||
RdfaGraph::parse_str(html, base, well_known_prefix).unwrap() | ||
|
||
``` | ||
|
||
```js | ||
<script type="module"> | ||
import init, {html_to_rdfa} from "./rdfa-wasm/pkg/rdfa_wasm.js"; | ||
|
||
async function run() { | ||
await init(); | ||
let html =` | ||
<div prefix="foaf: http://xmlns.com/foaf/0.1/" about="http://www.example.org/#somebody" rel="foaf:knows"> | ||
<p about="http://danbri.org/foaf.rdf#danbri" typeof="foaf:Person" property="foaf:name">Dan Brickley</p> | ||
</div> | ||
`; | ||
let base = "http://example.com" | ||
let well_known_prefix = "http://example.org/.well_known"; | ||
let res = html_to_rdfa(html, base, well_known_prefix); | ||
|
||
} | ||
run(); | ||
</script> | ||
|
||
``` | ||
|
||
- covers: | ||
|
||
- [RDFa 1.1 Primer - Third Edition](https://www.w3.org/TR/rdfa-primer/) | ||
- [RDFa Core](https://www.w3.org/TR/rdfa-core/) | ||
- [Earl-Reports](https://rdfa.info/earl-reports/#RDFa-rdfa1.1-tests-for-html5) | ||
|
||
- used [RDFa/Play](https://rdfa.info/play/) for comparing. | ||
- [Demo](https://nbittich.github.io/graph-rdfa-processor/) | ||
|
||
### WIP | ||
|
||
The plan is to make as much tests as possible, and fix the bugs along the way. | ||
### WIP | ||
|
||
Once enough tests have been implemented, a full refactoring will be needed before | ||
doing anything else. | ||
The plan is to make as much tests as possible, and fix the bugs along the way. | ||
|
||
### KNOWN ISSUES | ||
### KNOWN ISSUES | ||
|
||
- White space not preserved. See test 0329. | ||
- White space not preserved. See test 0329. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/MarkUp/DTD/html401-rdfa11-1.dtd"> | ||
<html version="HTML+RDFa 1.1" prefix="foaf: http://xmlns.com/foaf/0.1/"> | ||
<head> | ||
<title>Test 0035</title> | ||
</head> | ||
<body> | ||
<div> | ||
<img about="http://sw-app.org/mic.xhtml#i" | ||
rel="foaf:img" | ||
src="http://sw-app.org/img/mic_2007_01.jpg" | ||
href="http://sw-app.org/img/mic_2006_03.jpg" | ||
alt="A photo depicting Michael" /> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<http://sw-app.org/mic.xhtml#i> <http://xmlns.com/foaf/0.1/img> <http://sw-app.org/img/mic_2007_01.jpg>. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
|
||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/MarkUp/DTD/html401-rdfa11-1.dtd"> | ||
<html version="HTML+RDFa 1.1" prefix="foaf: http://xmlns.com/foaf/0.1/"> | ||
<head> | ||
<title>Test 0037</title> | ||
</head> | ||
<body> | ||
<div> | ||
<img about="http://sw-app.org/mic.xhtml#i" | ||
rel="foaf:img" | ||
src="http://sw-app.org/img/mic_2007_01.jpg" | ||
href="http://sw-app.org/img/mic_2006_03.jpg" | ||
resource="http://sw-app.org/mic.xhtml#photo" | ||
alt="A photo depicting Michael" /> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
|
||
<http://sw-app.org/mic.xhtml#i> <http://xmlns.com/foaf/0.1/img> <http://sw-app.org/mic.xhtml#photo>. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/MarkUp/DTD/html401-rdfa11-1.dtd"> | ||
<html version="HTML+RDFa 1.1" prefix="foaf: http://xmlns.com/foaf/0.1/"> | ||
<head> | ||
<title>Test 0039</title> | ||
</head> | ||
<body> | ||
<div> | ||
<img about="http://sw-app.org/mic.xhtml#i" | ||
rev="foaf:depicts" | ||
src="http://sw-app.org/img/mic_2007_01.jpg" | ||
href="http://sw-app.org/img/mic_2006_03.jpg" | ||
alt="A photo depicting Michael" /> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<http://sw-app.org/img/mic_2007_01.jpg> <http://xmlns.com/foaf/0.1/depicts> <http://sw-app.org/mic.xhtml#i>. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.