Skip to content

Commit

Permalink
Merge branch 'feature/bootstrap-group-map' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
bboc committed Feb 10, 2024
2 parents 5fb786e + f11bd3c commit 830c8ef
Show file tree
Hide file tree
Showing 13 changed files with 81 additions and 37 deletions.
2 changes: 1 addition & 1 deletion docs-src/config/project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ defaults:
# these are available for substitution in templates
variables:
# Version of the practical guide (added to all releases)
version: "v2022-02-22"
version: "v2024-02-09"
# Language and text direction for Jekyll site and epub
html-language: "en"
html-dir: "ltr"
Expand Down
12 changes: 12 additions & 0 deletions docs-src/content/src/appendix/changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
## Changelog


### v2.1.3 (2024-02-09)

- proper rendering of markdown in html-summaries

### v2.1.2 (2022-04-05)

- fixed a bug that broke rendering of summaries for LaTeX

### v2.1.1 (2022-02-27)

- a couple of bug fixes

### v2.1.0 (2022-02-22)

- integration of Bootstrap 4
Expand Down
4 changes: 2 additions & 2 deletions docs/_includes/footer.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<div class="row">
<div class="col footer-top">
<p><strong>v2022-02-22</strong></p>
<p><strong>v2024-02-09</strong></p>
<p>{{ site.description }}</p>
<p>This work by Bernhard Bockelbrink is licensed under the GNU General Public License v3.0.</p>
<p>{{ site.license }}</p>
</div>
</div>
<div class="row">
Expand Down
4 changes: 2 additions & 2 deletions docs/_includes/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<a class="site-title" href="{{ relative_url }}/">{{ site.title }}</a>
</div>
<div class="header-icons col-2">
<a href="site-index.html" ><img src="{{ '/icons/list-ul.svg' | relative_url }}" class="icon" title="An alphabetical index of all pages." /></a>
<a href="map.html" ><img src="{{'/icons/map.svg' | relative_url }}" class="icon" title="Use the map to jump to another page." /></a>
<a href="{{'site-index.html' | relative_url }}" ><img src="{{ '/icons/list-ul.svg' | relative_url }}" class="icon" title="An alphabetical index of all pages." alt="site index" /></a>
<a href="{{'map.html' | relative_url }}" ><img src="{{'/icons/map.svg' | relative_url }}" class="icon" alt="map" title="Use the map to jump to another page." /></a>
<span id="annotate-span"><a href="" id="annotate-link"><img src="{{ '/icons/comments-alt.svg' | relative_url }}" class="icon" title="Annotate this page with hypothes.is. Click here, wait for the page to reload, then you can highlight text and add public comments. You will need to set up a free account at hypothes.is." alt="annotate page"/></a></span>
</div>
</div>
10 changes: 5 additions & 5 deletions docs/_includes/menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@

<li><a href="#">Quick Links</a>
<ul class="mega-menu">
<li><a href="index.html">Homepage</a></li>
<li><a href="glossary.html">Glossary</a></li>
<li><a href="changelog.html">Changelog</a></li>
<li><a href="site-index.html" title="An alphabetical index of all pages."><img src="{{ 'icons/list-ul.svg' | relative_url }}" class="icon" alt="site index" />&nbsp;Pattern Index</a></li>
<li><a href="map.html" title="Use the map to jump to another page."><img src="{{ 'icons/map.svg' | relative_url }}" class="icon" alt="site map" />&nbsp;Map</a></li>
<li><a href="{{ 'index.html' | relative_url }}">Homepage</a></li>
<li><a href="{{ 'glossary.html' | relative_url }}">Glossary</a></li>
<li><a href="{{ 'changelog.html' | relative_url }}">Changelog</a></li>
<li><a href="{{ 'site-index.html' | relative_url }}" title="An alphabetical index of all pages."><img src="{{ 'icons/list-ul.svg' | relative_url }}" class="icon" alt="site index" />&nbsp;Pattern Index</a></li>
<li><a href="{{ 'map.html' | relative_url }}" title="Use the map to jump to another page."><img src="{{ 'icons/map.svg' | relative_url }}" class="icon" alt="site map" />&nbsp;Map</a></li>
<li><span id="annotate-span"><a href="" id="annotate-link" title="Annotate this page with hypothes.is. Click here, wait for the page to reload, then you can highlight text and add public comments. You will need to set up a free account at hypothes.is."><img src="{{ 'icons/comments-alt.svg' | relative_url }}" class="icon" alt="annotate page" />&nbsp;Annotate Page</a></span></li>
<li><a href="https://patterns.sociocracy30.org">A real-world example of a book built with mdtools</a></li>
</ul>
Expand Down
14 changes: 14 additions & 0 deletions docs/all.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ Usage: see `mdimg -h`

