diff --git a/src/renderer/html_handlebars/helpers/toc.rs b/src/renderer/html_handlebars/helpers/toc.rs
index 3fb7b904..c7cc074a 100644
--- a/src/renderer/html_handlebars/helpers/toc.rs
+++ b/src/renderer/html_handlebars/helpers/toc.rs
@@ -33,7 +33,7 @@ impl HelperDef for RenderToc {
}
let level = if let Some(s) = item.get("section") {
- s.len() / 2
+ s.matches(".").count()
} else {
1
};