2

Sometimes I write answers within the <pre>...</pre> tag to get more control over formatting the answers. Usually, I do this with the code-snippets, which may be required some emphasis.

In the below snippet, I want to emphasize the expression str(getattr(self, field.name)) and thus I wrote the answer as below,

<pre><code>class HelperClass:
    def get_fields(self):
        return [(field, <b>str(getattr(self, field.name))</b>) for field in self._meta.fields]</code></pre>

But, the bold formatting doesn't appear.

Enter image description here

Note: I/We can see the formatted code block in the "edit/preview mode"

Is this a bug? Or was this feature removed in some release?

References:

  1. Link to the specific SO answer
4
  • Possibly related: Bug with <pre><code> tags Jul 11, 2021 at 12:07
  • What if <strong> is used instead of <b>? Jul 11, 2021 at 12:11
  • @PeterMortensen won't work, in fact no inline HTML will work, as highlight.js now strips any unescaped html it finds in the code. Jul 11, 2021 at 12:21
  • @Vega The formatting is working in the "Edit Mode" (Already mentioned that in my Note section)
    – JPG
    Jul 11, 2021 at 14:35

0

Browse other questions tagged .