Fix ipynb title extraction stripping leading # from heading text
Problem
When converting a Jupyter notebook, the document title is taken from the first Markdown # heading. The extraction uses:
title = line.lstrip("# ").strip()
str.lstrip(chars) treats its argument as a set of characters to strip, not a prefix. So it removes every leading # and space character, not just the single "# " marker. A heading whose text itself begins with # loses those characters.
Example: a notebook whose first heading is # #100DaysOfCode produces the title 100DaysOfCode instead of #100DaysOfCode.
Fix
Strip only the "# " marker by slicing off its known length:
title = line[len("# ") :].strip()
The line already passed line.startswith("# "), so the prefix is guaranteed present. Outer whitespace is still trimmed by .strip().
Tests
Added tests/test_ipynb_converter.py:
- a heading whose text starts with
#keeps it (# #100DaysOfCode->#100DaysOfCode) - only the marker is removed, internal spacing preserved
- a plain heading is unchanged
All three pass; the first fails on the old code.
Disclosure: I used AI assistance while preparing this change. I reproduced the bug and verified the fix and tests locally.