else:
return TextPlus(text.decode('utf-8'))
+def as_bool(text):
+ return text == 'true'
+as_bool.no_lang = True
def as_wluri_strict(text):
return WLURI.strict(text)
if validator is None or val[0] is None:
return val[0]
nv = validator(val[0])
- if hasattr(val[0], 'lang'):
+ if hasattr(val[0], 'lang') and not hasattr(validator, 'no_lang'):
setattr(nv, 'lang', val[0].lang)
return nv
except ValueError as e:
Field(WLNS('coverClass'), 'cover_class', default=['default']),
Field(WLNS('coverLogoUrl'), 'cover_logo_urls', multiple=True,
required=False),
+ Field(WLNS('endnotes'), 'endnotes', as_bool,
+ required=False),
Field('pdf-id', 'isbn_pdf', required=False),
Field('epub-id', 'isbn_epub', required=False),
"coverBoxPosition": etree.ElementBase,
"coverLogoUrl": etree.ElementBase,
"contentWarning": etree.ElementBase,
+ "endnotes": etree.ElementBase,
"utwor": root.Utwor,
"dramat_wierszowany_l": masters.Master,
def gettext(self):
return get_translation(self.meta.language).gettext
+ def in_context_of(self, setting):
+ parent = self.getparent()
+ if parent is None:
+ return False
+ try:
+ return getattr(parent, setting)
+ except AttributeError:
+ return parent.in_context_of(setting)
+
+ def signal(self, signal):
+ parent = self.getparent()
+ if parent is not None:
+ parent.signal(signal)
+
def raw_printable_text(self):
# TODO: podtagi, wyroznienia, etc
t = ''
builder.start_chunk()
fragment = None
- if self.SECTION_PRECEDENCE:
+ if self.SECTION_PRECEDENCE and not self.in_context_of('NO_TOC'):
if not start_chunk:
fragment = 'sub%d' % builder.assign_section_number()
self.attrib['id'] = fragment
def validate(self):
from librarian.elements.masters import Master
from librarian.elements.blocks import DlugiCytat, PoezjaCyt
+ from librarian.elements.footnotes import Footnote
if self.SECTION_PRECEDENCE:
- assert isinstance(self.getparent(), (Master, DlugiCytat, PoezjaCyt)), \
+ assert isinstance(self.getparent(), (Master, DlugiCytat, PoezjaCyt, Footnote)), \
'Header {} inside a <{}> instead of a master.'.format(
etree.tostring(self), self.getparent().tag)
class Footnote(WLElement):
+ NO_TOC = True
+ START_INLINE = True
+
+ def signal(self, signal):
+ if signal == 'INLINE':
+ self.START_INLINE = False
+ else:
+ super().signal(signal)
+
def txt_build(self, builder):
pass
builder.enter_fragment('footnotes')
- builder.start_element('p', {
+ builder.start_element('div', {
'id': f'annotation-{fn_no}',
'class': "annotation"
})
TXT_LEGACY_TOP_MARGIN = 2
TXT_LEGACY_BOTTOM_MARGIN = 0
- EPUB_TAG = HTML_TAG = 'p'
+ HTML_TAG = 'p'
EPUB_CLASS = HTML_CLASS = 'paragraph'
+
+ @property
+ def EPUB_TAG(self):
+ try:
+ return self._set_EPUB_TAG
+ except AttributeError:
+ if self.in_context_of('START_INLINE'):
+ self.signal('INLINE')
+ self._set_EPUB_TAG = None
+ else:
+ self._set_EPUB_TAG = 'p'
+ return self._set_EPUB_TAG
+
document.clean_ed_note()
document.clean_ed_note('abstrakt')
-
+ document.fix_pa_akap()
+
if not options:
options = {}
)
or e.get('id') == 'nota_red'
or e.tag == 'blockquote'
+ or e.get('id') == 'footnotes'
)
if any_ancestor(element, f):
continue
node.tag = 'span'
node.tail = tail
+ def fix_pa_akap(self):
+ for pa in ('pa','pe','pr','pt'):
+ for akap in self.edoc.findall(f'//{pa}/akap'):
+ akap.getparent().set('blocks', 'true')
+ if not akap.getparent().index(akap):
+ akap.set('inline', 'true')
+
def editors(self):
"""Returns a set of all editors for book and its children.
elif package_available('morefloats', 'maxfloats=19'):
root.set('morefloats', 'new')
+ if customizations is None:
+ customizations = []
+ else:
+ customizations = list(customizations)
+
+ if book_info.endnotes:
+ customizations.append('endnotes')
+
# add customizations
if customizations is not None:
root.set('customizations', u','.join(customizations))
fix_hanging(document.edoc)
fix_tables(document.edoc)
mark_subauthors(document.edoc)
+ document.fix_pa_akap()
# wl -> TeXML
style_filename = get_stylesheet("wl2tex")
\newif\ifshowfootnotes \showfootnotestrue
\DeclareOption{nofootnotes}{\showfootnotesfalse}
+\newif\ifendnotes \endnotesfalse
+\DeclareOption{endnotes}{\endnotestrue}
+
\newif\ifshowthemes \showthemestrue
\DeclareOption{nothemes}{\showthemesfalse}
\usepackage{wrapfig}
+
+\ifendnotes
+ \usepackage{enotez}
+ \setenotez{list-name=Przypisy}
+ \setenotez{backref=true}
+\fi
+
+
\usepackage[overload]{textcase}
\usepackage{scalefnt}
\usepackage[colorlinks=true,linkcolor=black,setpagesize=false,urlcolor=black,xetex]{hyperref}
}
\ifshowfootnotes
- \newcommand{\pa}[1]{\NoCaseChange{\footnote{#1 [przypis autorski]}}}
- \newcommand{\pe}[1]{\NoCaseChange{\footnote{#1 [przypis edytorski]}}}
- \newcommand{\pr}[1]{\NoCaseChange{\footnote{#1 [przypis redakcyjny]}}}
- \newcommand{\pt}[1]{\NoCaseChange{\footnote{#1 [przypis tłumacza]}}}
+ \ifendnotes
+ \newcommand{\pa}[1]{\NoCaseChange{\endnote{#1 [przypis autorski]}}}
+ \newcommand{\pe}[1]{\NoCaseChange{\endnote{#1 [przypis edytorski]}}}
+ \newcommand{\pr}[1]{\NoCaseChange{\endnote{#1 [przypis redakcyjny]}}}
+ \newcommand{\pt}[1]{\NoCaseChange{\endnote{#1 [przypis tłumacza]}}}
+ \else
+ \newcommand{\pa}[1]{\NoCaseChange{\footnote{#1 [przypis autorski]}}}
+ \newcommand{\pe}[1]{\NoCaseChange{\footnote{#1 [przypis edytorski]}}}
+ \newcommand{\pr}[1]{\NoCaseChange{\footnote{#1 [przypis redakcyjny]}}}
+ \newcommand{\pt}[1]{\NoCaseChange{\footnote{#1 [przypis tłumacza]}}}
+ \fi
\else
\newcommand{\pa}[1]{}
\newcommand{\pe}[1]{}
</xsl:if>
</TeXML>
+ <TeXML escape="0">
+ \ifendnotes
+\newpage
+\begingroup
+\parindent 0pt
+\parskip 2ex
+\def\enotesize{\normalsize}
+\printendnotes
+ \endgroup
+ \fi
+ </TeXML>
+
<cmd name="editorialsection" />
</env>
<xsl:template
- match="naglowek_osoba|naglowek_podrozdzial|podtytul_podrozdzial|miejsce_czas|didaskalia|lista_osoba|akap|akap_dialog|akap_cd|motto_podpis|naglowek_listy|srodtytul|podtytul_czesc|podtytul_rozdzial|podtytul_akt|podtytul_scena">
- <cmd>
+ match="naglowek_osoba|naglowek_podrozdzial|podtytul_podrozdzial|miejsce_czas|didaskalia|lista_osoba|akap|akap_dialog|akap_cd|motto_podpis|naglowek_listy|srodtytul|podtytul_czesc|podtytul_rozdzial|podtytul_akt|podtytul_scena">
+ <xsl:choose>
+ <xsl:when test="@inline">
+ <xsl:apply-templates mode="inline"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <cmd>
<xsl:attribute name="name">
<xsl:value-of select="wl:texcommand(name())" />
</xsl:attribute>
<parm><xsl:apply-templates mode="inline"/></parm>
- </cmd>
+ </cmd>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:template>
<xsl:template match="naglowek_czesc|naglowek_rozdzial|naglowek_akt|naglowek_scena">
<!-- = (contain other inline tags and special tags) = -->
<!-- ================================================ -->
+
<xsl:template mode="inline"
match="pa|pe|pr|pt|mat|didask_tekst|slowo_obce|wyroznienie|osoba|indeks_dolny|wieksze_odstepy">
<cmd>
<xsl:attribute name="name">
- <xsl:value-of select="wl:texcommand(name())" />
+ <xsl:value-of select="wl:texcommand(name())" />
</xsl:attribute>
- <parm><xsl:apply-templates mode="inline"/></parm>
+ <parm>
+ <xsl:choose>
+ <xsl:when test="@blocks">
+ <xsl:apply-templates/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates mode="inline"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </parm>
</cmd>
</xsl:template>
</p>
</xsl:when>
<xsl:otherwise>
- <xsl:apply-templates select="text()|*" mode="inline" />
+ <xsl:apply-templates />
+ <p>
+ <xsl:if test="name()='pa'"> [przypis autorski]</xsl:if>
+ <xsl:if test="name()='pt'"> [przypis tłumacza]</xsl:if>
+ <xsl:if test="name()='pr'"> [przypis redakcyjny]</xsl:if>
+ <xsl:if test="name()='pe'"> [przypis edytorski]</xsl:if>
+ </p>
</xsl:otherwise>
</xsl:choose>
</div>