Refactored code and escape RST special character '_'
(cherry picked from commit 4629a464f701f919633fd220860b6610d097c291)