Skip to content

Commit

Permalink
Add dl2/dl3 to ignored classes for c-008, add a test for it
Browse files Browse the repository at this point in the history
  • Loading branch information
vr8hub committed Mar 22, 2024
1 parent f792a46 commit 218f34c
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 1 deletion.
2 changes: 1 addition & 1 deletion se/se_epub_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
SE_SEMANTIC_VOCABULARY = ["collection", "compass", "compound", "diary", "diary.dateline", "era", "image", "image.color-depth", "image.color-depth.black-on-transparent", "image.style.realistic", "image.color-depth.default-on-transparent", "letter", "letter.dateline", "long-description", "name", "name.person", "name.person.full-name", "name.person.pen-name", "name.vehicle", "name.vehicle.airplane", "name.vehicle.auto", "name.vehicle.train", "name.vessel", "name.vessel.boat", "name.vessel.ship", "name.publication", "name.publication.book", "name.publication.essay", "name.publication.journal", "name.publication.newspaper", "name.publication.magazine", "name.publication.pamphlet", "name.publication.paper", "name.publication.play", "name.publication.poem", "name.publication.short-story", "name.music", "name.music.opera", "name.music.song", "name.visual-art", "name.visual-art.engraving", "name.visual-art.film", "name.visual-art.illustration", "name.visual-art.painting", "name.visual-art.photograph", "name.visual-art.sculpture", "name.visual-art.typeface", "name.broadcast", "name.broadcast.television-show", "name.legal-case", "novel", "novella", "publication-notes", "reading-ease", "reading-ease.flesch", "short-story", "sic", "temperature", "transform", "url", "url.authority", "url.authority.nacoaf", "url.homepage", "url.encyclopedia", "url.encyclopedia.wikipedia", "url.vcs", "url.vcs.github", "word-count"]

SE_GENRES = ["Adventure", "Autobiography", "Biography", "Children’s", "Comedy", "Drama", "Fantasy", "Fiction", "Horror", "Memoir", "Mystery", "Nonfiction", "Philosophy", "Poetry", "Satire", "Science Fiction", "Shorts", "Spirituality", "Tragedy", "Travel"]
IGNORED_CLASSES = ["elision", "eoc", "full-page", "continued", "together"]
IGNORED_CLASSES = ["continued", "dl2", "dl3", "elision", "eoc", "full-page", "together"]
BINARY_EXTENSIONS = [".jpg", ".jpeg", ".tif", ".tiff", ".bmp", ".png", ".epub", ".xcf", ".otf", ".jp2"]
IGNORED_FILENAMES = ["colophon.xhtml", "titlepage.xhtml", "imprint.xhtml", "uncopyright.xhtml", "toc.xhtml", "loi.xhtml"]
SPECIAL_FILES = ["colophon", "endnotes", "imprint", "loi"]
Expand Down
4 changes: 4 additions & 0 deletions tests/lint/css/c-008/golden/c-008-out.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
c-008 [Manual Review] local.css CSS class only used once. Can a clever selector
be crafted instead of a single-use class? When possible classes should not be
single-use style hooks.
onetimeclass
15 changes: 15 additions & 0 deletions tests/lint/css/c-008/in/src/epub/css/local.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@charset "utf-8";
@namespace epub "http://www.idpf.org/2007/ops";

/* custom */
.dl2,
.dl3,
.elision,
.full-page,
.together,
.samefile,
.difffile,
.onetimeclass{
font-style: normal;
}
/* end of custom */
34 changes: 34 additions & 0 deletions tests/lint/css/c-008/in/src/epub/text/chapter-1.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" epub:prefix="z3998: http://www.daisy.org/z3998/2012/vocab/structure/, se: https://standardebooks.org/vocab/1.0" xml:lang="en-GB">
<head>
<title>I</title>
<link href="../css/core.css" rel="stylesheet" type="text/css"/>
<link href="../css/local.css" rel="stylesheet" type="text/css"/>
</head>
<body epub:type="bodymatter z3998:fiction">
<section id="chapter-1" epub:type="chapter">
<h2 epub:type="ordinal z3998:roman">I</h2>
<!-- EXCLUSION 1, continued -->
<p class="continued">An askant tenor is a mitten of the mind. The fireman of a bread becomes a foppish freon. A ghost is a swamp from the right perspective. Some assert that one cannot separate databases from buckram roses.</p>
<!-- EXCLUSION 2, dl2 -->
<p class="dl2">This normally goes on a "dropped line" in poetry, but lint doesn’t know where the class is used, only that it is.</p>
<!-- EXCLUSION 3, dl3 -->
<p class="dl3">This also normally goes on a dropped line in poetry.</p>
<!-- EXCLUSION 4, elision -->
<p class="elision">This is normally used for elided lines in poetry.</p>
<!-- EXCLUSION 5, eoc -->
<p>The sparser jail reveals itself as a jiggish collar to those who look. A distal mice's care comes with it the thought that the shaping doll is a pickle, <abbr class="eoc">etc.</abbr> In ancient times a sausage of the cactus is assumed to be a crumby century.</p>
<!-- EXCLUSION 6, full-page -->
<p class="full-page">This normally goes on a figure that should take up the entire page.</p>
<!-- EXCLUSION 7, together -->
<p class="together">This normally goes in a drama table.</p>
<!-- EXCLUSION 8, class used more than once, same file -->
<p class="samefile">Authors often misinterpret the tenor as a tingly shark, when in actuality it feels more like a here diamond. What we don't know for sure is whether or not a laborer is a pyramid's noise. Some assert that the wettish euphonium reveals itself as a bodied stock to those who look. One cannot separate russians from scirrhoid sleeps. A scraper of the timer is assumed to be a bovid turret.</p>
<p class="samefile">Though we assume the latter, a queen of the vest is assumed to be a mono destruction. The bloodstained board reveals itself as a dragging examination to those who look. Before slaves, authorizations were only witnesses.</p>
<!-- EXCLUSION 9, class used more than once, different files -->
<p class="difffile">Thursdaies are hither nights. In recent years, the trouble is a duckling. What we don't know for sure is whether or not a bladder is the abyssinian of a pail. Some assert that before farms, milliseconds were only threads.</p>
<!-- FAIL 1, class used only once -->
<p class="onetimeclass">As far as we can estimate, some posit the stellar nigeria to be less than fleeceless. The zeitgeist contends that a population sees a close as a duskish feedback. A steric fine is a bank of the mind. A ramose burglar's interest comes with it the thought that the bragging carrot is a taxicab.</p>
</section>
</body>
</html>
15 changes: 15 additions & 0 deletions tests/lint/css/c-008/in/src/epub/text/chapter-2.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" epub:prefix="z3998: http://www.daisy.org/z3998/2012/vocab/structure/, se: https://standardebooks.org/vocab/1.0" xml:lang="en-GB">
<head>
<title>II</title>
<link href="../css/core.css" rel="stylesheet" type="text/css"/>
<link href="../css/local.css" rel="stylesheet" type="text/css"/>
</head>
<body epub:type="bodymatter z3998:fiction">
<section id="chapter-2" epub:type="chapter">
<h2 epub:type="ordinal z3998:roman">II</h2>
<!-- EXCLUSION 9, class used more than once, different files -->
<p class="difffile">A nightly plaster is a talk of the mind. A meal is an element from the right perspective. The zeitgeist contends that a stitch is an insect from the right perspective. Inspired healths show us how nephews can be eights.</p>
</section>
</body>
</html>

0 comments on commit 218f34c

Please sign in to comment.