Code highlights prevent the placeholder value from being displayed in a codeblock

I struggled with this issue for the last days before figuring out what the issue was. It was reported here: Placeholder Forms - #48 by jericson.

The issue doesn’t seem to happen (anymore?) on the example given in the linked post, so I’ll do my own repro here:

[wrap=placeholder key=TABLE description="table name" default="users"][/wrap]

```
SELECT * FROM =TABLE=;
```

does:

SELECT * FROM =TABLE=;

The variable isn’t recognized because of the codeblock highlight, which is automatically set to SQL.

The output HTML is:

<code class="hljs language-sql" data-highlighted="yes">
  <span class="hljs-keyword">SELECT</span>
  <span class="hljs-operator">*</span>
  <span class="hljs-keyword">FROM</span>
  <span class="hljs-operator">=</span>
  <span class="hljs-keyword">TABLE</span>
  <span class="hljs-operator">=</span>
  ;
</code>

If I specify txt in the codeblock, then the value is correctly displayed:

SELECT * FROM =TABLE=;

The expected behavior would be to have the value displayed regardless of the code highlight.

I don’t know why the codeblock isn’t automatically set to SQL as it was the case yesterday. It renders my repro ineffective, but it works on try.discourse.org so here’s a screenshot:

Regardless of the auto language detection, the fact is that some language highlights will break the string =VALUE= and the value won’t be rendered, which is unwanted.

A fix here is going to be quite complicated, if placeholder markers are parsed as syntax highlighted sections, when we head over to replace we do not find them.

The correct way of sorting this is to redo the pipeline and only do highlighting after we do replacement.

For now I would say this is in the feature request department, I don’t mind putting a pr-welcome on this in case someone can come up with a cheap and simple way of sorting this out.

1 Like