Unformatted Code Detector theme component

I had a false positive on this component. I think it may be from the bullet point items? I made all the text lorem ipsum but the structure is the same:

Hi,

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

https://www.discourse.org

Lorem ipsum dolor sit amet, consectetur adipiscing elit:

* pull_request
* pull_request_review
* pull_request_review_comment

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis `nostrud` exercitation ullamco `laboris` nisi ut aliquip ex ea commodo consequat.

https://www.discourse.org

Lorem ipsum dolor sit amet:

* push
* commit_comment

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Thanks,
Martin
1 Like

That looks like a valid code request format to me? Is there any reason it wouldn’t be

  • item_with_underscores

e.g. as code?

2 Likes

I just wouldn’t expect it to detect things inside an ordered or unordered list as code, but if this is expected I guess it’s fine?

But isn’t pull_request, pull_request_review, etc actually code? I guess I need more specifics on exactly what was in that list… I’d view it as a correct positive, not a false positive?

1 Like

I would argue it’s not a correct positive because it is not a block of code, it is in a list. And those are GitHub webhook “actions” that I have listed. But not a huge deal I guess, just seemed odd to me and I thought I would report it in case.

It could be; it’s borderline in my view due to the underscores :man_shrugging:

Minor nitpick: The default for the warning_modal.content is asking for the “code” toolbar button, but this button is called the “Preformatted text” button in the editor when you hover over it with your mouse.

grafik

grafik

To make it easier for new users to find this button (they will not find any code button), the warning_modal.content should be changed from “code button” → “Preformatted text button”.

1 Like

How can I add a link to a topic with further examples and instructions?

I tried simply adding it at the end of warning_modal.content, but that resulted in this (my additions marked yellow):

grafik

How can I add some text and a link below the the current content?

Edit:

I just noticed that changing even a single character in warning_modal.content breaks the formatting.

grafik

Even worse: Just clicking into the warning_modal.content input field and then moving the cursor by the arrow keys makes the input field highlighted. After clicking the green checkmark to save the “edited” warning_modal.content (no change at all has been done, just moving the cursor one character), the formatting is broken as shown above.

Edit # 2

Solved with the help of How do I escape a backtick ` within in-line code in Markdown? - Meta Stack Exchange

@codinghorror @lionel-rowe Maybe you should look into this and adjust the default warning_modal.content accordingly regarding spaces and backticks (missing spaces within the heavily with backticks equipped “multiplelines” section were causing the problems described above).

1 Like

Is there any way we can make it more clear to the user which key to chose for the code fences if he is doing it manually (i.e. not via the button)?

Today I have seen this:

The user obviously tried to follow the instructions, but chose the wrong key for the code fences ( ' instead of `). In the past I have also seen ... instead of ```. Both cases indicate that users need more explicit instructions which key to choose.

Alternatively: Don’t confuse users with those keys and just say: Use the “Preformatted text” button and you are done.


@lionel-rowe How can I customize the detection behaviour?

Currently the shebang is not detected as code, and I would like to change this.

Expected behaviour: #! indicates the beginning of a script and therefore should be detected as code.

Example for non-detection:


#!/bin/sh

echo “test”

. /lib/upgrade/common.sh

firmware="/tmp/firmware.img"
tmpdir="/tmp/_upgrade"
output="/dev/ttyS0"
before=“before-upgrade.sh”
after=“after-upgrade.sh”


In addition to this, it would be useful for us if root@ would be detected as code.

root@OpenWrt:~# ip link add link eth0 name eth0.9 type vlan id 9
root@OpenWrt:~# brctl addbr br-foo
root@OpenWrt:~# brctl addif br-foo eth0.9
root@OpenWrt:~# ip link set eth0.9 up
root@OpenWrt:~# ip link set br-foo up

3 Likes

@david is there a way to customize the detection?

There isn’t any way to have per-site customizations at the moment, no. We could certainly look at adding shebang and shell prompt detection to the ‘code energy’ system though.

2 Likes

Thanks for raising this - looks like a core bug with multiline theme translations. I’ve made a PR to fix:

2 Likes