Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 29 additions & 4 deletions examples/sample-article/sample-article.xml
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
<case direction="cycle">
<p>Does the first statement imply the second?</p>
</case>

<case direction="cycle">
<title>The <q>middle</q> case</title>
<p>Does the second statement imply the third?</p>
Expand Down Expand Up @@ -12924,6 +12924,28 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.

</section>

<section xml:id="literate-programming" label="literate-programming">
<title>Literate Programming</title>
<p>There is support for literate programming using the <tag>fragment</tag> tag. It should always contain an <attr>@xml:id</attr> or a <attr>@filename</attr> attribute, and may contain <tag>code</tag> segments as well as <tag>fragref</tag> segments referencing other fragments. The final code is to be assembled starting from a fragment with a filename attribute and traversing the tree of fragment references.</p>
<p>For example here is the gcd algorithm in Python. Note that indentation is hard to get right at the moment.</p>
<fragment filename="gcd.py">
<title>The GCD algorithm</title>
<code>
def gcd(a, b):
while(b):
</code>
<fragref ref="gcd-loop" />
<code> return a</code>
</fragment>
<p>The key part is the inner part of the loop</p>:
<fragment xml:id="gcd-loop">
<title>The key loop part</title>
<code>
a, b = b, a % b
</code>
</fragment>
<p>This double assignment changes both a and b.</p>
</section>
<section xml:id="atomic-items" label="section-atomic-items">
<title>Atomic Objects</title>

Expand Down Expand Up @@ -15563,9 +15585,12 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.

<exercisegroup workspace="0.25in">
<introduction>
<p>
Now with one column, do things to the following.
</p>
<title>Title of introduction of an exercise group</title>
<statement>
<p>
Now with one column, do things to the following.
</p>
</statement>
</introduction>
<exercise>
<statement>
Expand Down
Loading