copy #891 code to nikola.utils

Signed-off-by: Chris “Kwpolska” Warrick <kwpolska@gmail.com>
resolve #891 — implement demoting headers

Signed-off-by: Chris “Kwpolska” Warrick <kwpolska@gmail.com>