mirror of
https://github.com/Threnklyn/dungeon-sheets.git
synced 2026-05-19 04:33:26 +02:00
Bug fixes and EPUB CSS improvements.
This commit is contained in:
@@ -329,6 +329,8 @@ class Druid(CharClass):
|
||||
valid_swim = max_swim is None or shape.swim_speed <= max_swim
|
||||
valid_fly = max_fly is None or shape.fly_speed <= max_fly
|
||||
can_assume = shape.is_beast and valid_cr and valid_swim and valid_fly
|
||||
if shape.name == "Spider":
|
||||
assert can_assume
|
||||
return can_assume
|
||||
|
||||
@property
|
||||
|
||||
+11
-8
@@ -36,9 +36,9 @@ def create_epub(
|
||||
book.set_language("en")
|
||||
# Add the css files
|
||||
css_template = jinja_env.get_template("dungeonsheets_epub.css")
|
||||
dl_widths = { # Width for dl lists, in 'em' units
|
||||
dl_widths = { # Width for dl lists, in 'em' units
|
||||
"character-details": 11,
|
||||
"combat-stats": 18,
|
||||
"combat-stats": 15,
|
||||
"proficiencies": 8.5,
|
||||
"faction": 6,
|
||||
"spellcasting": 12.5,
|
||||
@@ -118,13 +118,17 @@ class HeadingParser(HTMLParser):
|
||||
|
||||
def handle_endtag(self, tag):
|
||||
this_level = self.heading_level(tag)
|
||||
if this_level is not None and this_level == self._curr_level:
|
||||
if this_level is not None and this_level == self._curr_level and self._curr_id is not None:
|
||||
heading = {
|
||||
"level": this_level,
|
||||
"id": self._curr_id,
|
||||
"title": self._curr_title,
|
||||
}
|
||||
self.headings.append(heading)
|
||||
# Reset the current values
|
||||
self._curr_level = None
|
||||
self._curr_id = None
|
||||
self._curr_title = None
|
||||
|
||||
def handle_data(self, data):
|
||||
# Save the title
|
||||
@@ -151,10 +155,6 @@ def toc_from_headings(
|
||||
A sequence of table-of-contents links.
|
||||
|
||||
"""
|
||||
# [(<ebooklib.epub.Section at 0x7fdf903595d0>,
|
||||
# [(<ebooklib.epub.Section at 0x7fdf90359310>,
|
||||
# [<ebooklib.epub.Link at 0x7fdf90359bd0>,
|
||||
# <ebooklib.epub.Link at 0x7fdf90359c50>])])]
|
||||
# Parse the HTML
|
||||
parser = HeadingParser()
|
||||
parser.feed(html)
|
||||
@@ -278,7 +278,10 @@ def rst_to_html(rst, top_heading_level=0):
|
||||
|
||||
def to_heading_id(inpt: str) -> str:
|
||||
"""Take a string and make it suitable for use as an HTML header id."""
|
||||
return inpt.replace(" ", "-").replace("'", "")
|
||||
bad_characters = ["'", "(", ")", "&", "/", "+", ",", "=", ]
|
||||
for c in bad_characters:
|
||||
inpt = inpt.replace(c, "")
|
||||
return inpt.replace(" ", "-")
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -33,9 +33,9 @@
|
||||
<dd>[[ character.hair ]] </dd>
|
||||
</dl>
|
||||
|
||||
<h2 id="combat-stats details">Combat Statistics</h2>
|
||||
<h2 id="combat-stats">Combat Statistics</h2>
|
||||
|
||||
<dl class="combat-stats">
|
||||
<dl class="combat-stats details">
|
||||
<dt>Armor Class</dt>
|
||||
<dd>[[ character.armor_class ]]</dd>
|
||||
<dt>Initiative</dt>
|
||||
@@ -138,33 +138,33 @@
|
||||
|
||||
<h3 id="treasure">Additional Treasure</h3>
|
||||
|
||||
<block>
|
||||
<div>
|
||||
[[ character.treasure ]]
|
||||
</block>
|
||||
</div>
|
||||
|
||||
<h2 id="personaility-traits">Personality Traits</h2>
|
||||
|
||||
<block>
|
||||
<div>
|
||||
[[ character.personality_traits ]]
|
||||
</block>
|
||||
</div>
|
||||
|
||||
<h2 id="ideals">Ideals</h2>
|
||||
|
||||
<block>
|
||||
<div>
|
||||
[[ character.ideals ]]
|
||||
</block>
|
||||
</div>
|
||||
|
||||
<h2 id="bonds">Bonds</h2>
|
||||
|
||||
<block>
|
||||
<div>
|
||||
[[ character.bonds ]]
|
||||
</block>
|
||||
</div>
|
||||
|
||||
<h2 id="flaws">Flaws</h2>
|
||||
|
||||
<block>
|
||||
<div>
|
||||
[[ character.flaws ]]
|
||||
</block>
|
||||
</div>
|
||||
|
||||
<h2 id="appearance">Appearance</h2>
|
||||
|
||||
@@ -175,18 +175,18 @@
|
||||
<dd>[[ character.faction_name ]] </dd>
|
||||
</dl>
|
||||
|
||||
<block>
|
||||
<div>
|
||||
[[ character.allies ]]
|
||||
</block>
|
||||
</div>
|
||||
|
||||
<h2 id="other-traits">Additional Features & Traits</h2>
|
||||
|
||||
<block>
|
||||
<div>
|
||||
[[ character.other_feats_traits ]]
|
||||
</block>
|
||||
</div>
|
||||
|
||||
<h2 id="backstory">Backstory</h2>
|
||||
|
||||
<block>
|
||||
<div>
|
||||
[[ character.backstory ]]
|
||||
</block>
|
||||
</div>
|
||||
|
||||
@@ -2,11 +2,9 @@
|
||||
|
||||
[% for shape in character.all_wild_shapes|sort(attribute='challenge_rating') %]
|
||||
|
||||
|
||||
<block class="[% if not character.can_assume_shape(shape) %]known-beast-disabled[% endif %]">
|
||||
<div class="[% if not character.can_assume_shape(shape) %]known-beast-disabled[% endif %]">
|
||||
|
||||
<h2 id="known-beasts-[[ shape.name | to_heading_id ]]">[[ shape.name ]]</h2>
|
||||
|
||||
[% if shape.description %]
|
||||
<p>[[ shape.description ]]</p>
|
||||
[% endif %]
|
||||
@@ -45,10 +43,10 @@
|
||||
<dt>Immunities</dt><dd>[[ shape.condition_immunities ]] </dd>
|
||||
</dl>
|
||||
|
||||
<block>
|
||||
<div>
|
||||
[[ shape.__doc__ | rst_to_html(top_heading_level=2) ]]
|
||||
</block>
|
||||
</div>
|
||||
|
||||
[% endfor %]
|
||||
</div>
|
||||
|
||||
</block>
|
||||
[% endfor %]
|
||||
|
||||
@@ -1,7 +1,32 @@
|
||||
[% if use_dnd_decorations %]
|
||||
/* With fancy decorations */
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
color: #58180d;
|
||||
color: #58180d;
|
||||
font-family: sans-serif;
|
||||
}
|
||||
body {
|
||||
background: #ECDDB4;
|
||||
}
|
||||
table {
|
||||
background: #ECEEE3;
|
||||
}
|
||||
tr:nth-child(even) {
|
||||
background: #CDD290;
|
||||
}
|
||||
th {
|
||||
font-family: sans-serif
|
||||
}
|
||||
|
||||
|
||||
[% else %]
|
||||
/* Without Fancy decorations */
|
||||
|
||||
th {
|
||||
border-style: solid;
|
||||
border-width: 0px;
|
||||
border-bottom-width: 1px;
|
||||
}
|
||||
[% endif %]
|
||||
/* End fancy decorations */
|
||||
|
||||
/* Spell lists */
|
||||
@@ -63,7 +88,7 @@ dl.[[ class ]] dd {
|
||||
|
||||
/* For showing beasts */
|
||||
.known-beast-disabled {
|
||||
color: lightgrey;
|
||||
opacity: 0.33;
|
||||
}
|
||||
|
||||
/* Errors in rst conversion or missing content */
|
||||
@@ -85,10 +110,11 @@ table {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
table p {
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
th {
|
||||
border-style: solid;
|
||||
border-width: 0px;
|
||||
border-bottom-width: 1px;
|
||||
padding-left: 5px;
|
||||
padding-right: 5px;
|
||||
text-align: center;
|
||||
|
||||
@@ -9,7 +9,7 @@ import re
|
||||
from pathlib import Path
|
||||
from multiprocessing import Pool, cpu_count
|
||||
from itertools import product
|
||||
from typing import Union, Sequence, Optional, Literal, List
|
||||
from typing import Union, Sequence, Optional, List
|
||||
|
||||
from dungeonsheets import (
|
||||
character as _char,
|
||||
@@ -210,6 +210,7 @@ def make_gm_sheet(
|
||||
char_file = gm_file.parent / char_file
|
||||
char_file = char_file.resolve()
|
||||
# Load the character file
|
||||
log.debug(f"Loading party member: {char_file}")
|
||||
character_props = readers.read_sheet_file(char_file)
|
||||
member = _char.Character.load(character_props)
|
||||
party.append(member)
|
||||
@@ -304,7 +305,7 @@ def make_gm_sheet(
|
||||
|
||||
def make_character_content(
|
||||
character: Character,
|
||||
content_format: Literal["tex", "html"],
|
||||
content_format: str,
|
||||
fancy_decorations: bool = False,) -> List[str]:
|
||||
"""Prepare the inner content for a character sheet.
|
||||
|
||||
@@ -323,7 +324,7 @@ def make_character_content(
|
||||
character
|
||||
The character to render content for.
|
||||
content_format
|
||||
Which markup syntax to use.
|
||||
Which markup syntax to use, "tex" or "html".
|
||||
fancy_decorations
|
||||
Use fancy page layout and decorations for extra sheets, namely
|
||||
the dnd style file for *tex*, or extended CSS for *html*.
|
||||
@@ -436,7 +437,7 @@ def make_character_sheet(
|
||||
character=character, basename=char_base, flatten=flatten
|
||||
)
|
||||
pages.append(char_pdf)
|
||||
Person_pdf = create_personality_pdf_template(
|
||||
person_pdf = create_personality_pdf_template(
|
||||
character=character, basename=person_base, flatten=flatten
|
||||
)
|
||||
pages.append(person_pdf)
|
||||
|
||||
@@ -74,6 +74,7 @@ class BaseCharacterReader:
|
||||
The path to the file that will be imported.
|
||||
|
||||
"""
|
||||
print(filename)
|
||||
self.filename = filename
|
||||
|
||||
def __call__(self, filename):
|
||||
|
||||
Reference in New Issue
Block a user