# Path: templar/api/rules/core.py
# class Rule:
# class SubstitutionRule(Rule):
# class VariableRule(Rule):
# class InvalidRule(TemplarError):
#     def __init__(self, src=None, dst=None):
#     def applies(self, src, dst):
#     def apply(self, content):
#     def substitute(self, match):
#     def apply(self, content):
#     def extract(self, content):
#     def apply(self, content):


from templar.api.rules import core
import re


class HtmlTableOfContents(core.VariableRule):
    """A rule that constructs a table of contents based on all HTML headers found in the
    content.

    This rule adds a variable called "table_of_contents". By default, this rule only applies
    to destinations with a .html extension.
    """
    header_regex = re.compile(r"""
        <\s*h([1-6])        # \1 is the header level
        (?:
            .*?         # attributes
            id=(['"])   # \2 is the quote

# Path: templar/api/rules/core.py
# class Rule:
# class SubstitutionRule(Rule):
# class VariableRule(Rule):
# class InvalidRule(TemplarError):
#     def __init__(self, src=None, dst=None):
#     def applies(self, src, dst):
#     def apply(self, content):
#     def substitute(self, match):
#     def apply(self, content):
#     def extract(self, content):
#     def apply(self, content):


# Path: templar/api/rules/table_of_contents.py
from templar.api.rules import core
import re



class HtmlTableOfContents(core.VariableRule):
    """A rule that constructs a table of contents based on all HTML headers found in the
    content.

    This rule adds a variable called "table_of_contents". By default, this rule only applies
    to destinations with a .html extension.
    """
    header_regex = re.compile(r"""
        <\s*h([1-6])        # \1 is the header level
        (?:
            .*?         # attributes
            id=(['"])   # \2 is the quote

            (.*?)       # \3 is the actual id