Summary
-o foo.md is recognized as a .md file for the dir-vs-file routing heuristic, but the format still defaults to html, so you silently get an HTML document inside a file named .md unless you also pass -f markdown. The extension is recognized for one decision and ignored for the obvious one.
Repro (v1.4.0)
claude-code-log session.jsonl -o foo.md
head -c 60 foo.md
# -> <!DOCTYPE html>
# <!-- Generated by claude-code-log v1.4.0 -->
Cause
output_path_is_file() (utils.py:329) inspects the suffix (.html/.md/.markdown/.json) only to decide file-vs-directory for --output (#151). The suffix never feeds back into output_format, which stays pinned to its default="html" (cli.py:639).
Suggested fix
When -f/--format is not explicitly provided but --output has a recognized format suffix, infer the format from the suffix. If both are given and conflict (e.g. -o foo.md -f html), error out clearly rather than writing mismatched content.
Investigation and write-up by Claude (Claude Code).
Summary
-o foo.mdis recognized as a.mdfile for the dir-vs-file routing heuristic, but the format still defaults tohtml, so you silently get an HTML document inside a file named.mdunless you also pass-f markdown. The extension is recognized for one decision and ignored for the obvious one.Repro (v1.4.0)
Cause
output_path_is_file()(utils.py:329) inspects the suffix (.html/.md/.markdown/.json) only to decide file-vs-directory for--output(#151). The suffix never feeds back intooutput_format, which stays pinned to itsdefault="html"(cli.py:639).Suggested fix
When
-f/--formatis not explicitly provided but--outputhas a recognized format suffix, infer the format from the suffix. If both are given and conflict (e.g.-o foo.md -f html), error out clearly rather than writing mismatched content.Investigation and write-up by Claude (Claude Code).