#!/usr/bin/php \documentclass[12pt]{book} \usepackage{geometry} % See geometry.pdf to learn the layout options. There are lots. \geometry{letterpaper} % ... or a4paper or a5paper or ... %\geometry{landscape} % Activate for for rotated page geometry \usepackage[parfill]{parskip} % Activate to begin paragraphs with an empty line rather than an indent \usepackage{graphicx} \usepackage{graphics} \usepackage{amssymb} \usepackage{czech} \usepackage{wrapfig} \usepackage{hyperref} \usepackage{fontspec,xltxtra,xunicode} \usepackage{lettrine} \usepackage{color} \hypersetup[unicode]{ pdftitle={Lawrence Lessig: Svobodná kultura}, pdfauthor={wiki.root.cz, Aleš Janda, XeLaTeX}, pdfsubject={Svobodná kultura}, pdfkeywords={Svobodná kultura,Free culture,copyright,autorský zákon}, pdfproducer={Aleš Janda, XeLaTeX}, bookmarks=true,colorlinks=true,breaklinks=true,urlcolor=black,citecolor=blue,linkcolor=black,unicode=true } \clubpenalty 5000 \widowpenalty 10000 \hyphenpenalty 1000 \tolerance 10000 \defaultfontfeatures{Mapping=tex-text} \setromanfont[Scale=1.25,Mapping=tex-text]{Georgia} \setsansfont[Scale=MatchLowercase,Mapping=tex-text]{DejaVuSans} % \setmonofont[Scale=MatchLowercase]{Kirsty} \newfontfamily{\UvodniNadpis}[Scale=2.52]{LMSans17} \begin{document} \vspace*{360pt} \definecolor{NadpisBarva}{rgb}{0.6,0,0.2} \thispagestyle{empty} {\par\def\baselinestretch{5}\textbf{\Large\color{NadpisBarva}\UvodniNadpis{\MakeUppercase{Svobodná kultura}}}} \vspace{15pt} {\par\def\baselinestretch{1}\small\UvodniNadpis{Lawrence Lessig}} \newpage \thispagestyle{empty} \def\baselinestretch{1.4}\small \hfuzz 20pt \vfuzz 20pt \tableofcontents % vytvoří obsah podle souboru priklad.toc \newpage % provede odstránkování \def\baselinestretch{1.4} \parindent=20pt 'chapter*', 2 => 'chapter*', 3 => 'part', 4 => 'chapter', 5 => 'chapter', 6 => 'chapter', 7 => 'chapter', 8 => 'chapter', 9 => 'part', 10 => 'chapter', 11 => 'chapter', 12 => 'chapter', 13 => 'chapter', 14 => 'chapter', 15 => 'part', 16 => 'chapter', 17 => 'chapter', 18 => 'part', 19 => 'chapter', 20 => 'chapter', 21 => 'chapter*', 22 => 'chapter*', 23 => 'section*', 24 => 'section*', 25 => null, 26 => 'chapter*', 28 => 'chapter*', ); define('FALESNY_PART',21); //ktera kapitole se ma dat do rejstriku jako part, ale do textu jako chapter @MkDir('img'); @MkDir('html'); $gradky = Array(); $gpoznamky = Array(); $gpoznamky['global'] = Array(); foreach ($GLOBALS['stranky'] as $cislo_stranky => $typ_stranky) { $radky = Array(); $poznamky = Array(); $typ = 'zacatek'; $pozice_globalnich_poznamek = 0; //pro kapitolu s poznámkami, při každém
([0-9]+). (.*)$/',$radek,$shody)) {
$gpoznamky['global'][$pozice_globalnich_poznamek][$shody[2]] = $shody[3];
$posledni_poznamka_odkaz = &$gpoznamky['global'][$pozice_globalnich_poznamek][$shody[2]];
}
else if ($posledni_poznamka_odkaz !== null) { //navazuje na predchozi radek
$posledni_poznamka_odkaz = RTrim($posledni_poznamka_odkaz.' '.$radek);
}
break;
case 'konec':
break;
}
}
$gradky[CisloNaNazev($cislo_stranky)] = $radky;
$gpoznamky[CisloNaNazev($cislo_stranky)] = $poznamky;
UnSet($posledni_poznamka_odkaz);
}
$pozice_globalnich_poznamek = 1;
foreach ($GLOBALS['stranky'] as $cislo_stranky => $typ_stranky) {
if ($typ_stranky === null) continue;
echo '% Stránka '.$cislo_stranky."\n";
$pouzita_alespon_jedna_globalni_poznamka = false;
$radky = $gradky[CisloNaNazev($cislo_stranky)];
foreach ($radky as $index_radku => $radek) {
for ($zmena = true; $zmena; ) { //bude se to cyklit tak dlouho, dokud se bude jeste neco menit (pro vychytani vsech vnorenych elementu)
$zmena = false;
//vyrobím poznámky do footnote
while (PReg_Match('/^(.*)([^<]*)<\/a>/',$radek,$shody)) {
$radek = $shody[1].$shody[3].'\footnote{'.$gpoznamky[CisloNaNazev($cislo_stranky)][$shody[2]].'}'.SubStr($radek,StrLen($shody[0]));
$zmena = true;
}
while (PReg_Match('/^(.*)([0-9]+)<\/a>/',$radek,$shody)) {
$radek = $shody[1].'\footnote{'.$gpoznamky['global'][$pozice_globalnich_poznamek][$shody[3]].'}'.SubStr($radek,StrLen($shody[0]));
$pouzita_alespon_jedna_globalni_poznamka = true;
$zmena = true;
}
while (PReg_Match('/^(.*)([^<]*)<\/a>/',$radek,$shody)) { //jinak prevedu odkaz
$radek = $shody[1].'\href{'.$shody[2].'}{\textsf{'.$shody[3].'}}'.SubStr($radek,StrLen($shody[0]));
$zmena = true;
}
while (PReg_Match('/^(.*)([0-9]+)<\/a>/',$radek,$shody)) {
$radek = $shody[1].'\footnote{'.$gpoznamky['global'][$pozice_globalnich_poznamek][$shody[3]].'}'.SubStr($radek,StrLen($shody[0]));
$pouzita_alespon_jedna_globalni_poznamka = true;
$zmena = true;
}
while (PReg_Match('/^(.*)([^<]*)<\/a>/',$radek,$shody)) { //jinak prevedu odkaz
$radek = $shody[1].'\href{'.$shody[2].'}{\textsf{'.$shody[3].'}}'.SubStr($radek,StrLen($shody[0]));
$zmena = true;
}
while (PReg_Match('/^(.*)([^<]*)<\/strong>/',$radek,$shody)) { //tucny text
$radek = $shody[1].'\textbf{'.$shody[2].'}'.SubStr($radek,StrLen($shody[0]));
$zmena = true;
}
while (PReg_Match('/^(.*)([^<]*)<\/em>/',$radek,$shody)) { //zvyrazneny text
$radek = $shody[1].'\textit{'.$shody[2].'}'.SubStr($radek,StrLen($shody[0]));
$zmena = true;
}
while (PReg_Match('/^(.*) ','',$radek);
$radek = Str_Replace(' ','',$radek);
$radek = Str_Replace(']*>
]*> ]*>([^<]*)<\/th> ]*>([^<]*)<\/th> ]*>([^<]*)<\/th><\/tr>/',$radek,$shody)) { //zacatek tabulky se tremi sloupci
$radek = $shody[1].'\begin{table}[ht]{\begin{center}\small\begin{tabular}{|c|c|c|}\hline'."\n".'\bfseries '.$shody[2].' & \bfseries '.$shody[3].' & \bfseries '.$shody[4].' \\\\ \hline'.SubStr($radek,StrLen($shody[0]));
$zmena = true;
}
while (PReg_Match('/^(.*) ]*> ]*>([^<]*)<\/td> ]*>([^<]*)<\/td> ]*>([^<]*)<\/td><\/tr>/',$radek,$shody)) { //telo tabulky se tremi sloupci
$radek = ''.$shody[1].$shody[2].' & '.$shody[3].' & '.$shody[4].' \\\\ \hline'.SubStr($radek,StrLen($shody[0]));
$zmena = true;
}
while (PReg_Match('/^(.*) ]*>
]*> ]*>([^<]*)<\/th> ]*>([^<]*)<\/th> ]*>([^<]*)<\/th> ]*>([^<]*)<\/th><\/tr>/',$radek,$shody)) { //zacatek tabulky se ctyrmi sloupci
$radek = $shody[1].'\begin{table}[ht]{\begin{center}\scriptsize\begin{tabular}{|c|c|c|c|}\hline'."\n".'\bfseries '.$shody[2].' & \bfseries '.$shody[3].' & \bfseries '.$shody[4].' & \bfseries '.$shody[5].' \\\\ \hline'.SubStr($radek,StrLen($shody[0]));
$zmena = true;
}
while (PReg_Match('/^(.*) ]*> ]*>([^<]*)<\/td> ]*>([^<]*)<\/td> ]*>([^<]*)<\/td> ]*>([^<]*)<\/td><\/tr>/',$radek,$shody)) { //telo tabulky se ctyrmi sloupci
$radek = ''.$shody[1].$shody[2].' & '.$shody[3].' & '.$shody[4].' & '.$shody[5].' \\\\ \hline'.SubStr($radek,StrLen($shody[0]));
$zmena = true;
}
while (PReg_Match('/^(.*)<\/table>/',$radek,$shody)) { //konec tabulky
$radek = $shody[1].'\end{tabular}\end{center}}\end{table}'.SubStr($radek,StrLen($shody[0]));
$zmena = true;
}
while (PReg_Match('/^(.*)