File tree Expand file tree Collapse file tree 3 files changed +18
-6
lines changed Expand file tree Collapse file tree 3 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -32,11 +32,11 @@ def content(app):
32
32
return app
33
33
34
34
35
- def _meta_tags (content , subdir = None ):
35
+ def _meta_tags (content , subdir = None , target = 'index.html' ):
36
36
if subdir is None :
37
- c = (content .outdir / 'index.html' ).read_text (encoding = 'utf-8' )
37
+ c = (content .outdir / target ).read_text (encoding = 'utf-8' )
38
38
else :
39
- c = (content .outdir / subdir / 'index.html' ).read_text (encoding = 'utf-8' )
39
+ c = (content .outdir / subdir / target ).read_text (encoding = 'utf-8' )
40
40
return BeautifulSoup (c , 'html.parser' ).find_all ('meta' )
41
41
42
42
@@ -53,9 +53,7 @@ def meta_tags(content):
53
53
54
54
@pytest .fixture
55
55
def og_meta_tags (content ):
56
- return [
57
- tag for tag in _meta_tags (content ) if tag .get ('property' , '' ).startswith ('og:' )
58
- ]
56
+ return _og_meta_tags (content )
59
57
60
58
61
59
@pytest .fixture
Original file line number Diff line number Diff line change 8
8
html_theme = 'basic'
9
9
10
10
ogp_site_url = 'http://example.org/en/latest/'
11
+
12
+ # needed for ePub build
13
+ epub_copyright = 'sphinxext.opengraph team'
14
+ version = '1.0'
Original file line number Diff line number Diff line change @@ -42,6 +42,16 @@ def test_simple(og_meta_tags):
42
42
)
43
43
44
44
45
+ @pytest .mark .sphinx ('epub' , testroot = 'simple' )
46
+ def test_epub (content : Sphinx ):
47
+ """Ogp tags are disabled for ePub build"""
48
+ meta_tags = conftest ._meta_tags (content , target = 'index.xhtml' )
49
+ og_meta_tags = [
50
+ tag for tag in meta_tags if tag .get ('property' , '' ).startswith ('og:' )
51
+ ]
52
+ assert len (og_meta_tags ) == 0
53
+
54
+
45
55
@pytest .mark .sphinx ('html' , testroot = 'meta-name-description' )
46
56
def test_meta_name_description (meta_tags ):
47
57
og_description = get_tag_content (meta_tags , 'description' )
You can’t perform that action at this time.
0 commit comments