Skip to content

Commit

Permalink
Use pandoc for PDF, EPUB, single HTML.
Browse files Browse the repository at this point in the history
  • Loading branch information
blynn committed Apr 10, 2018
1 parent f78421c commit 31deb51
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 71 deletions.
40 changes: 21 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SHELL := /bin/bash

all: $(LANGS)

$(LANGS): %: book-% book-%/default.css book-%.html book-%.pdf
$(LANGS): %: book-% book-%/default.css book-%.html book-%.pdf book-%.epub

# The book consists of these text files in the following order:

Expand Down Expand Up @@ -57,27 +57,29 @@ $(foreach l,$(LANGS),book-$(l)/default.css): book-%/default.css: book.css
rsync book.css book-$*/default.css

$(foreach l,$(LANGS),book-$(l).html): book-%.html: book-%.xml
xmlto -m custom-nochunks.xsl html-nochunks $^
-tidy -utf8 -imq $@
pandoc -s -f docbook -t html5 -o $@ $^

# Set SP_ENCODING to avoid "non SGML character" errors.
# Can also do SP_ENCODING="UTF-8".
$(foreach l,$(LANGS),book-$(l).pdf): book-%.pdf: book-%.xml
if [ $* = zh_cn -o $* = zh_tw ]; then \
if ! [ -f fop-$*.xsl ]; then wget -q http://bestrecords.net/fop/fop-$*.xsl; fi; \
if ! [ -f fop-$*.xconf ]; then wget -q http://bestrecords.net/fop/fop-$*.xconf; fi; \
xmlto -m fop-$*.xsl --with-fop -p "-c `pwd`/fop-$*.xconf" pdf book-$*.xml ;\
elif [ $* = vi ] ; then \
xsltproc --encoding utf-8 fop-vi.xsl book-$*.xml > book-$*.fo; \
fop -c fop-vi.xconf -fo book-$*.fo -pdf book-$*.pdf; \
else \
SP_ENCODING="XML" docbook2pdf book-$*.xml; \
fi
pandoc -s -f docbook -o $@ --latex-engine xelatex $^

book-ru.pdf: book-ru.xml
pandoc -s -f docbook -o $@ --latex-engine xelatex -V mainfont='DejaVuSansMono' $^

book-uk.pdf: book-uk.xml
pandoc -s -f docbook -o $@ --latex-engine xelatex -V mainfont='DejaVuSansMono' $^

book-ko.pdf: book-ko.xml
pandoc -s -f docbook -o $@ --latex-engine xelatex -V CJKmainfont='WenQuanYi Micro Hei Mono' $^

book-zh_cn.pdf: book-zh_cn.xml
pandoc -s -f docbook -o $@ --latex-engine xelatex -V CJKmainfont='WenQuanYi Micro Hei Mono' $^

book-zh_tw.pdf: book-zh_tw.xml
pandoc -s -f docbook -o $@ --latex-engine xelatex -V CJKmainfont='WenQuanYi Micro Hei Mono' $^

$(foreach l,$(LANGS),book-$(l).epub): book-%.epub: book-%.xml
pandoc -s -f docbook -o $@ $^

clean:
-rm -rf $(foreach l,$(LANGS),book-$(l).pdf book-$(l).xml book-$(l).html book-$(l)) \
*.fo *.log *.out *.aux conf

distclean: clean
-rm -rfv fop fop-zh*

18 changes: 9 additions & 9 deletions custom-html.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
<xsl:param name="html.stylesheet" select="'default.css'"/>

<xsl:template name="user.footer.navigation">
<script type="text/javascript" src="find_selflink.js"></script>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-1901330-2");
pageTracker._initData();
pageTracker._trackPageview();
<!-- Google Analytics -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-1901330-2', 'auto');
ga('send', 'pageview');
</script>
<!-- End Google Analytics -->
</xsl:template>

</xsl:stylesheet>
8 changes: 0 additions & 8 deletions custom-nochunks.xsl

This file was deleted.

3 changes: 1 addition & 2 deletions en/preface.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Rather than go into details, we provide rough instructions for particular effect

- link:book.html[Single webpage]: barebones HTML, with no CSS.
- link:book.pdf[PDF file]: printer-friendly.
- link:book.epub[EPUB file]: E-reader-friendly.
- http://packages.debian.org/gitmagic[Debian package], http://packages.ubuntu.com/gitmagic[Ubuntu package]: get a fast and local copy of this site. Handy http://csdcf.stanford.edu/status/[when this server is offline].
- http://www.amazon.com/Git-Magic-Ben-Lynn/dp/1451523343/[Physical book [Amazon.com]]: 64 pages, 15.24cm x 22.86cm, black and white. Handy when there is no electricity.

Expand Down Expand Up @@ -58,8 +59,6 @@ repository, and can be obtained by typing:
or from one of the mirrors:

$ git clone git://github.com/blynn/gitmagic.git
$ git clone git://gitorious.org/gitmagic/mainline.git
$ git clone https://code.google.com/p/gitmagic/
$ git clone git://git.assembla.com/gitmagic.git
$ git clone [email protected]:blynn/gitmagic.git

