Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

creating valid epub structure #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ebook
3 changes: 1 addition & 2 deletions prolog/attributedvariables.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<head>
<title>Attributed Variables in Prolog</title>
Expand Down Expand Up @@ -1400,7 +1400,6 @@

and hence <i>fail</i>.

</pre>
<center><h2>Further reading and future work</h2></center>

Attributed variables are typically used to implement constraint
Expand Down
62 changes: 62 additions & 0 deletions prolog/ebook.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash

ebook_dir="./ebook"
content="$ebook_dir/content.opf"
manifest="$ebook_dir/manifest"
spine="$ebook_dir/spine"
toc="$ebook_dir/toc.ncx"

echo "dir: $ebook_dir"

if [ -d "$ebook_dir" ]; then
rm -rf "$ebook_dir"
fi
mkdir "$ebook_dir"

cp "kindle.css" "$ebook_dir/kindle.css"

for chapter in *.html; do
echo "chapter: $chapter"
chapter_file="$ebook_dir/$chapter"
echo " <item id=\"$chapter\" href=\"$chapter\" media-type=\"application/html\"/>" >> "$manifest"
echo " <itemref idref=\"$chapter\"/>" >> "$spine"
awk '{\
gsub(" style=\"[^\"]+?\"","");\
gsub("<script src=\".+\"></script>","");\
sub("<link rel=\"stylesheet\" type=\"text/css\" href=\".*toc.css\">","");\
sub("<link rel=\"stylesheet\" type=\"text/css\" href=\".*prolog.css\">","<link rel=\"stylesheet\" type=\"text/css\" href=\"kindle.css\">");\
print\
}' "$chapter" > "$chapter_file"
done

echo '<?xml version="1.0" encoding="utf-8"?>
<package version="2.0" unique-identifier="BookId" xmlns="http://www.idpf.org/2007/opf">
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
<dc:identifier opf:scheme="UUID" id="BookId">urn:uuid:ca006611-474d-43a3-9a76-c06b86ac020b</dc:identifier>
<dc:creator opf:role="aut">Markus Triska</dc:creator>
<dc:title>The Power of Prolog</dc:title>
<dc:language>en</dc:language>
<dc:date opf:event="modification" xmlns:opf="http://www.idpf.org/2007/opf">2018-05-28</dc:date>
</metadata>
<manifest>' >> "$content"
echo '<item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml"/>' >> "$content"
cat "$manifest" >> "$content"
echo ' </manifest>
<spine toc="ncx">' >> "$content"
cat "$spine" >> "$content"
echo ' </spine>
<guide>
</guide>
</package>' >> "$content"

rm "$manifest" "$spine"

echo '<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<!DOCTYPE ncx PUBLIC "-//NISO//DTD ncx 2005-1//EN" "http://www.daisy.org/z3986/2005/ncx-2005-1.dtd">
<ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1" xml:lang="en">
<!-- Metadata Section -->
<!-- Title and Author Section -->
<!-- Navigation Map Section -->
</ncx>' >> "$toc"

echo "prepared ebook data, zip files in ebook directory and rename file to .epub"
34 changes: 34 additions & 0 deletions prolog/kindle.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
h1 {
font-size: 3em;
page-break-before: always;
}

a {
color: black !important;
text-decoration: underline !important;
}

.box {
background: lightgray;
padding: 1em;
margin-left: 3em;
}

.example {
border: 1px solid gray;
padding: 1em;
}

.query {
background: lightgray;
}

.secret {
background: gray;
color: white;
padding: 0.2em;
}

b>tt, pre {
margin-left: 1em;
}
4 changes: 2 additions & 2 deletions prolog/puzzles.html
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,8 @@
implication_chain([], Prev) --&gt; [Prev].
implication_chain(Vs0, Prev) --&gt; [Prev],
{ select(V, Vs0, Vs) },
( { taut(Prev =< V, 1) } -&gt; implication_chain(Vs, V)
; { taut(Prev =< ~V, 1) } -&gt; implication_chain(Vs, ~V)
( { taut(Prev =&gt; V, 1) } -&gt; implication_chain(Vs, V)
; { taut(Prev =&gt; ~V, 1) } -&gt; implication_chain(Vs, ~V)
).
</pre>

Expand Down