ref: 2b752ff42ca8c542d64c5b41cd66eae6f3822811
parent: 528b6d8c25839665550a500e53c4cd9329de3927
author: phil9 <telephil9@gmail.com>
date: Sun Feb 4 09:01:56 EST 2024
allow comments in spit presentations all lines starting with a semicolon are comments and thus discarded
--- a/sample.spit
+++ b/sample.spit
@@ -1,3 +1,4 @@
+; Demonstration of spit capabilities
# A sample presentation
spit is a simple presentation tool for plan9.
spit presentations are simple markdown-like files.
@@ -7,11 +8,12 @@
- Quote if the line starts with '> '
- Code if the line is ``` (code block is ended with a similar line).
- Image, in p9 format, if the line starts with '! '
+Lines starting with a semicolon are comments and ignored by spit.
spit doesn't try to do proper layout or resizing, it's on you.
-# Some style examples
-Here is a simple hello world in plan9 C
+# Some examples
+Here is a simple hello world in plan9 C:
```
#include <u.h>
#include <libc.h>
--- a/spit.c
+++ b/spit.c
@@ -191,7 +191,7 @@
void
render(char *f)
{
- enum { Sstart, Scontent, Slist, Squote, Scode };
+ enum { Sstart, Scomment, Scontent, Slist, Squote, Scode };
Biobuf *bp;
char *l;
int s, ln;
@@ -214,6 +214,10 @@
Again:
switch(s){
case Sstart:
+ if(l[0] == ';'){
+ free(l);
+ continue;
+ }
if(l[0] != '#') error(f, ln, "expected title line");
Title:
p = Pt(margin, margin);
@@ -221,6 +225,9 @@
p = rendertitle(b, p, l+2);
s = Scontent;
break;
+ case Scomment:
+ s = Scontent;
+ break;
case Scontent:
if(l[0] == '#')
goto Title;
@@ -235,7 +242,10 @@
break;
}else if(l[0] == '!')
p = renderimage(b, p, l+2);
- else
+ else if(l[0] == ';'){
+ s = Scomment;
+ break;
+ }else
p = rendertext(b, p, l);
break;
case Slist:
@@ -392,6 +402,7 @@
fprint(2, "missing filename\n");
usage();
}
+ setfcr(getfcr() & ~(FPZDIV | FPOVFL | FPINVAL));
if(initdraw(nil, nil, argv0) < 0)
sysfatal("initdraw: %r");
if((mc = initmouse(nil, screen)) == nil)