@@ -0,0 +1,1122 @@
+#!/usr/bin/env python%0A%22%22%22Pandoc filter to convert add ids to glossary entries.%0A%0AUsage:%0A%0A    pandoc source.md --filter=id4glossary.py --output=output.html%0A%22%22%22%0Aimport pandocfilters as pf%0A%0Adef normalize_keyword(keyword):%0A    %22%22%22Normalize keyword for became id%0A%0A    - Replace white space with '-'%0A    - Convert to lowercase%22%22%22%0A    return keyword.lower().replace(' ', '-')%0A%0Adef keyword2html(keyword_node):%0A    %22%22%22Return HTML version of keyword with id.%22%22%22%0A    keyword = ' '.join(%5Bword%5B'c'%5D for word in keyword_node if word%5B't'%5D == 'Str'%5D)%0A    id = normalize_keyword(keyword)%0A    return %5B%7B%22t%22: %22Span%22,%0A             %22c%22: %5B%5Bid, %5B%5D,%5B%5D%5D,%0A                 keyword_node%5D%7D%5D%0A%0Adef id4glossary(key, value, format, meta):%0A    %22%22%22Add id to keywords at glossary.%22%22%22%0A    if %22subtitle%22 in meta and %5C%0A            ''.join(%5Bstring%5B'c'%5D for string in meta%5B%22subtitle%22%5D%5B'c'%5D%5D) == 'Reference':%0A        if key == %22DefinitionList%22:%0A            for definition in value:%0A                definition%5B0%5D = keyword2html(definition%5B0%5D)%0A            return %7B%22t%22: key,%0A                    %22c%22: value%7D%0A%0Aif __name__ == '__main__':%0A    pf.toJSONFilter(id4glossary)%0A

Add id to glossary entry