If this is a programming question, it belongs on Stack Overflow. I'm going to assume it's a linguistic question for now, however, based on the graphics.
Of the two examples, option 1 is preferred. The primary reason for this is that while most Japanese words written in kanji have readings that correspond to specific characters, there are several words for which this is not the case due to gikun. For example:
- 大人【おとな】
- 今日【きょう】
- 今朝【けさ】
- 山手線【やまのてせん】
The short of it is that breaking them apart for each character can suggest an association where it doesn't exist, and using one style consistently is generally preferable.