eudoxia0 / cl-yaml

YAML parser for Common Lisp
61 stars 7 forks source link

emit with block styles instead of flow styles #9

Open arademaker opened 8 years ago

arademaker commented 8 years ago

Given this input:


---
title: ABBOTT, Fernando
autor:
 - Izabel Noll
cargos:
 - const. 1891
 - gov. RS 1891
 - dep. fed.RS 1891-1892
 - gov. RS 1892-1893
 - dep.fed. RS 1893-1894
 - emb. Bras. Argentina 1894-1897

---

We can only dump the flow styles:

TEST> (cl-yaml:emit (cl-yaml:parse #P"1.tmp") *standard-output*)
{ cargos: [const. 1891, gov. RS 1891, dep. fed.RS 1891-1892, gov. RS 1892-1893, dep.fed. RS 1893-1894, emb. Bras. Argentina 1894-1897], autor: [Izabel Noll], title: ABBOTT, Fernando }

It would be nice to output the block styles too! Any idea? How difficult would be to extend the library for produce it?

arademaker commented 8 years ago

Please also note that in the flow styles I believe the strings with commas must be protected with double-quote, right? The parse of the output above would give us a wrong result, see the title key being splitted:

TEST> (alexandria:hash-table-alist (cl-yaml:parse "{ cargos: [const. 1891, gov. RS 1891, dep. fed.RS 1891-1892, gov. RS 1892-1893, dep.fed. RS 1893-1894, emb. Bras. Argentina 1894-1897], autor: [Izabel Noll], title: ABBOTT, Fernando }"))
(("Fernando" . "") ("title" . "ABBOTT") ("autor" "Izabel Noll")
 ("cargos" "const. 1891" "gov. RS 1891" "dep. fed.RS 1891-1892" "gov. RS 1892-1893" "dep.fed. RS 1893-1894" "emb. Bras. Argentina 1894-1897"))
eudoxia0 commented 8 years ago

Oh yes, the emitter is very low effort. We definitely need to have a way to emit things in the pretty human-readable style.

slyrus commented 3 years ago

+1