[augeas-devel] Re: Multiline values in INI Files

Nate Foster jnfoster at cis.upenn.edu
Fri Aug 29 17:14:46 UTC 2008


> I would write a lens that would actually keep the indentation, in this
> fashion:
>
> { "key" = "this is a long\n   text that belongs\n   to the same field" }
>
>
> but then I would add a q-lens to the front of it, which would take the
> abstract part of this lens (which contains the ugly indentation) and parse
> it in a reversible way, changing all /\n[ \t]+/ into "\n" to make it look
> nice. The default value for the indentation would then be "\n " so that the
> abstract line "this is a long\ntext that belongs\nto the same field" would
> get computed through the q-lens (in the case of a create, not of a put) into
> "this is a long\n text that belongs\n to the same field".

I think you'd do this the other way. You'd define a lens that works on
strings with no indentation--so just newlines--and then quotient it on
the left by a canonizer that "canonizes" source strings with arbitrary
indentation to ones with just new lines, and that "chooses" strings
with pretty printed indentation.

The final q-lens would accept keys like this in the source

   "This is\n   a key\n    with wacky indentation"

map them to views with no indentation like this

  "This is\nakey with\nwacky indentation"

and produce sources with standard indentation, maybe like this?

  "This is\n  akey with\n  wacky indentation"

Is that what you want?

Nate




More information about the augeas-devel mailing list