<div class="card summary"><div class="card-body">The various output formats require certain styles and other assets, this part of the documentation explains where goes what.
</div></div>

Since this documentation makes use of all those formats, so you can find everything described here this repository.


Expand Down Expand Up @@ -390,6 +391,18 @@ If templates contain translatable content, simply store them inside the content
#### Changelog


##### v2.1.3 (2024-02-09)

- proper rendering of markdown in html-summaries

##### v2.1.2 (2022-04-05)

- fixed a bug that broke rendering of summaries for LaTeX

##### v2.1.1 (2022-02-27)

- a couple of bug fixes

##### v2.1.0 (2022-02-22)

- integration of Bootstrap 4
Expand Down Expand Up @@ -508,6 +521,7 @@ If templates contain translatable content, simply store them inside the content

<div class="card summary"><div class="card-body">This page contains most of the Markdown syntax elements and several macros, so that you can check if the output looks ok in the various output formats. It doesn't cover all the edge cases, but it provides a solid start.
</div></div>

(The above paragraph is tagged as summary!)


Expand Down
9 changes: 9 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ prev_page_url: "glossary.html"
---



### v2.1.3 (2024-02-09)

- proper rendering of markdown in html-summaries

### v2.1.2 (2022-04-05)

- fixed a bug that broke rendering of summaries for LaTeX

### v2.1.1 (2022-02-27)

- a couple of bug fixes
Expand Down
6 changes: 3 additions & 3 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<article class="homepage">
<h1>mdtools documentation (Online Version)</h1>

<p class="hp-version small">v2022-02-22</p>
<p class="hp-version small">v2024-02-09</p>

<div class="card hp-box-green">
<div class="card-body">
Expand All @@ -30,9 +30,9 @@ <h5 class="card-title">Chapters</h5>
<h5 class="card-title">Keyboard Shortcuts</h5>
<p class="card-text">For those of you who use the Practical Guide in their daily work, we added some keyboard shortcuts to make your life a little easier.</p>

<p class="card-text"><strong>Shift + m</strong> will open the <strong>m</strong>enu, which you can then navigate with the arrow keys, and select an item with &lt;space&gt; or &lt;enter&gt; keys.</p>
<p class="card-text"><strong>Shift + m</strong> will open the <strong>m</strong>enu, which you can then navigate with the arrow keys, and select an item with &lt;space&lt; or &lt;enter&lt;</p>

<p class="card-text">The following commants will take you to specific pages, for all of those you will have to type 'g' (for 'Go'), followed by another letter:</p>
<p class="card-text">The following commands will take you to specific pages, for all of those you will have to type 'g' (for 'Go'), followed by another letter:</p>

<ul class="card-text">
<li><em>g n</em><strong>G</strong>o to the <strong>N</strong>ext page in the book</li>
Expand Down
1 change: 1 addition & 0 deletions docs/markdown-cheat-sheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ prev_page_url: "site-index.html"

<div class="card summary"><div class="card-body">This page contains most of the Markdown syntax elements and several macros, so that you can check if the output looks ok in the various output formats. It doesn't cover all the edge cases, but it provides a solid start.
</div></div>

(The above paragraph is tagged as summary!)


Expand Down
1 change: 1 addition & 0 deletions docs/styles-and-assets.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ prev_page_url: "mdimg.html"

<div class="card summary"><div class="card-body">The various output formats require certain styles and other assets, this part of the documentation explains where goes what.
</div></div>

Since this documentation makes use of all those formats, so you can find everything described here this repository.


Expand Down
2 changes: 1 addition & 1 deletion mdbuild/renderer/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def jekyll_front_matter(metadata, lines):
"""
Inject Jekyll front matter.
TODO: this should use the library for yaml, insert handcrafted lines of text!
TODO: this should use the library for yaml, instead of handcrafted lines of text!
"""

def escape_quotes(text):
Expand Down
51 changes: 29 additions & 22 deletions mdbuild/renderer/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import re
from functools import partial
import logging
import markdown

from .common import HEADLINE_PATTERN

Expand All @@ -12,15 +13,17 @@
class MetadataFilter(object):
"""Process stream and extract/process metadata (title, summary etc.)"""

# extracted metadata
# extracted metadata (acessed from outside)
title = None
summary = None
metadata = None
summary_lines = None

# store next filter funktion to use
filter_function = None
# store next filter function to use
_filter_function = None

# internal buffer for summary
_summary_lines = None

