Maybe it depends on where. AFAIK you're obliged to pay the entire lease with a few exceptions that might help you get out earlier. One being a nice landlord (so not a law)
https://www.nolo.com/legal-encyclopedia/free-books/renters-r...
AFAIK what you linked to only says a landlord is required to try to find a new renter. In SF that's probably easy to find but any many places it could easily be several months all of which you'd be required to keep paying.