cl-yaml icon indicating copy to clipboard operation
cl-yaml copied to clipboard

emit with block styles instead of flow styles

Open arademaker opened this issue 9 years ago • 3 comments

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 avatar Jun 28 '16 11:06 arademaker

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"))

arademaker avatar Jun 28 '16 11:06 arademaker

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

eudoxia0 avatar Jul 01 '16 23:07 eudoxia0

+1

slyrus avatar Feb 24 '21 19:02 slyrus