Offline vCard 3.0/4.0 contact text parser and writer
moon check --target all
moon build --target wasm
moon test --target wasm
moon run --target wasm examples/demoContacts: 2
Diagnostics: 0
Name: 张三 (v3.0)
TEL +8613900000001 [TYPE=home] [PREF=1]
TEL +8613900000002 [TYPE=cell] [PREF=2]
EMAIL zhang@example.org [TYPE=work]
Name: Bob (v4.0)moon add haol-05/moon-vcardlet card = "BEGIN:VCARD\nVERSION:4.0\nFN:Alice Smith\nN:Smith;Alice;;;\nTEL;TYPE=cell;PREF=1:+8613800000000\nEND:VCARD"
let result = parse(card)
for contact in result.contacts {
println(contact.full_name)
for phone in contact.phones {
println(phone.value)
for param in phone.params {
println(param.name + "=" + param.values.join(","))
}
}
let normalized = format(contact)
}| Type | Fields | Meaning |
|---|---|---|
| Field | value, params | one property value together with the parameters on its line |
| Param | name, values | one parameter; values is empty for a bare parameter such as ;PREF, and holds one entry per comma-separated value otherwise |
let ordered = sort_by_preference(result.contacts[0].phones)
println(ordered[0].value)| Package | What it adds |
|---|---|
| haol-05/moon-vcard | the parser, the writer and preference ordering |
| .../params | read, add, drop, merge, sort and render parameters of a field |
| .../normalize | comparison keys for phones, emails and names, plus masking and grouping helpers |
| .../query | a small filter expression language (has:email,type=cell,-name~test) |
| .../tools | statistics, duplicate detection, merging, dedupe, search, sorting and diffing |
| .../csv | RFC 4180 reading and writing, with contact rows |
| .../report | markdown, plain-text and summary renderers |
| .../json | JSON encoders and decoders for the model, built on the toolchain's JSON package |
Install
Download zipOffline vCard 3.0/4.0 contact text parser and writer