diff --git a/cl-theme/static/css/style.css b/cl-theme/static/css/style.css index 1e594fd..db822ef 100644 --- a/cl-theme/static/css/style.css +++ b/cl-theme/static/css/style.css @@ -503,20 +503,57 @@ h4 > a:hover { /* aplaylist */ .play-menu { - height: 200px; - overflow-y: auto; + height: 200px; + overflow-y: auto; } .play-menu a { - color: white; + color: white; } .play-menu a:hover { - background-color: #484848; - color: #fff; + background-color: #484848; + color: #fff; } .is-active-play { - color: #dd7325; - background-color: #dd7325; + color: #dd7325; + background-color: #dd7325; +} + +/* table of contents */ +.toc { + font-size: 0.85rem; +} + +.toctitle { + display: block; + text-align: center; + font-size: 1rem; + color: white; + text-decoration: underline; +} + +nav.toc { + background-color: #0c0f0f; + border: 1px solid #dd7325; + margin: 1rem 0px; +} + +div.toc { + margin: 1rem; +} + +a.headerlink { + color: grey; + padding-left: .5em; + visibility: hidden; +} + +h1:hover > a.headerlink, h2:hover > a.headerlink, +h3:hover > a.headerlink, h4:hover > a.headerlink, +h5:hover > a.headerlink, h6:hover > a.headerlink, +dt:hover > a.headerlink { + text-decoration: none; + visibility: visible; } diff --git a/cl-theme/templates/article.html b/cl-theme/templates/article.html index 836f24b..1b416b7 100644 --- a/cl-theme/templates/article.html +++ b/cl-theme/templates/article.html @@ -77,6 +77,12 @@
+ {% if article.toc %} + + {% endif %} + {{ article.content }}
diff --git a/pelicanconf.py b/pelicanconf.py index 45f283f..226e778 100644 --- a/pelicanconf.py +++ b/pelicanconf.py @@ -12,6 +12,10 @@ DISPLAY_CATEGORIES_ON_MENU = True DISPLAY_PAGES_ON_MENU = True MARKDOWN = { 'extension_configs': { + 'markdown.extensions.toc': { + 'title': 'Tabla de Contenidos', + 'permalink': 'true' + }, 'markdown.extensions.codehilite': {'css_class': 'highlight'}, 'markdown.extensions.extra': {}, 'markdown.extensions.footnotes': {'BACKLINK_TITLE': 'Volver a la nota %d en el texto'}, @@ -24,7 +28,7 @@ MARKDOWN = { PATH = 'content' PLUGIN_PATHS = ['plugins'] -PLUGINS = ['another_read_more_link', 'i18n_subsites', 'neighbors', 'pelican-css', 'pelican-js', 'sitemap', 'tag-cloud', 'tipue-search'] +PLUGINS = ['another_read_more_link', 'extract_toc', 'i18n_subsites', 'neighbors', 'pelican-css', 'pelican-js', 'sitemap', 'tag-cloud', 'tipue-search'] SITENAME = 'Conocimientos Libres' SITENAME_SINGLE = 'CL' SITEURL = 'https://conocimientoslibres.tuxfamily.org' @@ -128,6 +132,9 @@ I18N_SUBSITES = { 'LOCALE': ('en_US.UTF-8'), 'MARKDOWN': { 'extension_configs': { + 'markdown.extensions.toc': { + 'title': 'Table of Contents', + }, 'markdown.extensions.codehilite': {'css_class': 'highlight'}, 'markdown.extensions.extra': {}, 'markdown.extensions.footnotes': {'BACKLINK_TITLE': 'Jump back to footnote %d in the text'}, diff --git a/plugins/extract_toc/README.md b/plugins/extract_toc/README.md new file mode 100644 index 0000000..40d2bee --- /dev/null +++ b/plugins/extract_toc/README.md @@ -0,0 +1,137 @@ +Extract Table of Content +======================== + +A Pelican plugin to extract table of contents (ToC) from `article.content` and +place it in its own `article.toc` variable for use in templates. + +Copyright (c) Talha Mansoor + +Author | Talha Mansoor +----------------|----- +Author Email | talha131@gmail.com +Author Homepage | http://onCrashReboot.com +Github Account | https://github.com/talha131 + + +Acknowledgement +--------------- + +Thanks to [Avaris](https://github.com/avaris) for going out of the way to help +me fix Unicode issues and doing a thorough code review. + +Thanks to [gw0](http://gw.tnode.com/) for adding Pandoc reader support. + + +Why do you need it? +=================== + +Pelican can generate ToC of reST and Markdown files, using markup's respective +directive and extension. Such ToC is generated and placed at the beginning of +`article.content` like a string. Consequently it can not be placed anywhere +else on the page (eg. `