METADATA_PATTERN = re.compile(r'\[\:(?P<key>.*?)\]: # \"(?P<value>.*?)\"')
YAML_METADATA_PATTERN = re.compile(r'(?P<key>.*?):\w+\"(?P<value>.*?)\"')

Expand All @@ -32,7 +35,7 @@ class MetadataFilter(object):
SUMMARY_MARKUP = {
'html': {
BEGIN_SUMMARY: '<div class="card summary"><div class="card-body">',
END_SUMMARY: '</div></div>',
END_SUMMARY: '</div></div>\n',
},
'epub': {
BEGIN_SUMMARY: '<p class="summary">',
Expand All @@ -44,7 +47,7 @@ class MetadataFilter(object):
},
None: {
BEGIN_SUMMARY: None,
END_SUMMARY: None,
END_SUMMARY: '\n',
},
'preserve': {
BEGIN_SUMMARY: BEGIN_SUMMARY,
Expand All @@ -67,7 +70,7 @@ def _header_filter(cls, line, after_metadata=False):
key = match.groupdict()['key']
value = match.groupdict()['value']
cls.metadata[key] = value
cls.filter_function = cls._header_filter
cls._filter_function = cls._header_filter
return None

elif line.strip().startswith('#'):
Expand All @@ -78,17 +81,17 @@ def _header_filter(cls, line, after_metadata=False):
except AttributeError:
logger.warning("title not set")
cls.title = ''
cls.filter_function = cls._standard_filter
cls._filter_function = cls._standard_filter
return line

elif line.strip() == '':
# process empty line
if after_metadata:
cls.filter_function = cls._standard_filter
cls._filter_function = cls._standard_filter
return line
else:
# ignore one blank line
cls.filter_function = partial(cls._header_filter, after_metadata=True)
cls._filter_function = partial(cls._header_filter, after_metadata=True)
return None
else:
raise Exception('Metadata must be followed by an empty line!')
Expand All @@ -102,26 +105,30 @@ def _summary_filter(cls, line):
Transition to standard filter after end of summary.
"""
if line.strip() == cls.END_SUMMARY:
cls.filter_function = cls._standard_filter
cls._filter_function = cls._standard_filter
return cls.SUMMARY_MARKUP[cls.target_format][cls.END_SUMMARY]
else:
# remove bold around summary if present
if line.startswith("**") or line.startswith("__"):
sline = line.strip()[2:-2]
else:
sline = line
cls.summary_lines.append(sline)
cls.summary = '\n'.join(cls.summary_lines)
sline = line.strip()
cls._summary_lines.append(sline)
cls.summary = '\n'.join(cls._summary_lines)

if cls.target_format == 'latex':
# wrap summary in bold for latex (for now)
# TODO: add LaTeX markup for a proper box or something nice
if line.startswith("**") or line.startswith("__"):
pass
else:
line = "**%s**" % line
cls.filter_function = cls._summary_filter
return line
line = "**%s**\n\n" % line.strip()
cls._filter_function = cls._summary_filter
if cls.target_format == "html":
# render to markdown (and strip <p>)
return markdown.markdown(line)[3:-4] + "\n"
else:
return line

@classmethod
def _standard_filter(cls, line):
Expand All @@ -131,10 +138,10 @@ def _standard_filter(cls, line):
Transition to summary filter on encountering summary tag.
"""
if line.strip() == cls.BEGIN_SUMMARY:
cls.filter_function = cls._summary_filter
cls._filter_function = cls._summary_filter
return cls.SUMMARY_MARKUP[cls.target_format][cls.BEGIN_SUMMARY]
else:
cls.filter_function = cls._standard_filter
cls._filter_function = cls._standard_filter
return line

@classmethod
Expand Down Expand Up @@ -169,15 +176,15 @@ def filter(cls, lines, target_format=None):
# Initialize all class variables
cls.title = None
cls.summary = None
cls.summary_lines = []
cls._summary_lines = []
cls.metadata = {}
cls.target_format = target_format

if target_format not in cls.SUMMARY_MARKUP:
raise Exception("Error: unknown target_format '%s'" % target_format)

cls.filter_function = cls._header_filter
cls._filter_function = cls._header_filter
for line in lines:
res = cls.filter_function(line)
res = cls._filter_function(line)
if res is not None:
yield res
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def read(fname):
# TODO: make a nicer setup.py from https://github.com/navdeep-G/setup.py
setup(
name="mdtools",
version='2.1.1',
version='2.1.3',
packages=find_packages(exclude=["tests", "*.tests", "*.tests.*", "tests.*"]),
install_requires=['polib'],
author="Bernhard Bockelbrink",
Expand Down

0 comments on commit 830c8ef

Please sign in to comment.