Bug: "#" is always interpreted as comment prefix, even when it should be an HTML hash
For URLs (wiki internal as well as http(s)) a "#" meant as an HTML hash (pointing to a section) is interpreted as "#" introducing a field comment and cutting the field content at that point (obviously meant as splitting content and comment) - this has very strong impact on fields of type "_wiki" where "... [[...#...]] ..." is used: anything up from the "#" is lost.
The plugin:data wiki page helps solving this issue: https://www.dokuwiki.org/plugin:data#data_entry_input
Quote: "You may use the # character to add comments to the block. Those will be ignored and will neither be displayed nor saved. If you need to enter # as data, escape it with a backslash (#). If you need a backslash, escape it as well ()."
Sorry, escaping hash signs in URIs means spoiling the URIs, as far as I can see it - maybe you didn't get the point here, if I'll find time I'll see in a fork how simple it should be to identify hash signs - as opposed to lattices as arbitrary literal signs for which your answer is appropriate.
Your point about the hash in the url I can understand.
- An idea is to ignore # without escaping when it is in urls that is in words starting with http(s)://...
- Or maybe to say that # needs to be prefixed with a space... (no idea how good backward compatibility is)
Please be aware that a hash should be available to comment out a whole entry line. Example implementations welcome!
A regexp is welcome... Matching an url is not possible in the lookbehind, because in lookbehinds are only patterns of fixed length allowed. So I guess it needs a different approach.