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):
3232 return app
3333
3434
35- def _meta_tags (content , subdir = None ):
35+ def _meta_tags (content , subdir = None , target = 'index.html' ):
3636 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' )
3838 else :
39- c = (content .outdir / subdir / 'index.html' ).read_text (encoding = 'utf-8' )
39+ c = (content .outdir / subdir / target ).read_text (encoding = 'utf-8' )
4040 return BeautifulSoup (c , 'html.parser' ).find_all ('meta' )
4141
4242
@@ -53,9 +53,7 @@ def meta_tags(content):
5353
5454@pytest .fixture
5555def 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 )
5957
6058
6159@pytest .fixture
Original file line number Diff line number Diff line change 88html_theme = 'basic'
99
1010ogp_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):
4242 )
4343
4444
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+
4555@pytest .mark .sphinx ('html' , testroot = 'meta-name-description' )
4656def test_meta_name_description (meta_tags ):
4757 og_description = get_tag_content (meta_tags , 'description' )
You can’t perform that action at this time.
0 commit comments