Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
django_markup takes code blocks written in Markdown and wraps them in <pre> tags. Pygments, which is used by django_markup when available, takes all the words inside the code blocks and wraps them in various span tags so that the stylesheet may color them appropriately. Inline rendering depends on BeautifulSoup. BeautifulSoup preserves whitespace in <pre> tags that have no further tags inside of them, but the trouble is that BeautifulSoup sees all those <span> tags, recognizes it as HTML, and strips what it thinks to be extraneous whitespace. Thus all the indentation is gone, and your Python code examples have pretty colors but are useless. The solution is simply to render inlines before rendering Markdown. Then BeautifulSoup doesn't have any <pre> or <span> tags to mess up. It doesn't know what Markdown's markup is, so it doesn't do anything to it. This also increases efficiency compared to rendering inlines in templates. as long as we've got a model field specifically for rendered data, we might as well put rendered inlines in it, you know? Sweet.
- Loading branch information