entangled / entangled.py

Python port of Entangled
Apache License 2.0
33 stars 7 forks source link

filtered output/pre-commit safe/synced output #5

Open RonnyPfannschmidt opened 1 year ago

RonnyPfannschmidt commented 1 year ago

when trying to sync example fragments with entangled, i took note that pre-commit fixup's like end of line, or back completely throw entangled off its "game"

that keeps dropping the tool into a "can't sync" state

jhidding commented 1 year ago

Several things to say about this:

  1. I've noticed working with Entangled that sometimes the semantics of when entangled sync starts to complain is a bit too strict, but its hard to single out a case where the decision logic can be clearly improved.
  2. No newline is added to the end of a tangled document.
  3. Indented code with newlines will give spaces on empty lines.
  4. Entangled ignores indentation on empty lines, instead looking at indentation of current block See code_reader.py#63
  5. Changed lines by a code formatter end up being ignored by Entangled because its only whitespace.

I suppose a few unit-tests regarding behaviour under code-formatters couldn't hurt.

jhidding commented 1 year ago

If you are sure that the code formatters only changed the tangled files and no changes are present in the markdown (or you have everything committed to git) running entangled stitch --force should get you out of the "can't sync" state.

RonnyPfannschmidt commented 1 year ago

I think part of this is related to having a edit loop running while using both pre-commit and a ide

I'll observe and try to get a example one could run with a script