Commit9a81e9e9Recorded31 Mar 2026Repositorysigil-sxml
Add README
Changed
README.md | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 70 insertions(+)Diff
README.mdadded
@@ -0,0 +1,70 @@
+1
# sigil-sxml+2
+3
SXML processing library for [Sigil](https://codeberg.org/sigil/sigil). Convert between S-expression representations of XML/HTML and serialized markup strings.+4
+5
## Usage+6
+7
```scheme+8
(import (sigil sxml))+9
+10
;; Convert SXML to HTML+11
(sxml->html '(div (@ (class "main"))+12
(h1 "Hello")+13
(p "Welcome to " (strong "Sigil") ".")))+14
; => "<div class=\"main\"><h1>Hello</h1><p>Welcome to <strong>Sigil</strong>.</p></div>"+15
+16
;; Void elements handled automatically+17
(sxml->html '(img (@ (src "photo.jpg"))))+18
; => "<img src=\"photo.jpg\">"+19
+20
;; Convert SXML to XML (self-closing void elements)+21
(sxml->xml '(item (@ (id "1")) "Content"))+22
; => "<item id=\"1\">Content</item>"+23
```+24
+25
### Parsing XML+26
+27
```scheme+28
(import (sigil sxml reader))+29
+30
;; Parse XML string to SXML+31
(xml->sxml "<div class=\"main\"><p>Hello</p></div>")+32
; => (div (@ (class "main")) (p "Hello"))+33
+34
;; Parse multiple top-level elements+35
(xml->sxml* "<p>One</p><p>Two</p>")+36
; => ((p "One") (p "Two"))+37
```+38
+39
### Element Inspection+40
+41
```scheme+42
(sxml-tag '(div (@ (class "box")) "content")) ; => div+43
(sxml-attributes '(div (@ (id "main")) "text")) ; => ((id "main"))+44
(sxml-content '(div (@ (id "main")) "hello" "world")) ; => ("hello" "world")+45
(sxml-attr-ref '(div (@ (id "main"))) 'id) ; => "main"+46
(sxml-attr-set '(div "text") 'id "main") ; => (div (@ (id "main")) "text")+47
```+48
+49
## Features+50
+51
- **SXML to HTML** with automatic void element handling and text escaping+52
- **SXML to XML** with self-closing element support+53
- **XML parser** with streaming/incremental parsing support+54
- **Element inspection** for querying tags, attributes, and content+55
- **Raw HTML pass-through** via `(*raw* "...")` nodes+56
+57
## Dependencies+58
+59
- sigil-stdlib+60
+61
## Build+62
+63
```sh+64
sigil build+65
sigil test+66
```+67
+68
## License+69
+70
BSD-3-Clause