We are importing a bunch of posts, and the content often contains text like @global or similar (the topic of our discourse instance is related to programming, and @ is a symbol in that language).
Is there a nice and clean way to suppress pinging users? I don’t mind pre-processing the posts before importing.
As a kinda dirty workaround, I found that inserting an empty bbcode tag after the @ works (like @[b][/b]global). It just doesn’t feel like a very good solution and would require me to parse/tokenize the markdown, since the bbcode should not be inserted if the string is within a code block. So it is not a good solution. A zero-width space is also not a solution as that will lead to weird errors when users copy the code snippet into their own source code.
If it’s in a code block it’s not a problem. If your can make sure it’s always in a code block, you’re in good shape. You’ve got to run a real parser to know when you’re in a code block, though.
Oh, or turn off the Allow users to mention other users setting while you import the data.
Sure if the @name is in a codeblock then it’s not a problem. The problem is detecting when it is and when it isn’t, so that I can prevent the ping outside of codeblocks by inserting the invisible [b][/b] tag between @ and the name. It would indeed require a full markdown parser/tokenizer.
Hmm, does that still apply even when the post is later rebaked or would that lead to random pings in that event?
I don’t see anything preventing pings, the changes are directly published to clients as far as I understand it (but I am by far no expert in ruby or with discourse, so please correct me if I’m wrong):