Skip to content

Commit 2fb785c

Browse files
authored
Support xinclude pub files (#1158)
* add project with xinclude pub file and (broken) test * formating * another formatting fix * xinclude publication file * use href, not src * fix files * formatting, linting * correct path
1 parent cdbe916 commit 2fb785c

12 files changed

Lines changed: 107 additions & 1 deletion

File tree

pretext/project/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,9 @@ def generated_cache_abspath(self) -> Path:
472472
return self._project.generated_cache_abspath()
473473

474474
def _read_publication_file_subset(self) -> PublicationSubset:
475-
p_bytes = self.publication_abspath().read_bytes()
475+
p_et = ET.parse(self.publication_abspath())
476+
p_et.xinclude()
477+
p_bytes = ET.tostring(p_et)
476478
return PublicationSubset.from_xml(p_bytes)
477479

478480
def external_dir(self) -> Path:
35 Bytes
Loading
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<project ptx-version="2">
3+
<targets>
4+
<target name="web" format="html" />
5+
<target name="print" format="pdf" />
6+
</targets>
7+
</project>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<html>
3+
<baseurl href="https://pretextbook.org" />
4+
</html>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<publication xmlns:xi="http://www.w3.org/2001/XInclude">
3+
<xi:include href="./source.ptx"/>
4+
<xi:include href="./html.ptx"/>
5+
</publication>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<source>
3+
<directories external="../assets" generated="../generated-assets"/>
4+
</source>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<frontmatter>
3+
<bibinfo>
4+
<author>
5+
<personname>Author X. Lastname</personname>
6+
</author>
7+
</bibinfo>
8+
9+
<abstract>
10+
<p>
11+
This is the abstract.
12+
</p>
13+
</abstract>
14+
</frontmatter>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<introduction xml:id="intro" xmlns:xi="http://www.w3.org/2001/XInclude">
3+
<p>Some words before the first section of the paper</p>
4+
<p>Some more words.</p>
5+
</introduction>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version='1.0' encoding='utf-8'?>
2+
<pretext xml:lang="en-US" xmlns:xi="http://www.w3.org/2001/XInclude">
3+
4+
<docinfo>
5+
6+
<document-id>authorslastnamelowercase-ShortTitleCamelCase</document-id>
7+
8+
<macros>\newcommand{\foo}{b^{ar}}</macros>
9+
<latex-image-preamble>\usepackage{tikz}</latex-image-preamble>
10+
</docinfo>
11+
12+
<article xml:id="shorttitlelowercase">
13+
<title>The title of my groundbreaking paper</title>
14+
15+
<xi:include href="./frontmatter.ptx" />
16+
17+
<xi:include href="./introduction.ptx" />
18+
<xi:include href="./section-1.ptx" />
19+
<xi:include href="./section-2.ptx" />
20+
</article>
21+
22+
</pretext>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<section xml:id="section-1" xmlns:xi="http://www.w3.org/2001/XInclude">
3+
<title>My First Section</title>
4+
<introduction>
5+
<p>Some words</p>
6+
</introduction>
7+
<subsection xml:id="subsection-1">
8+
<title>My First Subsection</title>
9+
<p>Some more words</p>
10+
<p>foo</p>
11+
<figure>
12+
<caption>A frog</caption>
13+
<image source="frog.jpg" width="50%">
14+
<description>A nice-looking frog with a longish description.</description>
15+
</image>
16+
</figure>
17+
<p>Bar: <m>\foo</m></p>
18+
</subsection>
19+
</section>

0 commit comments

Comments
 (0)