diff --git a/Readme.md b/Readme.md
index 982c1a2..db499f8 100644
--- a/Readme.md
+++ b/Readme.md
@@ -154,6 +154,14 @@ Code copied from `AutoIdentifierExtension`, then added some code and options.
* `aClass`: `string? : default null`
Class attribute for `a` element.
+
+* `CurrentUrl`: `string? : default null`
+
+ Current Url for toc items to work on subpages like `/help#anker`
+
+* `MaxLevel`: `int : default 6`
+
+ Maximum heading level to include in the table of content. e.g. set to 2 to only include # and ## headings.
diff --git a/src/Helpers/HeadingInfos.cs b/src/Helpers/HeadingInfos.cs
index 972ece3..d72ecbc 100644
--- a/src/Helpers/HeadingInfos.cs
+++ b/src/Helpers/HeadingInfos.cs
@@ -33,7 +33,7 @@ void renderHtmlMixed(HtmlRenderer renderer, TocOptions options)
renderer.Write("
{Content}");
@@ -70,7 +70,7 @@ void renderHtmlLint(HtmlRenderer renderer, TocOptions options)
if (!item.IsLocator)
{
- renderer.Write($"{item.Content}");
diff --git a/src/TocOptions.cs b/src/TocOptions.cs
index f38f9c8..d610eb5 100644
--- a/src/TocOptions.cs
+++ b/src/TocOptions.cs
@@ -55,6 +55,10 @@ public TocOptions()
/// Classes for ContainerTag, work on ContainerTag is not null.
///
public string? ContainerClass { get; set; }
+ ///
+ /// Current Url for toc items to work on subpages like /help.
+ ///
+ public string? CurrentUrl { get; set; }
#endregion
#region toc tag
///
@@ -102,6 +106,12 @@ public TocOptions()
///
public string? TitleClass { get; set; }
#endregion
+ ///
+ /// Maximum heading level to include in the table of content (default 6).
+ /// e.g. set to 2 to only include # and ## headings.
+ ///
+ public int MaxLevel { get; set; } = 6;
+
#region toc items
///
/// Class names for ul emement.
@@ -124,7 +134,11 @@ public TocOptions()
#endregion
internal void AddHeading(HeadingInfo info)
- => Headings.Append(HeadingInfos.FromHeading(info));
+ {
+ if (info.Level > MaxLevel)
+ return;
+ Headings.Append(HeadingInfos.FromHeading(info));
+ }
}
}