1
0
mirror of https://github.com/venthur/blag.git synced 2025-11-25 20:52:43 +00:00

Compare commits

..

51 Commits
0.0.5 ... 1.2.0

Author SHA1 Message Date
Bastian Venthur
db30fe1d06 bumped version 2021-11-06 15:01:11 +01:00
Bastian Venthur
27a760d834 Merge pull request #17 from venthur/fix_autoreload
Fix autoreload
2021-11-06 15:00:08 +01:00
Bastian Venthur
a9abcd753a updated changelog 2021-11-06 14:59:53 +01:00
Bastian Venthur
3deb62ed88 Merge pull request #16 from venthur/dependabot/pip/twine-3.5.0
Bump twine from 3.4.2 to 3.5.0
2021-11-06 14:58:38 +01:00
Bastian Venthur
2366a2ae86 print the devserver URL to output 2021-11-06 14:57:37 +01:00
Bastian Venthur
0fb01e3249 updated changelog 2021-11-06 14:53:56 +01:00
Bastian Venthur
78316725cf remove warning in test due to threading race condition we don´t care
about
2021-11-06 14:51:46 +01:00
Bastian Venthur
4f1632e3cd Immediately rebuild once when entering autoreload 2021-11-06 14:12:57 +01:00
dependabot[bot]
d23f3666dc Bump twine from 3.4.2 to 3.5.0
Bumps [twine](https://github.com/pypa/twine) from 3.4.2 to 3.5.0.
- [Release notes](https://github.com/pypa/twine/releases)
- [Changelog](https://github.com/pypa/twine/blob/main/docs/changelog.rst)
- [Commits](https://github.com/pypa/twine/compare/3.4.2...3.5.0)

---
updated-dependencies:
- dependency-name: twine
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-11-04 14:17:19 +00:00
Bastian Venthur
60cfd0290a updated changelog 2021-10-23 12:21:05 +02:00
Bastian Venthur
10ea8df1ac Merge pull request #12 from venthur/dependabot/pip/jinja2-3.0.2
Bump jinja2 from 3.0.1 to 3.0.2
2021-10-23 12:18:37 +02:00
Bastian Venthur
edc89581af Merge pull request #14 from venthur/dependabot/pip/pytest-cov-3.0.0
Bump pytest-cov from 2.12.1 to 3.0.0
2021-10-23 12:17:35 +02:00
dependabot[bot]
6d75891ace Bump pytest-cov from 2.12.1 to 3.0.0
Bumps [pytest-cov](https://github.com/pytest-dev/pytest-cov) from 2.12.1 to 3.0.0.
- [Release notes](https://github.com/pytest-dev/pytest-cov/releases)
- [Changelog](https://github.com/pytest-dev/pytest-cov/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest-cov/compare/v2.12.1...v3.0.0)

---
updated-dependencies:
- dependency-name: pytest-cov
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-23 10:16:33 +00:00
Bastian Venthur
6367f5a55a Merge branch 'master' of github.com:venthur/blag 2021-10-23 12:16:06 +02:00
dependabot[bot]
3cd316a537 Bump jinja2 from 3.0.1 to 3.0.2
Bumps [jinja2](https://github.com/pallets/jinja) from 3.0.1 to 3.0.2.
- [Release notes](https://github.com/pallets/jinja/releases)
- [Changelog](https://github.com/pallets/jinja/blob/main/CHANGES.rst)
- [Commits](https://github.com/pallets/jinja/compare/3.0.1...3.0.2)

---
updated-dependencies:
- dependency-name: jinja2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-23 10:15:27 +00:00
Bastian Venthur
3b8d2fe9d6 Merge pull request #15 from venthur/dependabot/pip/flake8-4.0.1
Bump flake8 from 3.9.2 to 4.0.1
2021-10-23 12:15:06 +02:00
Bastian Venthur
1fe576a771 Merge pull request #13 from venthur/dependabot/pip/feedgenerator-2.0.0
Bump feedgenerator from 1.9.2 to 2.0.0
2021-10-23 12:14:39 +02:00
Bastian Venthur
2f4d2267a0 fixed typo in changelog 2021-10-23 12:08:13 +02:00
dependabot[bot]
7bb51ff060 Bump flake8 from 3.9.2 to 4.0.1
Bumps [flake8](https://github.com/pycqa/flake8) from 3.9.2 to 4.0.1.
- [Release notes](https://github.com/pycqa/flake8/releases)
- [Commits](https://github.com/pycqa/flake8/compare/3.9.2...4.0.1)

---
updated-dependencies:
- dependency-name: flake8
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-11 14:17:10 +00:00
dependabot[bot]
5a8012d62b Bump feedgenerator from 1.9.2 to 2.0.0
Bumps [feedgenerator](https://github.com/getpelican/feedgenerator) from 1.9.2 to 2.0.0.
- [Release notes](https://github.com/getpelican/feedgenerator/releases)
- [Changelog](https://github.com/getpelican/feedgenerator/blob/master/CHANGELOG.md)
- [Commits](https://github.com/getpelican/feedgenerator/compare/1.9.2...2.0.0)

---
updated-dependencies:
- dependency-name: feedgenerator
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-06 14:23:13 +00:00
Bastian Venthur
713b53d0d9 bumped version 2021-10-06 13:34:03 +02:00
Bastian Venthur
2d1d0ab302 Merge pull request #9 from venthur/0130dependabot/pip/twine-3.4.2
Bump twine from 3.4.1 to 3.4.2
2021-10-06 13:30:29 +02:00
dependabot[bot]
572710fab1 Bump twine from 3.4.1 to 3.4.2
Bumps [twine](https://github.com/pypa/twine) from 3.4.1 to 3.4.2.
- [Release notes](https://github.com/pypa/twine/releases)
- [Changelog](https://github.com/pypa/twine/blob/main/docs/changelog.rst)
- [Commits](https://github.com/pypa/twine/compare/3.4.1...3.4.2)

---
updated-dependencies:
- dependency-name: twine
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-06 11:30:11 +00:00
Bastian Venthur
0b66c5fbf4 Merge pull request #7 from venthur/902edependabot/pip/wheel-0.37.0
Bump wheel from 0.36.2 to 0.37.0
2021-10-06 13:29:28 +02:00
dependabot[bot]
18ecd82c5a Bump wheel from 0.36.2 to 0.37.0
Bumps [wheel](https://github.com/pypa/wheel) from 0.36.2 to 0.37.0.
- [Release notes](https://github.com/pypa/wheel/releases)
- [Changelog](https://github.com/pypa/wheel/blob/master/docs/news.rst)
- [Commits](https://github.com/pypa/wheel/compare/0.36.2...0.37.0)

---
updated-dependencies:
- dependency-name: wheel
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-06 11:27:47 +00:00
Bastian Venthur
a74f36be8a Merge pull request #6 from venthur/ae1edependabot/pip/pygments-2.10.0
Bump pygments from 2.9.0 to 2.10.0
2021-10-06 13:27:30 +02:00
Bastian Venthur
dd7d6cdae2 Merge pull request #10 from venthur/5121dependabot/pip/pytest-6.2.5
Bump pytest from 6.2.4 to 6.2.5
2021-10-06 13:27:09 +02:00
Bastian Venthur
39e6aa2676 Merge pull request #11 from venthur/12a6dependabot/pip/sphinx-4.2.0
Bump sphinx from 4.0.1 to 4.2.0
2021-10-06 13:26:56 +02:00
Bastian Venthur
93f6840168 Merge pull request #5 from venthur/py310
added python 3.10 to ci pipeline
2021-10-06 13:23:19 +02:00
Bastian Venthur
e27d82ac2a Merge branch 'master' into py310 2021-10-06 13:23:02 +02:00
Bastian Venthur
88b4fc8233 minor fix 2021-10-06 13:18:37 +02:00
dependabot[bot]
8923b0bb6e Bump sphinx from 4.0.1 to 4.2.0
Bumps [sphinx](https://github.com/sphinx-doc/sphinx) from 4.0.1 to 4.2.0.
- [Release notes](https://github.com/sphinx-doc/sphinx/releases)
- [Changelog](https://github.com/sphinx-doc/sphinx/blob/4.x/CHANGES)
- [Commits](https://github.com/sphinx-doc/sphinx/compare/v4.0.1...v4.2.0)

---
updated-dependencies:
- dependency-name: sphinx
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-13 14:30:08 +00:00
dependabot[bot]
2671239ac1 Bump pytest from 6.2.4 to 6.2.5
Bumps [pytest](https://github.com/pytest-dev/pytest) from 6.2.4 to 6.2.5.
- [Release notes](https://github.com/pytest-dev/pytest/releases)
- [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest/compare/6.2.4...6.2.5)

---
updated-dependencies:
- dependency-name: pytest
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-31 14:16:34 +00:00
dependabot[bot]
7aa6cebb63 Bump pygments from 2.9.0 to 2.10.0
Bumps [pygments](https://github.com/pygments/pygments) from 2.9.0 to 2.10.0.
- [Release notes](https://github.com/pygments/pygments/releases)
- [Changelog](https://github.com/pygments/pygments/blob/master/CHANGES)
- [Commits](https://github.com/pygments/pygments/compare/2.9.0...2.10.0)

---
updated-dependencies:
- dependency-name: pygments
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-18 18:41:36 +00:00
Bastian Venthur
4869ea0fd2 Merge pull request #4 from venthur/dependabot
Create dependabot.yml
2021-08-18 20:41:11 +02:00
Bastian Venthur
aeedd9b73a added changelog entry 2021-08-18 20:40:15 +02:00
Bastian Venthur
52412b8926 fix string for python 3.10 m( 2021-08-18 20:30:45 +02:00
Bastian Venthur
c0dae31b60 added python 3.10 to ci pipeline 2021-08-18 20:29:45 +02:00
Bastian Venthur
2366ee2def Create dependabot.yml 2021-08-18 20:26:34 +02:00
Bastian Venthur
67f24642e5 bumped dependency to feedgenerator to version that uses description as a
subtitle for the feed.

bumped version.
2021-08-18 20:14:40 +02:00
Bastian Venthur
f1020637e6 bumped version, added changelog url 2021-06-22 22:13:04 +02:00
Bastian Venthur
a4d596b79d updated dependencies 2021-06-22 22:12:29 +02:00
Bastian Venthur
79edd04ee8 added smartypants support 2021-04-18 13:03:05 +02:00
Bastian Venthur
9cdecdccf7 replaced args with cleandir where possible, removed tempdir 2021-03-29 13:22:04 +02:00
Bastian Venthur
499b0dfe11 added cleandir to change cwd 2021-03-29 13:02:12 +02:00
Bastian Venthur
72971408b2 added tests for build and main 2021-03-29 12:40:13 +02:00
Bastian Venthur
6445f31204 fixed bug so empty tags don't throw an error 2021-03-29 12:39:52 +02:00
Bastian Venthur
98b97fbbbd fixed bug in blag where context was not provided to pages 2021-03-29 12:06:08 +02:00
Bastian Venthur
df65dee488 added conftest 2021-03-29 12:01:09 +02:00
Bastian Venthur
d227392c79 put fixtures into conftest 2021-03-29 11:59:43 +02:00
Bastian Venthur
03663a855d added project urls 2021-03-28 11:16:41 +02:00
15 changed files with 341 additions and 88 deletions

6
.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "daily"

View File

@@ -19,6 +19,7 @@ jobs:
python-version:
- 3.8
- 3.9
- "3.10"
steps:
- uses: actions/checkout@v2

View File

@@ -1,6 +1,35 @@
# Changelog
## [0.0.0] - YYYY-MM-DD
## [1.2.0] - 2021-11-06
*
* `make serve` now rebuilds immediately once after called to avoid serving
stale files
* updated dependencies:
* feedgenerator 2.0.0
* jinja2 3.0.1
* pytest-cov 3.0.0
* flake8 4.0.1
* twine 3.5.0
## [1.1.0] - 2021-10-06
* added Python 3.10 to list of supported versions to test against
* added dependabot to github workflows
* updated various dependencies:
* pygments 2.10.0
* sphinx 4.2.0
* twine 3.4.2
* wheel 0.37.0
* pytest 6.2.5
## [1.0.0] - 2021-08-18
* first 1.0 release!
* bump requirements of feedgenerator to 1.9.2. this version uses the
description to provide a subtitle for the feed
## [0.0.9] - 2021-06-22
* updated to jinja 3.0
* updated to sphinx 4.0
* added link to changelog

View File

@@ -289,7 +289,7 @@ def process_markdown(convertibles, input_dir, output_dir,
articles.append((dst, context))
result = article_template.render(context)
else:
pages.append((dst, content))
pages.append((dst, context))
result = page_template.render(context)
with open(f'{output_dir}/{dst}', 'w') as fh_dest:
fh_dest.write(result)
@@ -392,7 +392,7 @@ def generate_tags(articles, tags_template, tag_template, output_dir):
# get tags number of occurrences
all_tags = {}
for _, context in articles:
tags = context.get('tags', None)
tags = context.get('tags', [])
for tag in tags:
all_tags[tag] = all_tags.get(tag, 0) + 1
# sort by occurrence
@@ -405,7 +405,7 @@ def generate_tags(articles, tags_template, tag_template, output_dir):
# get tags and archive per tag
all_tags = {}
for dst, context in articles:
tags = context.get('tags', None)
tags = context.get('tags', [])
for tag in tags:
archive = all_tags.get(tag, [])
entry = context.copy()

View File

@@ -55,6 +55,9 @@ def autoreload(args):
last modified time). If the last modified time has changed, a
rebuild is triggered.
A rebuild is also performed immediately when this method is called
to avoid serving stale contents.
Parameters
----------
args : argparse.Namespace
@@ -62,12 +65,14 @@ def autoreload(args):
"""
dirs = [args.input_dir, args.template_dir, args.static_dir]
logger.info(f'Monitoring {dirs} for changes...')
last_mtime = get_last_modified(dirs)
# make sure we trigger the rebuild immediately when we enter the
# loop to avoid serving stale contents
last_mtime = 0
while True:
mtime = get_last_modified(dirs)
if mtime > last_mtime:
last_mtime = mtime
logger.debug('Change detected, rebuilding...')
logger.info('Change detected, rebuilding...')
blag.build(args)
time.sleep(1)
@@ -84,4 +89,5 @@ def serve(args):
directory=args.output_dir))
proc = multiprocessing.Process(target=autoreload, args=(args,))
proc.start()
logger.info("\n\n Devserver Started -- visit http://localhost:8000\n")
httpd.serve_forever()

View File

@@ -30,7 +30,7 @@ def markdown_factory():
"""
md = Markdown(
extensions=[
'meta', 'fenced_code', 'codehilite',
'meta', 'fenced_code', 'codehilite', 'smarty',
MarkdownLinkExtension()
],
output_format='html5',

View File

@@ -1 +1 @@
__VERSION__ = '0.0.5'
__VERSION__ = '1.2.0'

View File

@@ -1,6 +1,6 @@
sphinx==3.5.3
twine==3.4.1
wheel==0.36.2
pytest==6.2.2
pytest-cov==2.11.1
flake8==3.9.0
sphinx==4.2.0
twine==3.5.0
wheel==0.37.0
pytest==6.2.5
pytest-cov==3.0.0
flake8==4.0.1

View File

@@ -1,4 +1,4 @@
markdown==3.3.4
feedgenerator==1.9.1
jinja2==2.11.3
pygments==2.8.1
feedgenerator==2.0.0
jinja2==3.0.2
pygments==2.10.0

View File

@@ -1,6 +1,5 @@
#!/usr/bin/env python
from setuptools import setup
meta = {}
@@ -17,6 +16,12 @@ setup(
author='Bastian Venthur',
author_email='mail@venthur.de',
url='https://github.com/venthur/blag',
project_urls={
'Documentation': 'https://blag.readthedocs.io/',
'Source': 'https://github.com/venthur/blag',
'Changelog':
'https://github.com/venthur/blag/blob/master/CHANGELOG.md',
},
python_requires='>=3.8',
package_data={
'blag': ['templates/*'],

86
tests/conftest.py Normal file
View File

@@ -0,0 +1,86 @@
from tempfile import TemporaryDirectory
import os
import pytest
from blag import blag
@pytest.fixture
def environment():
site = {
'base_url': 'site base_url',
'title': 'site title',
'description': 'site description',
'author': 'site author',
}
env = blag.environment_factory(globals_=dict(site=site))
yield env
@pytest.fixture
def page_template(environment):
yield environment.get_template('page.html')
@pytest.fixture
def article_template(environment):
yield environment.get_template('article.html')
@pytest.fixture
def archive_template(environment):
yield environment.get_template('archive.html')
@pytest.fixture
def tags_template(environment):
yield environment.get_template('tags.html')
@pytest.fixture
def tag_template(environment):
yield environment.get_template('tag.html')
@pytest.fixture
def cleandir():
"""Create a temporary workind directory and cwd.
"""
config = """
[main]
base_url = https://example.com/
title = title
description = description
author = a. u. thor
"""
with TemporaryDirectory() as dir:
for d in 'content', 'build', 'static', 'templates':
os.mkdir(f'{dir}/{d}')
with open(f'{dir}/config.ini', 'w') as fh:
fh.write(config)
# change directory
old_cwd = os.getcwd()
os.chdir(dir)
yield dir
# and change back afterwards
os.chdir(old_cwd)
@pytest.fixture
def args(cleandir):
class NameSpace:
def __init__(self, **kwargs):
for name in kwargs:
setattr(self, name, kwargs[name])
args = NameSpace(
input_dir='content',
output_dir='build',
static_dir='static',
template_dir='templates',
)
yield args

View File

@@ -7,19 +7,13 @@ import pytest
from blag import blag
@pytest.fixture
def outdir():
with TemporaryDirectory() as dir:
yield dir
def test_generate_feed(outdir):
def test_generate_feed(cleandir):
articles = []
blag.generate_feed(articles, outdir, ' ', ' ', ' ', ' ')
assert os.path.exists(f'{outdir}/atom.xml')
blag.generate_feed(articles, 'build', ' ', ' ', ' ', ' ')
assert os.path.exists('build/atom.xml')
def test_feed(outdir):
def test_feed(cleandir):
articles = [
[
'dest1.html',
@@ -40,9 +34,9 @@ def test_feed(outdir):
]
blag.generate_feed(articles, outdir, 'https://example.com/', 'blog title',
'blog description', 'blog author')
with open(f'{outdir}/atom.xml') as fh:
blag.generate_feed(articles, 'build', 'https://example.com/',
'blog title', 'blog description', 'blog author')
with open('build/atom.xml') as fh:
feed = fh.read()
assert '<title>blog title</title>' in feed
@@ -66,7 +60,7 @@ def test_feed(outdir):
assert '<link href="https://example.com/dest2.html"' in feed
def test_generate_feed_with_description(outdir):
def test_generate_feed_with_description(cleandir):
# if a description is provided, it will be used as the summary in
# the feed, otherwise we simply use the title of the article
articles = [[
@@ -78,9 +72,9 @@ def test_generate_feed_with_description(outdir):
'content': 'content',
}
]]
blag.generate_feed(articles, outdir, ' ', ' ', ' ', ' ')
blag.generate_feed(articles, 'build', ' ', ' ', ' ', ' ')
with open(f'{outdir}/atom.xml') as fh:
with open('build/atom.xml') as fh:
feed = fh.read()
assert '<title>title</title>' in feed
@@ -180,3 +174,106 @@ def test_environment_factory():
env = blag.environment_factory(globals_=globals_)
assert env.globals['foo'] == 'bar'
assert env.globals['test'] == 'me'
def test_process_markdown(cleandir, page_template, article_template):
page1 = """\
title: some page
some text
foo bar
"""
article1 = """\
title: some article1
date: 2020-01-01
some text
foo bar
"""
article2 = """\
title: some article2
date: 2021-01-01
some text
foo bar
"""
convertibles = []
for i, txt in enumerate((page1, article1, article2)):
i = str(i)
with open(f'content/{i}', 'w') as fh:
fh.write(txt)
convertibles.append([i, i])
articles, pages = blag.process_markdown(
convertibles,
'content',
'build',
page_template,
article_template
)
assert isinstance(articles, list)
assert len(articles) == 2
for dst, context in articles:
assert isinstance(dst, str)
assert isinstance(context, dict)
assert 'content' in context
assert isinstance(pages, list)
assert len(pages) == 1
for dst, context in pages:
assert isinstance(dst, str)
assert isinstance(context, dict)
assert 'content' in context
def test_build(args):
page1 = """\
title: some page
some text
foo bar
"""
article1 = """\
title: some article1
date: 2020-01-01
tags: foo, bar
some text
foo bar
"""
article2 = """\
title: some article2
date: 2021-01-01
tags: baz
some text
foo bar
"""
# write some convertibles
convertibles = []
for i, txt in enumerate((page1, article1, article2)):
i = str(i)
with open(f'{args.input_dir}/{i}.md', 'w') as fh:
fh.write(txt)
convertibles.append([i, i])
# some static files
with open(f'{args.static_dir}/test', 'w') as fh:
fh.write('hello')
os.mkdir(f'{args.input_dir}/testdir')
with open(f'{args.input_dir}/testdir/test', 'w') as fh:
fh.write('hello')
blag.build(args)
def test_main(cleandir):
blag.main(['build'])

View File

@@ -1,30 +1,66 @@
import time
import threading
import pytest
from tempfile import TemporaryDirectory
from blag import devserver
@pytest.fixture
def tempdir():
with TemporaryDirectory() as dir:
yield dir
def test_get_last_modified(tempdir):
def test_get_last_modified(cleandir):
# take initial time
t1 = devserver.get_last_modified([tempdir])
t1 = devserver.get_last_modified(['content'])
# wait a bit, create a file and measure again
time.sleep(0.1)
with open(f'{tempdir}/test', 'w') as fh:
with open('content/test', 'w') as fh:
fh.write('boo')
t2 = devserver.get_last_modified([tempdir])
t2 = devserver.get_last_modified(['content'])
# wait a bit and take time again
time.sleep(0.1)
t3 = devserver.get_last_modified([tempdir])
t3 = devserver.get_last_modified(['content'])
assert t2 > t1
assert t2 == t3
def test_autoreload_builds_immediately(args):
# create a dummy file that can be build
with open('content/test.md', 'w') as fh:
fh.write('boo')
t = threading.Thread(target=devserver.autoreload,
args=(args, ),
daemon=True,)
t0 = devserver.get_last_modified(['build'])
t.start()
# try for 5 seconds...
for i in range(5):
time.sleep(1)
t1 = devserver.get_last_modified(['build'])
print(t1)
if t1 > t0:
break
assert t1 > t0
@pytest.mark.filterwarnings("ignore::pytest.PytestUnhandledThreadExceptionWarning") # noqa
def test_autoreload(args):
t = threading.Thread(target=devserver.autoreload,
args=(args, ),
daemon=True,)
t.start()
t0 = devserver.get_last_modified(['build'])
# create a dummy file that can be build
with open('content/test.md', 'w') as fh:
fh.write('boo')
# try for 5 seconds to see if we rebuild once...
for i in range(5):
time.sleep(1)
t1 = devserver.get_last_modified(['build'])
if t1 > t0:
break
assert t1 > t0

View File

@@ -49,3 +49,31 @@ def test_convert_metadata(input_, expected):
def test_markdown_factory():
md = markdown_factory()
assert isinstance(md, markdown.Markdown)
def test_smarty():
md = markdown_factory()
md1 = """
this --- is -- a test ...
"""
html, meta = convert_markdown(md, md1)
assert 'mdash' in html
assert 'ndash' in html
assert 'hellip' in html
def test_smarty_code():
md = markdown_factory()
md1 = """
```
this --- is -- a test ...
```
"""
html, meta = convert_markdown(md, md1)
assert 'mdash' not in html
assert 'ndash' not in html
assert 'hellip' not in html

View File

@@ -1,46 +1,5 @@
import datetime
import pytest
from blag import blag
@pytest.fixture
def environment():
site = {
'base_url': 'site base_url',
'title': 'site title',
'description': 'site description',
'author': 'site author',
}
env = blag.environment_factory(globals_=dict(site=site))
yield env
@pytest.fixture
def page_template(environment):
yield environment.get_template('page.html')
@pytest.fixture
def article_template(environment):
yield environment.get_template('article.html')
@pytest.fixture
def archive_template(environment):
yield environment.get_template('archive.html')
@pytest.fixture
def tags_template(environment):
yield environment.get_template('tags.html')
@pytest.fixture
def tag_template(environment):
yield environment.get_template('tag.html')
def test_page(page_template):
ctx = {