-
Notifications
You must be signed in to change notification settings - Fork 2
/
pnotes.sty
125 lines (104 loc) · 3.32 KB
/
pnotes.sty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
%%
%% This is file `pnotes.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% pnotes.dtx (with options: `package')
%%
%% This is a generated file.
%%
%% Copyright (C) 2014-2016 by rwen, jonasc
%%
%% This file may be distributed and/or modified under the conditions of the
%% Creative Commons Attribution-ShareAlike 3.0 Unported License.
%% The license can be found in LICENSE and on:
%%
%% https://creativecommons.org/licenses/by-sa/3.0/
%%
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{pnotes}[2017/03/23 v1.4 pdfpc presentation notes]
\RequirePackage{xstring}
\RequirePackage{kvoptions}
\RequirePackage{expl3}
\RequirePackage{etoolbox}
\DeclareStringOption[0]{duration}
\DeclareStringOption[0]{endslide}
\DeclareStringOption[.]{outputdir}
\DeclareStringOption[0]{fontsize}
\ProcessKeyvalOptions*
\ExplSyntaxOn
\cs_new_eq:NN \pnotes@trimspaces \tl_trim_spaces:n
\ExplSyntaxOff
\newwrite\pnotes@output
\newwrite\pnotes@endslideout
\newread\pnotes@endslidein
\AtBeginDocument{%
\immediate\openout\pnotes@output\jobname.pdfpc\relax%
\immediate\write\pnotes@output{[file]}%
\immediate\write\pnotes@output{\jobname.pdf}%
\ifnum\pnotes@duration>0%
\immediate\write\pnotes@output{[duration]}%
\immediate\write\pnotes@output{\pnotes@duration}%
\fi%
\ifnum\pnotes@fontsize>0%
\immediate\write\pnotes@output{[font_size]}%
\immediate\write\pnotes@output{\pnotes@fontsize}%
\fi%
\ifnum\pnotes@endslide>0%
\immediate\write\pnotes@output{[end_user_slide]}%
\immediate\write\pnotes@output{\pnotes@endslide}%
\else%
\IfFileExists{\jobname.pce}{%
\immediate\openin\pnotes@endslidein=\jobname.pce\relax%
\immediate\read\pnotes@endslidein to \pnotes@endslide%
\immediate\write\pnotes@output{[end_user_slide]}%
\immediate\write\pnotes@output{\pnotes@endslide}%
\immediate\closein\pnotes@endslidein%
}{}%
\fi%
\immediate\write\pnotes@output{[notes]}%
}
\AtEndDocument{%
\immediate\closeout\pnotes@output%
}
\begingroup%
\catcode`\#=12%
\gdef\pnotes@slidestart{### }%
\endgroup
\newcount\pnotes@lastframe
\pnotes@lastframe=0
\newcommand{\pnote@writenote}[1]{%
\ifnum\value{framenumber}=\pnotes@lastframe\else%
\immediate\write\pnotes@output{\pnotes@slidestart\theframenumber}%
\fi%
\expandarg%
\StrSubstitute{\unexpanded{#1}}{\unexpanded{\par}}{\unexpanded{\\\\}}[\pnotes@rest]%
\StrCut{\pnotes@rest}{\unexpanded{\\}}\pnotes@first\pnotes@rest%
\whileboolexpr{
not test {\ifdefempty{\pnotes@first}}
or
not test {\ifdefempty{\pnotes@rest}}
}{%
\ifdefempty{\pnotes@first}{%
\immediate\write\pnotes@output{}%
}{%
\immediate\write\pnotes@output{%
- \expandafter\pnotes@trimspaces\expandafter{\pnotes@first}%
}%
}%
\StrCut{\pnotes@rest}{\unexpanded{\\}}\pnotes@first\pnotes@rest%
}%
\pnotes@lastframe=\value{framenumber}%
}
\newcommand{\pnote}[1]{%
\only<1>{\pnote@writenote{#1}}%
}
\newcommand{\plastslide}{%
\immediate\openout\pnotes@endslideout\jobname.pce\relax%
\immediate\write\pnotes@endslideout{\theframenumber}%
\immediate\closeout\pnotes@endslideout%
}
\endinput
%%
%% End of file `pnotes.sty'.