From 7175186ff74ea18cc3c63c3c45dbec6cddcf1855 Mon Sep 17 00:00:00 2001 From: Ville Rantanen Date: Wed, 19 Apr 2023 14:42:10 +0300 Subject: [PATCH] remove code and tables from toc --- reporting/md-toc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/reporting/md-toc b/reporting/md-toc index 2b385ea..92f225a 100755 --- a/reporting/md-toc +++ b/reporting/md-toc @@ -49,7 +49,16 @@ def main(): marker_found = False marker_end_found = False to_remove = [] + in_code = False + for i, row in enumerate(markdown): + in_table = row.startswith("|") + if row.startswith("```"): + in_code = not in_code + + if any((in_code, in_table)): + continue + if row.startswith("#"): headers, title = row.strip().split(" ", 1) if opts.l: