pelican/plugins/toc.py [14:50]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
'''

from __future__ import unicode_literals

import logging
import re

from bs4 import BeautifulSoup, Comment

from pelican import contents, signals
from pelican.utils import slugify


logger = logging.getLogger(__name__)

'''
https://github.com/waylan/Python-Markdown/blob/master/markdown/extensions/headerid.py
'''
IDCOUNT_RE = re.compile(r'^(.*)_([0-9]+)$')


def unique(id_, ids):
    """ Ensure id is unique in set of ids. Append '_1', '_2'... if not """
    while id_ in ids or not id_:
        m = IDCOUNT_RE.match(id_)
        if m:
            id_ = '%s_%d' % (m.group(1), int(m.group(2)) + 1)
        else:
            id_ = '%s_%d' % (id_, 1)
    ids.add(id_)
    return id_
'''
end
'''


class HtmlTreeNode(object):
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



pelican/plugins/toc2.py [8:44]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
'''

from __future__ import unicode_literals

import logging
import re

from bs4 import BeautifulSoup, Comment

from pelican import contents, signals
from pelican.utils import slugify


logger = logging.getLogger(__name__)

'''
https://github.com/waylan/Python-Markdown/blob/master/markdown/extensions/headerid.py
'''
IDCOUNT_RE = re.compile(r'^(.*)_([0-9]+)$')


def unique(id_, ids):
    """ Ensure id is unique in set of ids. Append '_1', '_2'... if not """
    while id_ in ids or not id_:
        m = IDCOUNT_RE.match(id_)
        if m:
            id_ = '%s_%d' % (m.group(1), int(m.group(2)) + 1)
        else:
            id_ = '%s_%d' % (id_, 1)
    ids.add(id_)
    return id_
'''
end
'''


class HtmlTreeNode(object):
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