Expand Down
2 changes: 1 addition & 1 deletion es/preface.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ En lugar de ser detallados, proveemos instrucciones generales para efectos parti

.Otras ediciones

- http://docs.google.com/View?id=dfwthj68_675gz3bw8kj[Traducción al chino]: por JunJie, Meng y JiangWei.
- link:/~blynn/gitmagic/intl/zh_cn/[Traducción al chino]: por JunJie, Meng y JiangWei.
- link:book.html[Una única página]: HTML simple, sin CSS.
- link:book.pdf[Archivo PDF]: Listo para imprimir.
- http://packages.debian.org/search?searchon=names&keywords=gitmagic[Paquete gitmagic para Debian]: Consigue una copia rápida y local de este sitio. http://packages.ubuntu.com/jaunty/gitmagic[Paquete para Ubuntu (Jaunty Jackalope)] también disponible. Útil http://csdcf.stanford.edu/status/[cuando este servidor está offline para mantenimiento].
Expand Down
11 changes: 0 additions & 11 deletions fop-vi.xconf

This file was deleted.

17 changes: 0 additions & 17 deletions fop-vi.xsl

This file was deleted.

2 changes: 1 addition & 1 deletion fr/preface.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ recettes pour répondre à vos besoins.

.Traductions

- http://docs.google.com/View?id=dfwthj68_675gz3bw8kj[Chinois
- link:/~blynn/gitmagic/intl/zh_cn/[Chinois
(Simplifié)]&#160;: par JunJie, Meng et JiangWei.

- link:/~blynn/gitmagic/intl/fr/[Française]&#160;: par Alexandre Garel, Paul
Expand Down
2 changes: 1 addition & 1 deletion makeover
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ gawk '
# For every file except the index...
for FILE in $BOOKDIR/*.html
do
sed '/<title>/a <link href="http://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet" type="text/css">' -i $FILE
sed '/<title>/a <link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet" type="text/css">' -i $FILE
if [ $FILE != "$BOOKDIR/index.html" ]
then
# Prepend "Git Magic - " to titles of all pages.
Expand Down
2 changes: 1 addition & 1 deletion ru/preface.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ http://git.or.cz/[Git] это швейцарский нож управления

.Переводы

- http://docs.google.com/View?id=dfwthj68_675gz3bw8kj[ Китайский (упрощенный)]: JunJie, Meng и JiangWei.
- link:/~blynn/gitmagic/intl/zh_cn/[Китайский (упрощенный)]: JunJie, Meng и JiangWei.
- link:/~blynn/gitmagic/intl/es/[Испанский]: Rodrigo Toledo.
- link:/~blynn/gitmagic/intl/de/[Немецкий]: Benjamin Bellee и Armin Stebich. Armin также разместил http://gitmagic.lordofbikes.de/[немецкий перевод на его сайте].
- link:/~blynn/gitmagic/intl/ru/[Русский]: Тихон Тарнавский, Михаил Дымсков и другие.
Expand Down
2 changes: 1 addition & 1 deletion uk/preface.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ http://git.or.cz/[Git] — це швейцарський ніж керуванн

- link:/~blynn/gitmagic/intl/vi/[В'єтнамська]: Trần Ngọc Quân; також http://vnwildman.users.sourceforge.net/gitmagic/[розміщено на його вебсайті].
- link:/~blynn/gitmagic/intl/es/[Іспанська]: Rodrigo Toledo та Ariset Llerena Tapia.
- http://docs.google.com/View?id=dfwthj68_675gz3bw8kj[Китайська (спрощена)]: JunJie, Meng та JiangWei. Конвертовано у link:/~blynn/gitmagic/intl/zh_tw/[Традиційна китайська] via +cconv -f UTF8-CN -t UTF8-TW+.
- link:/\~blynn/gitmagic/intl/zh_cn/[Китайська (спрощена)]: JunJie, Meng та JiangWei. Конвертовано у link:/~blynn/gitmagic/intl/zh_tw/[Традиційна китайська] via +cconv -f UTF8-CN -t UTF8-TW+.

This comment has been minimized.

Copy link
@605885

605885 Mar 12, 2021

@

- link:/~blynn/gitmagic/intl/de/[Німецька]: Benjamin Bellee і Armin Stebich. Armin також розмістив http://gitmagic.lordofbikes.de/[німецький переклад на своєму сайті].
- http://www.slideshare.net/slide_user/magia-git[Португальська]: Leonardo Siqueira Rodrigues [http://www.slideshare.net/slide_user/magia-git-verso-odt[в форматі ODT]].
- link:/~blynn/gitmagic/intl/ru/[Російська]: Тихон Тарнавский, Михаил Дымсков і інші.
Expand Down

2 comments on commit 31deb51

@padnawadee
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@padnawadee
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dragging & dropping, selecting or pasting them

Please sign in to comment.