AbuseFilter prevents edits via a hook and makes that hook return messages which are huge HTML blobs, typically including some big warning rectangle with colors and an icon, and some text in the middle. Since it can prevent API edits, and the HTML blob is not really useful for the API (the client might not even be able to display HTML, and even if it does, the big block might not fit with the design or the device constraints), it should be possible to get the message in a more flexible format.
This is not trivial as the message might contain <p> tags (a corresponding text message would probably have multiple paragraphs), hyperlinks (easy to turn to plaintext, but useful for some clients which would still not want the formatting), inline styling, lists etc. (Here is an example of a more involved filter message). Also the warning boilerplates tend to have information which doesn't really fit in an error message but can be useful (like where to report filter errors on the given wiki). Also any new syntax should support gradual migration or backwards compatibility as the HTML wrappers are part of the community-defined message, so those messages themselves would have to be changed.
Some options:
- Provide an URL to the wiki page with the warning notice, as an alternative to returning the contents of the notice. (This would require some kind of structured output from the hook beyond just a message, which seems like a good idea in general.)
- Allow defining a plantext version of the warning inside the same message in some kind of invisible, easy-to-parse-out syntax (wikitext comment? hidden div like it's done for CommonsMetadata? parser function? maybe even MCR?) and update the existing warning messages with such alternatives.
- (probably in concert with the previous option) allow returning a (short) main error message and a help message which explains it in more details (as many AbuseFilter templates do this, at length).