Browsable API markdown description broken if tabs are used in code indentation. · Issue #4345 · encode/django-rest-framework (original) (raw)

get_view_description(html=True) with markdown installed is broken if the project uses tabs instead of spaces. Everything after the first line is rendered as a <pre> block.

The problem is in the utils.formatting.dedent() function which only dedents spaces, not tabs.

Checklist

Steps to reproduce

from rest_framework.utils.formatting import dedent dedent("\tfirst string\n\n\tsecond string")

Expected behavior

It returns:

u'first string\n\n\tsecond string'

Actual behavior

It should return:

u'first string\n\nsecond string'