Skip to content

Syntax highlighting with fenced-code-blocks is broken #897

Open
@bendavis78

Description

@bendavis78

I want the following markdown code to work:

```python
if True:
    print("hello")
```

I've added a custom ASKBOT_MARKDOWN_CLASS to load fenced-code-blocks extension:

import markdown2

class Markdown(markdown2.Markdown):
    def __init__(self, *args, **kwargs):
        extras = kwargs.get('extras', list())
        extras.extend([
            'fenced-code-blocks'
        ])
        kwargs['extras'] = extras
        super().__init__(*args, **kwargs)

When writing the question with the above markdown, it does not show the preview correctly:
image

When I submit the question, it does render correctly on the first load:
image

However, when I refresh the page, the code loses newlines (and the syntax colors are oddly different):
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions