Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sogaiu/janet-xmlish
Parse XML-ish Strings as Janet Data
https://github.com/sogaiu/janet-xmlish
janet peg xml
Last synced: about 1 month ago
JSON representation
Parse XML-ish Strings as Janet Data
- Host: GitHub
- URL: https://github.com/sogaiu/janet-xmlish
- Owner: sogaiu
- Created: 2020-09-20T07:18:31.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-09-06T13:48:07.000Z (5 months ago)
- Last Synced: 2024-09-06T16:04:30.710Z (5 months ago)
- Topics: janet, peg, xml
- Language: Janet
- Homepage:
- Size: 95.7 KB
- Stars: 8
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# janet-xmlish
PEG-based Parsing for XML-ish Data
## Description and Disclaimer
This code provides a single PEG to help parse XML-like strings to
produce Janet data structures. It's not an attempt at a complete /
correct parser, but it seems to have handled some cases tolerably
well.## Usage
### Command Line
Zero to sample invocation:
```
git clone https://github.com/sogaiu/janet-xmlish
cd janet-xmlish
janet -l ./janet-xmlish/grammar -e '(pp (peg/match xmlish-peg "hi
"))'
```Output:
```
@[{:content @["hi"] :tag "h1"}]
```### From Code
Assuming installation like:
```
jpm install https://github.com/sogaiu/janet-xmlish
```Code might look like:
```
(import janet-xmlish/grammar :as xmlish)(peg/match xmlish/xmlish-peg
``link``)
```Evaluation might yield:
```
@[{:attrs @{"href" "http://127.0.0.1:8000"}
:content @["link"]
:tag "a"}]
```## More Examples
See `(comment ...)` portions of source files and files in `usages` for examples.