Fix hash in TOC

hi.

Strange hash in href of TOC.

*example markdown*

```
# title

# A

## B

## C

### D
```

*generated TOC*

- A [#a](#a)
  - B [#a_b](#a_b)
  - C [#a_b_c](#a_b_c)
    - D [#a_b_c_d](#a_b_c_d)

I think following is better.

*generated TOC*

- A [#a](#a)
  - B [#a_b](#a_b)
  - C [#a_c](#a_c)
    - D [#a_c_d](#a_c_d)

I tried to fix this.
Would you mind review my code?