summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_compile_markdown.py10
-rw-r--r--tests/test_rst_compiler.py23
-rw-r--r--tests/test_utils.py26
3 files changed, 53 insertions, 6 deletions
diff --git a/tests/test_compile_markdown.py b/tests/test_compile_markdown.py
index 0e805ba..a902347 100644
--- a/tests/test_compile_markdown.py
+++ b/tests/test_compile_markdown.py
@@ -28,12 +28,10 @@ from .helper import FakeSite
from this
""",
"""\
-<table class="codehilitetable"><tr><td class="linenos">\
-<div class="linenodiv"><pre><span class="normal">1</span></pre></div>\
-</td><td class="code"><pre class="code literal-block"><span></span>\
-<code><span class="kn">from</span> <span class="nn">this</span>
-</code></pre>
-</td></tr></table>
+<div class="code"><table class="codetable"><tr><td class="linenos linenodiv">\
+<a href="#-1"><code data-line-number="1"></code></a></td>\
+<td class="code"><code><span class="kn">from</span> <span class="nn">this</span>
+</code></td></tr></table></div>
""",
id="hilite",
),
diff --git a/tests/test_rst_compiler.py b/tests/test_rst_compiler.py
index 803fd79..88638f7 100644
--- a/tests/test_rst_compiler.py
+++ b/tests/test_rst_compiler.py
@@ -87,6 +87,29 @@ def test_youtube_iframe():
)
+def test_youtube_iframe_start_at():
+ """Test Youtube iframe tag generation with start_at attribute"""
+
+ sample = ".. youtube:: YID\n :height: 400\n :width: 600\n :start_at: 60"
+ html = get_html_from_rst(sample)
+ assert_html_contains(
+ html,
+ "iframe",
+ attributes={
+ "src": (
+ "https://www.youtube-nocookie.com"
+ "/embed/YID?rel=0&"
+ "wmode=transparent&start=60"
+ ),
+ "height": "400",
+ "width": "600",
+ "frameborder": "0",
+ "allowfullscreen": "",
+ "allow": "encrypted-media",
+ },
+ )
+
+
def test_vimeo(disable_vimeo_api_query):
"""Test Vimeo iframe tag generation"""
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 1996679..764eec2 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -14,13 +14,16 @@ from nikola.post import get_meta
from nikola.utils import (
TemplateHookRegistry,
TranslatableSetting,
+ NikolaPygmentsHTML,
demote_headers,
get_asset_path,
get_crumbs,
get_theme_chain,
get_translation_candidate,
+ nikola_find_formatter_class,
write_metadata,
bool_from_meta,
+ parselinenos
)
@@ -619,3 +622,26 @@ class FakePost:
def __init__(self):
metadata_extractors.load_defaults(self, self.metadata_extractors_by)
+
+
+def test_parselinenos():
+ assert parselinenos('1,2,3', 10) == [0, 1, 2]
+ assert parselinenos('4, 5, 6', 10) == [3, 4, 5]
+ assert parselinenos('-4', 10) == [0, 1, 2, 3]
+ assert parselinenos('7-9', 10) == [6, 7, 8]
+ assert parselinenos('7-', 10) == [6, 7, 8, 9]
+ assert parselinenos('1,7-', 10) == [0, 6, 7, 8, 9]
+ assert parselinenos('7-7', 10) == [6]
+ assert parselinenos('11-', 10) == [10]
+ with pytest.raises(ValueError):
+ parselinenos('1-2-3', 10)
+ with pytest.raises(ValueError):
+ parselinenos('abc-def', 10)
+ with pytest.raises(ValueError):
+ parselinenos('-', 10)
+ with pytest.raises(ValueError):
+ parselinenos('3-1', 10)
+
+
+def test_nikola_find_formatter_class_returns_pygments_class():
+ assert NikolaPygmentsHTML == nikola_find_formatter_class("html")