Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #405 from progit/use_pandoc_tables

Use pandoc tables for pdf generation
  • Loading branch information...
commit fa5527927df803da9f9bb359afdf142970eb1cff 2 parents 7d3af49 + a7159ae
@jnavila jnavila authored
View
15 en/02-git-basics/01-chapter2.markdown
@@ -561,6 +561,11 @@ The most interesting option is `format`, which allows you to specify your own lo
Table 2-1 lists some of the more useful options that format takes.
+<!-- Attention to translators: this is a table declaration.
+The lines must be formatted as follows
+<TAB><First column text><TAB><Second column text>
+-->
+
Option Description of Output
%H Commit hash
%h Abbreviated commit hash
@@ -596,6 +601,11 @@ The `oneline` and `format` options are particularly useful with another `log` op
Those are only some simple output-formatting options to `git log` — there are many more. Table 2-2 lists the options we’ve covered so far and some other common formatting options that may be useful, along with how they change the output of the `log` command.
+<!-- Attention to translators: this is a table declaration.
+The lines must be formatted as follows
+<TAB><First column text><TAB><Second column text>
+-->
+
Option Description
-p Show the patch introduced with each commit.
--word-diff Show the patch in a word diff format.
@@ -625,6 +635,11 @@ The last really useful option to pass to `git log` as a filter is a path. If you
In Table 2-3 we’ll list these and a few other common options for your reference.
+<!-- Attention to translators: this is a table declaration.
+The lines must be formatted as follows
+<TAB><First column text><TAB><Second column text>
+-->
+
Option Description
-(n) Show only the last n commits
--since, --after Limit the commits to those made after the specified date.
View
37 latex/makepdf
@@ -78,6 +78,22 @@ def pre_pandoc(string, config)
s /\`(http:\/\/[A-Za-z0-9\/\%\&\=\-\_\\\.\(\)\#]+)\`/, '<\1>'
s /(\n\n)\t(http:\/\/[A-Za-z0-9\/\%\&\=\-\_\\\.\(\)\#]+)\n([^\t]|\t\n)/, '\1<\2>\1'
+ # Match table in markdown and change them to pandoc's markdown tables
+ s /(\n(\n\t([^\t\n]+)\t([^\t\n]+))+\n\n)/ do
+ first_col=20
+ t = $1.gsub /(\n?)\n\t([^\t\n]+)\t([^\t\n]+)/ do
+ if $1=="\n"
+ # This is the header, need to add the dash line
+ $1 << "\n " << $2 << " "*(first_col-$2.length) << $3 <<
+ "\n " << "-"*18 << " " << "-"*$3.length
+ else
+ # Table row : format the first column as typewriter and align
+ $1 << "\n `" << $2 << "`" + " "*(first_col-$2.length-2) << $3
+ end
+ end
+ t << "\n"
+ end
+
# Process figures
s /Insert\s18333fig\d+\.png\s*\n.*?\d{1,2}-\d{1,2}\. (.*)/, 'FIG: \1'
end
@@ -112,25 +128,8 @@ def post_pandoc(string, config)
# Convert inline-verbatims into \texttt (which is able to wrap)
s /\\verb(\W)(.*?)\1/ ,'\\texttt{\2}'
- # Make Tables 2-1..2-3 actual tables
- s /\\begin\{verbatim\}\n(([^\t\n]+\t.*?\n)+)(([^\t\n]*)\n)?\\end\{verbatim\}/ do
- $cap = $4
- "\\begin{table}[ht!]
- \\refstepcounter{tab}
- \\centering
- \\label{tab:\\thetab}
- \\begin{tabular}{p{2.75cm}p{8.25cm}}
- \\toprule\n" <<
- verbatim_sanitize($1).
- gsub(/^([^\n\t]+)\t/, '{\footnotesize\texttt{\1}} & ').
- gsub(/(\n)/, '\\\\\\\\\1').
- sub(/\{\\footnotesize\\texttt(.*?)\n/, '{\1\midrule ').
- concat("
- \\bottomrule
- \\end{tabular}
- \\textbf{\\caption{#{$cap}}}
- \\end{table}")
- end
+ # Style ctables
+ s /ctable\[pos = H, center, botcap\]\{..\}/ , 'ctable[pos = ht!, caption = ~ ,width = 130mm, center, botcap]{lX}'
# Shaded verbatim block
s /(\\begin\{verbatim\}.*?\\end\{verbatim\})/m, '\begin{shaded}\1\end{shaded}'
View
6 latex/template.tex
@@ -13,6 +13,10 @@
\usepackage{booktabs}
\usepackage{indentfirst}
\usepackage{framed,color}
+\usepackage{caption}
+\captionsetup{font=bf,position=below}
+
+\usepackage{ctable}
\definecolor{shadecolor}{gray}{0.90}
@@ -91,7 +95,7 @@
\label{img:\theimg}
\centering\IfFileExists{figures/\theimg.pdf}{\includegraphics[width=\maxwidth]{figures/\theimg.pdf}}{\includegraphics[width=\maxwidth]{figures/\theimg.png}}
- \textbf{\caption{#1}}
+ \caption{#1}
\end{figure}}
\newcounter{tab}[chapter]

0 comments on commit fa55279

Please sign in to comment.
Something went wrong with that request. Please try again.