├── .gitignore ├── Makefile ├── README.md ├── config.mk ├── doc ├── config ├── config_black └── config_darkorange ├── ssg ├── ssg.1 └── t └── test /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # ssg - simple slide generator 2 | # nibble - MIT License - 2010 3 | 4 | include config.mk 5 | 6 | all: 7 | @echo sudo make install PREFIX=/usr 8 | 9 | clean: 10 | @rm -f t/test.* t/test_black.* t/test_darkorange.* 11 | 12 | dist: clean 13 | @echo creating dist tarball 14 | @mkdir -p ssg-${VERSION} 15 | @cp -R Makefile config.mk README TODO \ 16 | ssg.1 ssg t doc ssg-${VERSION} 17 | @tar -cf ssg-${VERSION}.tar ssg-${VERSION} 18 | @gzip ssg-${VERSION}.tar 19 | @rm -rf ssg-${VERSION} 20 | 21 | install: 22 | @echo installing executable file to ${DESTDIR}${PREFIX}/bin 23 | @mkdir -p ${DESTDIR}${PREFIX}/bin 24 | @cp -f ssg ${DESTDIR}${PREFIX}/bin 25 | @chmod 755 ${DESTDIR}${PREFIX}/bin/ssg 26 | @echo installing manual page to ${DESTDIR}${MANPREFIX}/man1 27 | @mkdir -p ${DESTDIR}${MANPREFIX}/man1 28 | @sed "s/VERSION/${VERSION}/g" < ssg.1 > ${DESTDIR}${MANPREFIX}/man1/ssg.1 29 | @chmod 644 ${DESTDIR}${MANPREFIX}/man1/ssg.1 30 | 31 | deinstall uninstall: 32 | @echo removing executable file from ${DESTDIR}${PREFIX}/bin 33 | @rm -f ${DESTDIR}${PREFIX}/bin/ssg 34 | @echo removing manual page from ${DESTDIR}${MANPREFIX}/man1 35 | @rm -f ${DESTDIR}${MANPREFIX}/man1/ssg.1 36 | 37 | test: 38 | cd t && cat test | ../ssg > test.ps 39 | cd t && cat test | ../ssg -c ../doc/config_black > test_black.ps 40 | cd t && cat test | ../ssg -c ../doc/config_darkorange > test_darkorange.ps 41 | 42 | test-pdf: test 43 | cd t && ps2pdf test.ps 44 | cd t && ps2pdf test_black.ps 45 | cd t && ps2pdf test_darkorange.ps 46 | 47 | .PHONY: all clean dist install uninstall test test-pdf 48 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ssg - simple slide generator 2 | 3 | ## Description 4 | 5 | ssg is a slide generation system which provides a markdown-like syntax. 6 | 7 | ## Usage 8 | 9 | `cat slides | ssg > slides.ps` 10 | 11 | See t/test for typical use cases. 12 | 13 | ## Customization 14 | 15 | Copy doc/config to your working directory and customize it. Then, load the 16 | new config with: 17 | 18 | `cat slides | ssg -c config > slides.ps` 19 | 20 | ## Encoding 21 | 22 | `ssg < slides | iconv -f UTF-8 -t L1 > slides.ps` 23 | 24 | ## Author 25 | 26 | * Nibble \ 27 | -------------------------------------------------------------------------------- /config.mk: -------------------------------------------------------------------------------- 1 | # ssg version 2 | VERSION = 0.1 3 | 4 | # paths 5 | PREFIX = /usr/local 6 | MANPREFIX = ${PREFIX}/share/man 7 | -------------------------------------------------------------------------------- /doc/config: -------------------------------------------------------------------------------- 1 | # Slide 2 | $hdrsz="75"; 3 | $hdrcolor="0 0 0"; 4 | $bgcolor="1 1 1"; 5 | $linecolor="0 0 0"; 6 | # Frontpage font 7 | $frontfont="Verdana"; 8 | $frontfontsz="60"; 9 | $frontfontcolor="0.5 0.5 0.9"; 10 | # Author font 11 | $authorfont="Times-Italic"; 12 | $authorfontsz="23"; 13 | $authorfontcolor="0 0 0"; 14 | # Title font 15 | $titlefont="Verdana"; 16 | $titlefontsz="40"; 17 | $titlefontcolor="0.5 0.5 0.9"; 18 | # Default font 19 | $mainfont="Verdana"; 20 | $mainfontsz="25"; 21 | $mainfontcolor="0 0 0"; 22 | # Code Block font 23 | $codefont="Courier"; 24 | $codefontsz="20"; 25 | $codefontcolor="0 0 0"; 26 | # Tiny font 27 | $tinyfont="Verdana"; 28 | $tinyfontsz="18"; 29 | $tinyfontcolor="0 0 0"; 30 | -------------------------------------------------------------------------------- /doc/config_black: -------------------------------------------------------------------------------- 1 | # Slide 2 | $hdrsz="75"; 3 | $hdrcolor="0 0 0"; 4 | $bgcolor="0 0 0"; 5 | $linecolor="1 1 1"; 6 | # Frontpage font 7 | $frontfont="Verdana"; 8 | $frontfontsz="60"; 9 | $frontfontcolor="0.5 0.5 0.9"; 10 | # Author font 11 | $authorfont="Times-Italic"; 12 | $authorfontsz="23"; 13 | $authorfontcolor="1 1 1"; 14 | # Title font 15 | $titlefont="Verdana"; 16 | $titlefontsz="40"; 17 | $titlefontcolor="0.5 0.5 0.9"; 18 | # Default font 19 | $mainfont="Verdana"; 20 | $mainfontsz="25"; 21 | $mainfontcolor="1 1 1"; 22 | # Code Block font 23 | $codefont="Courier"; 24 | $codefontsz="20"; 25 | $codefontcolor="1 1 1"; 26 | # Tiny font 27 | $tinyfont="Verdana"; 28 | $tinyfontsz="18"; 29 | $tinyfontcolor="1 1 1"; 30 | -------------------------------------------------------------------------------- /doc/config_darkorange: -------------------------------------------------------------------------------- 1 | # Slide 2 | $hdrsz="75"; 3 | $hdrcolor="0.89 0.38 0"; 4 | $bgcolor="0.1 0.1 0.1"; 5 | $linecolor="0.89 0.38 0"; 6 | # Frontpage font 7 | $frontfont="Verdana"; 8 | $frontfontsz="60"; 9 | $frontfontcolor="0.89 0.38 0"; 10 | # Author font 11 | $authorfont="Times-Italic"; 12 | $authorfontsz="23"; 13 | $authorfontcolor="1 1 1"; 14 | # Title font 15 | $titlefont="Verdana"; 16 | $titlefontsz="40"; 17 | $titlefontcolor="1 1 1"; 18 | # Default font 19 | $mainfont="Verdana"; 20 | $mainfontsz="25"; 21 | $mainfontcolor="1 1 1"; 22 | # Code Block font 23 | $codefont="Courier"; 24 | $codefontsz="20"; 25 | $codefontcolor="1 1 1"; 26 | # Tiny font 27 | $tinyfont="Verdana"; 28 | $tinyfontsz="18"; 29 | $tinyfontcolor="1 1 1"; 30 | -------------------------------------------------------------------------------- /ssg: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | # ssg - simple slide generator 3 | # nibble - MIT License - 2010-2011 4 | # Contribs: pancake 5 | 6 | # Configuration vars 7 | # Slide 8 | $hdrsz="75"; 9 | $hdrcolor="0 0 0"; 10 | $bgcolor="1 1 1"; 11 | $linecolor="0 0 0"; 12 | # Frontpage font 13 | $frontfont="Verdana"; 14 | $frontfontsz="60"; 15 | $frontfontcolor="0.5 0.5 0.9"; 16 | # Author font 17 | $authorfont="Times-Italic"; 18 | $authorfontsz="23"; 19 | $authorfontcolor="0 0 0"; 20 | # Title font 21 | $titlefont="Verdana"; 22 | $titlefontsz="40"; 23 | $titlefontcolor="0.5 0.5 0.9"; 24 | # Default font 25 | $mainfont="Verdana"; 26 | $mainfontsz="25"; 27 | $mainfontcolor="0 0 0"; 28 | # Code Block font 29 | $codefont="Courier"; 30 | $codefontsz="20"; 31 | $codefontcolor="0 0 0"; 32 | # Tiny font 33 | $tinyfont="Verdana"; 34 | $tinyfontsz="18"; 35 | $tinyfontcolor="0 0 0"; 36 | 37 | # Load user config 38 | foreach (0 .. $#ARGV) { 39 | do $ARGV[$_] if ($ARGV[$_-1] eq "-c"); 40 | &usage if ($ARGV[$_] eq "-h"); 41 | } 42 | 43 | # Global vars 44 | $pages = 1; 45 | $code = 0; 46 | $bgimg = ""; 47 | 48 | sub usage { 49 | print " Usage: $0 [-c file]\n"; 50 | exit 1; 51 | } 52 | 53 | sub printdict { 54 | print <<__DICT__; 55 | %!PS-Adobe-3.0 56 | %%DocumentMedia: SLIDE 842 595 0 () () 57 | %%EndComments 58 | %%BeginDefaults 59 | %%PageMedia: SLIDE 60 | %%EndDefaults 61 | << /PageSize [842 595] /ImagingBBox null >> setpagedevice 62 | 63 | /ReEncode { 64 | exch findfont 65 | dup length dict 66 | begin 67 | { 68 | 1 index /FID eq 69 | { pop pop } 70 | { def } ifelse 71 | } forall 72 | /Encoding ISOLatin1Encoding def 73 | currentdict 74 | end 75 | definefont 76 | pop 77 | } bind def 78 | /Verdana /Verdana ReEncode 79 | /Courier /Courier ReEncode 80 | /Times-Italic /Times-Italic ReEncode 81 | 82 | /pagewidth 842 def 83 | /pageheight 595 def 84 | /headerheight $hdrsz def 85 | /pad 10 def 86 | 87 | /leftmargin 30 def 88 | /topmargin 595 def 89 | 90 | /frontfontsz $frontfontsz def 91 | /authorfontsz $authorfontsz def 92 | /titlefontsz $titlefontsz def 93 | /mainfontsz $mainfontsz def 94 | /codefontsz $codefontsz def 95 | /tinyfontsz $tinyfontsz def 96 | 97 | /titlefonth titlefontsz pad add def 98 | /mainfonth mainfontsz pad add def 99 | /codefonth codefontsz pad add def 100 | /tinyfonth tinyfontsz pad add def 101 | /frontfonth frontfontsz pad add def 102 | /authorfonth authorfontsz pad add def 103 | 104 | /titlefont /$titlefont findfont titlefontsz scalefont def 105 | /mainfont /$mainfont findfont mainfontsz scalefont def 106 | /codefont /$codefont findfont codefontsz scalefont def 107 | /tinyfont /$tinyfont findfont tinyfontsz scalefont def 108 | /frontfont /$frontfont findfont frontfontsz scalefont def 109 | /authorfont /$authorfont findfont authorfontsz scalefont def 110 | 111 | /headermargin 112 | pageheight headerheight titlefonth sub 2 div titlefontsz add sub 113 | def 114 | /rightmargin pagewidth leftmargin sub def 115 | /tbtop topmargin def 116 | /ypos topmargin def 117 | 118 | /xcur { currentpoint pop } def 119 | /ycur { currentpoint exch pop } def 120 | 121 | /wordbreak ( ) def 122 | /linewrap { 123 | /proc exch def 124 | /linelength exch def 125 | /textstring exch def 126 | /breakwidth wordbreak stringwidth pop def 127 | /curwidth 0 def 128 | /lastwordbreak 0 def 129 | /startchar 0 def 130 | /restoftext textstring def 131 | { 132 | restoftext wordbreak search 133 | { 134 | /nextword exch def pop 135 | /restoftext exch def 136 | /wordwidth nextword stringwidth pop def 137 | curwidth wordwidth add linelength gt 138 | { 139 | textstring startchar 140 | lastwordbreak startchar sub 141 | getinterval proc 142 | /startchar lastwordbreak def 143 | /curwidth wordwidth breakwidth add def 144 | } 145 | { 146 | /curwidth curwidth wordwidth add 147 | breakwidth add def 148 | } ifelse 149 | /lastwordbreak lastwordbreak 150 | nextword length add 1 add def 151 | } 152 | { 153 | pop exit 154 | } ifelse 155 | } loop 156 | /lastchar textstring length def 157 | textstring startchar lastchar startchar sub 158 | getinterval proc 159 | } def 160 | 161 | /line { 162 | $linecolor setrgbcolor 163 | 0.5 setlinewidth 164 | leftmargin ypos moveto 165 | rightmargin ypos lineto 166 | stroke 167 | } def 168 | 169 | /center { 170 | dup 171 | /str exch def 172 | /sw str stringwidth pop def 173 | /xpos pagewidth sw sub 2 div xcur sub def 174 | xpos 0 rmoveto 175 | } def 176 | 177 | /objcenter { 178 | pagewidth exch sub 2 div 0 translate 179 | } def 180 | 181 | /s { 182 | /tbtop topmargin def 183 | /ypos topmargin def 184 | $bgcolor setrgbcolor 185 | 0 setlinewidth 186 | newpath 187 | 0 pageheight moveto 188 | pagewidth pageheight lineto 189 | pagewidth 0 lineto 190 | 0 0 lineto 191 | closepath 192 | fill 193 | stroke 194 | } def 195 | 196 | /l { 197 | /h exch def 198 | /ypos ypos h sub def 199 | leftmargin ypos moveto 200 | } def 201 | 202 | /title { 203 | line 204 | frontfont setfont 205 | $frontfontcolor setrgbcolor 206 | { pagewidth leftmargin 2 mul sub } 207 | { frontfonth l center show } 208 | linewrap 209 | frontfonth 2 div l 210 | line 211 | } def 212 | 213 | /author { 214 | authorfont setfont 215 | $authorfontcolor setrgbcolor 216 | { pagewidth leftmargin 2 mul sub } 217 | { authorfonth l center show } 218 | linewrap 219 | } def 220 | 221 | /header { 222 | /ypos pageheight headerheight sub def 223 | $hdrcolor setrgbcolor 224 | 0 setlinewidth 225 | newpath 226 | 0 pageheight moveto 227 | pagewidth pageheight lineto 228 | pagewidth ypos lineto 229 | 0 ypos lineto 230 | closepath 231 | fill 232 | stroke 233 | leftmargin headermargin moveto 234 | titlefont setfont 235 | $titlefontcolor setrgbcolor 236 | center show 237 | leftmargin ypos moveto 238 | } def 239 | 240 | /n { 241 | mainfont setfont 242 | $mainfontcolor setrgbcolor 243 | { pagewidth leftmargin 2 mul sub } 244 | { mainfonth l show } 245 | linewrap 246 | } def 247 | 248 | /cn { 249 | codefont setfont 250 | $codefontcolor setrgbcolor 251 | { pagewidth leftmargin 2 mul sub } 252 | { codefonth l show } 253 | linewrap 254 | } def 255 | 256 | /tn { 257 | tinyfont setfont 258 | $tinyfontcolor setrgbcolor 259 | { pagewidth leftmargin 2 mul sub } 260 | { tinyfonth l show } 261 | linewrap 262 | } def 263 | 264 | /is { 265 | /level1 save def 266 | /showpage {} def 267 | } def 268 | 269 | /ie { 270 | level1 restore 271 | } def 272 | 273 | /bs { 274 | /tbtop ypos def 275 | } def 276 | 277 | /be { 278 | /tm tbtop pad sub def 279 | /bm ypos pad sub def 280 | newpath 281 | leftmargin 10 sub tm moveto 282 | rightmargin tm lineto 283 | rightmargin bm lineto 284 | leftmargin 10 sub bm lineto 285 | closepath 286 | $linecolor setrgbcolor 287 | 0.5 setlinewidth 288 | stroke 289 | } def 290 | 291 | __DICT__ 292 | } 293 | 294 | sub printfooter { 295 | print "showpage\n\n%%EOF"; 296 | } 297 | 298 | sub printimg { 299 | local $fn = shift; 300 | if ($fn=~/^(.*)\|(.*)$/ || !($fn=~/\.ps$/)) { 301 | $fn = $1 if ($2); 302 | open IMG, "-|", "convert $2 '$fn' ps:-" or die ("Cannot find $fn\n"); 303 | } else { 304 | open IMG, "<", $fn or die ("Cannot find postscript file $fn\n"); 305 | } 306 | print "is\n"; 307 | for ($s=""; ; $s.=$_) { 308 | if ($_=~/%%BoundingBox: \d+ \d+ (\d+) \d+/) { 309 | print "$1 objcenter\n"; 310 | last; 311 | } 312 | } 313 | print "%%BeginDocument: $1\n$s",,"\n\n%%EndDocument\nie\n"; 314 | close IMG; 315 | } 316 | 317 | # main 318 | 319 | &printdict; 320 | 321 | #STDIN=>':encoding(utf8)'; 322 | #STDOUT=>':encoding(iso 8859-1)'; 323 | while () { 324 | s/[\r\n]+//g; s/([^^])\\/$1\\\\/g; s/(\(|\))/\\$1/g; 325 | /^%/ && do next; 326 | /^##(.*)/ && do { # Main Title 327 | if ($code == 1) { print "be\n"; $code = 0; } 328 | if ($pages != 1) { print "showpage\n"; } 329 | print "%%Page: $pages $pages\ns\n"; 330 | if ($bgimg ne "") { &printimg ($bgimg)} 331 | print "frontfonth l\n($1) title\nfrontfonth l\n"; 332 | $pages++; 333 | next; 334 | }; 335 | /^#(.*)/ && do { # Slide Title 336 | if ($code == 1) { print "be\n"; $code = 0 } 337 | if ($pages != 1) { print "showpage\n" } 338 | print "%%Page: $pages $pages\ns\n"; 339 | if ($bgimg ne "") { &printimg ($bgimg)} 340 | print "($1) header\n"; 341 | $pages++; 342 | next; 343 | }; 344 | /^\.$/ && do { # Blank slide 345 | if ($code == 1) { print "be\n"; $code = 0 } 346 | if ($pages != 1) { print "showpage\n" } 347 | print "%%Page: $pages $pages\ns\n"; 348 | if ($bgimg ne "") { &printimg ($bgimg) } 349 | $pages++; 350 | next; 351 | }; 352 | /^@(.*)/ && do { # Author 353 | if ($code == 1) { print "be\n"; $code = 0; } 354 | print "($1 ) author\n"; 355 | next; 356 | }; 357 | /^\t(.*)/ && do { # Code 358 | if ($code == 0) { print "bs\n"; $code = 1; } 359 | print "($1 ) cn\n"; 360 | next; 361 | }; 362 | /^\[(.*)\]/ && do { # Image 363 | if ($code == 1) { print "be\n"; $code = 0; } 364 | &printimg ($1); 365 | next; 366 | }; 367 | /^\{(.*)\}/ && do { # Background 368 | $bgimg = $1; 369 | next; 370 | }; 371 | /^_(.*)/ && do { # Tiny 372 | if ($code == 1) { print "be\n"; $code = 0; } 373 | print "($1 ) tn\n"; 374 | next; 375 | }; 376 | s/^\\//; 377 | if ($code == 1) { print "be\n"; $code = 0; } 378 | print "($_ ) n\n"; 379 | } 380 | &printfooter; 381 | -------------------------------------------------------------------------------- /ssg.1: -------------------------------------------------------------------------------- 1 | .TH SSG 1 ssg\-VERSION 2 | .SH NAME 3 | ssg \- simple slide generator 4 | .SH SYNOPSIS 5 | .B ssg 6 | .RB [-c file] 7 | .SH DESCRIPTION 8 | ssg is a slide generation system which provides a markdown-like syntax. 9 | .SH OPTIONS 10 | .TP 11 | .B \-c file 12 | loads configuration file. 13 | .SH USAGE 14 | cat slides | ssg > slides.ps 15 | .P 16 | See t/test for a typical case of use. 17 | .SH ENCODING 18 | ssg < slides | iconv -f UTF-8 -t L1 > slides.ps 19 | .SH AUTHORS 20 | nibble 21 | -------------------------------------------------------------------------------- /t/test: -------------------------------------------------------------------------------- 1 | % Test 1 - Front Page (Title + authors) 2 | ##Simple Slide Generator 3 | @nibble 4 | @author2 5 | % ----------------------------------------------------- % 6 | % Test 2 - Slide with header and Text 7 | #Test 2 (Header + Text) 8 | This is a simple slide, it just contains some text and ... 9 | - Item 1 10 | - SubItem 1.1 11 | - SubItem 1.2 12 | - SubItem 1.3 13 | - Item 2 14 | - Item 3 15 | - Item 4 16 | - SubItem 4.1 17 | - Item 5 18 | 19 | returns :) :] }:( 20 | % ----------------------------------------------------- % 21 | % Test 3 (Header + Text + Code) 22 | #Test 3 (Header + Text + Code) 23 | This is a slide with text and code 24 | #include 25 | 26 | int main() { 27 | printf ("Hello World!\n"); 28 | } 29 | and some more text. 30 | % ----------------------------------------------------- % 31 | % Test 4 (Blank Slide) 32 | . 33 | % ----------------------------------------------------- % 34 | % Test 5 (Blank Slide + Text) 35 | . 36 | This is a simple slide, it just contains some text and ... 37 | - Item 1 38 | - SubItem 1.1 39 | - SubItem 1.2 40 | - SubItem 1.3 41 | - Item 2 42 | - Item 3 43 | - Item 4 44 | - SubItem 4.1 45 | - Item 5 46 | 47 | returns on a blank slide. 48 | % ----------------------------------------------------- % 49 | % Test 6 (Blank Slide + Text + Code + Tiny) 50 | . 51 | This is a slide with text and code 52 | #include 53 | 54 | int main() { 55 | printf ("Hello World!\n"); 56 | } 57 | and some more text. 58 | #include 59 | 60 | int main() { 61 | printf ("Bye bye World!\n\n"); 62 | } 63 | _ and some tiny text. 64 | % ----------------------------------------------------- % 65 | % Test 7 (special char scape) 66 | #Test 7 (special char scape) 67 | Some text and ... 68 | 69 | \@section..text 70 | 71 | \... Use of @ and . at the beginning of the line 72 | --------------------------------------------------------------------------------