Interesting problem that I also don't have a solution to. I think removing roman numerals above number 5000 will be the best way to deal with.
But still I found a way to add overlines like this, so why not:
- 5407 ==> VCDVII
- 157897 ==> CLVMMDCCCXCVII
This is also very useful for representing rational numbers that have repeating digits such as this:
- 1/31 = 0.032258064516129