
import sys
import json

for arg in sys.argv[1:]:
    with open(arg) as f:
        equajson = json.load(f)

    try:
        latex = equajson["markup-languages"]["LaTeX"][0]["markup"]
    except KeyError:
        continue

    if 'documentclass' not in latex:
        with_boilerplate = "\\documentclass{article}\n\\begin{document}\n\\[\n%s\n\\]\n\\end{document}" % latex
        equajson["markup-languages"]["LaTeX"][0]["markup"] = with_boilerplate

    with open(arg, 'w') as f:
        json.dump(equajson, f, indent=4, separators=(',', ': '), ensure_ascii=False, sort_keys=True)


import sys
import json

for arg in sys.argv[1:]:
    with open(arg) as f:
        equajson = json.load(f)

    try:
        latex = equajson["markup-languages"]["LaTeX"][0]["markup"]
    except KeyError:
        continue

    if 'documentclass' not in latex:
        with_boilerplate = "\\documentclass{article}\n\\begin{document}\n\\[\n%s\n\\]\n\\end{document}" % latex
        equajson["markup-languages"]["LaTeX"][0]["markup"] = with_boilerplate

    with open(arg, 'w') as f:
        json.dump(equajson, f, indent=4, separators=(',', ': '), ensure_ascii=False, sort_keys=True)
        f.write('\n') # add trailing newline

Add trailing newline to make round-tripping without diffs possible.
Add trailing newline to make round-tripping without diffs possible.

  
  import sys
  import json
  
  for arg in sys.argv[1:]:
      with open(arg) as f:
          equajson = json.load(f)
  
      try:
          latex = equajson["markup-languages"]["LaTeX"][0]["markup"]
      except KeyError:
          continue
  
      if 'documentclass' not in latex:
          with_boilerplate = "\\documentclass{article}\n\\begin{document}\n\\[\n%s\n\\]\n\\end{document}" % latex
          equajson["markup-languages"]["LaTeX"][0]["markup"] = with_boilerplate
  
      with open(arg, 'w') as f:
          json.dump(equajson, f, indent=4, separators=(',', ': '), ensure_ascii=False, sort_keys=True)
+         f.write('\n') # add trailing newline
  
Add trailing newline to make round-tripping without diffs possible.
## Code Before:

import sys
import json

for arg in sys.argv[1:]:
    with open(arg) as f:
        equajson = json.load(f)

    try:
        latex = equajson["markup-languages"]["LaTeX"][0]["markup"]
    except KeyError:
        continue

    if 'documentclass' not in latex:
        with_boilerplate = "\\documentclass{article}\n\\begin{document}\n\\[\n%s\n\\]\n\\end{document}" % latex
        equajson["markup-languages"]["LaTeX"][0]["markup"] = with_boilerplate

    with open(arg, 'w') as f:
        json.dump(equajson, f, indent=4, separators=(',', ': '), ensure_ascii=False, sort_keys=True)

## Instruction:
Add trailing newline to make round-tripping without diffs possible.
## Code After:

import sys
import json

for arg in sys.argv[1:]:
    with open(arg) as f:
        equajson = json.load(f)

    try:
        latex = equajson["markup-languages"]["LaTeX"][0]["markup"]
    except KeyError:
        continue

    if 'documentclass' not in latex:
        with_boilerplate = "\\documentclass{article}\n\\begin{document}\n\\[\n%s\n\\]\n\\end{document}" % latex
        equajson["markup-languages"]["LaTeX"][0]["markup"] = with_boilerplate

    with open(arg, 'w') as f:
        json.dump(equajson, f, indent=4, separators=(',', ': '), ensure_ascii=False, sort_keys=True)
        f.write('\n') # add trailing newline
