Hacker News new | ask | show | jobs
by Jtsummers 525 days ago
Which ones? Org mode's babel works fine with it. If you do something like this (loose, not precise babel syntax):

  <<body>>=
    if 1 == 1:
        print('1 == 1, shocking!')

  <<function>>=
    def foo():
      <<body>>
It will generate properly indented code when tangled as in:

  def foo():
    if 1 == 1
        print('1 == 1, shocking!')
Note that it puts in precisely two extra spaces for each line in the tangled `body`, which is the amount used in the block named `function` where it references `body`. If you used 4 spaces of indentation, it would use 4 in the tangled output. I've also used noweb and don't recall this being an issue, however that was not with Python so it's possible I just didn't notice a problem with it.
1 comments

I stand corrected! I'm guessing my own bad formatting lead me astray at some point. I tried to come up with a pathological example that'd break with noweb just now and had no luck.