/* This program produces an html page showing bullet lists (nested). The input format is trivial. The program can do the following: -Presents only the first items. The following items will be there, but using the white color. The goal is to present one slide in multiple steps, each time showing more items. By putting all items in the page, but invisible, we end up with a fixed layout. -Presents all items, but one in a different color, to show this is the current topic. */ #include #include #include #include #include #include #include #include "util.h" using namespace std; struct ITEM { string item; vector subs; ITEM(const char *line){ item = line; } }; static void no_first (vector &items) { if (items.size() == 0){ items.push_back(ITEM("**** NO FIRST ITEM ***")); items.push_back(ITEM("")); } } static string patch_table (const string &line, const char *tableid) { size_t pos = line.find (""); if (pos != string::npos){ string tmp = string ("
"; return line.substr(0,pos) + tmp + line.substr(pos+7); } return line; } int main (int argc, char *argv[]) { glocal int ret = -1; glocal int itemsize=5; glocal bool nobullet = false; glocal bool nosubbullet = false; glocal.ret = (argc,argv); presentation_setarg (this); navigation_setarg (this); setgrouparg ("Misc."); setarg (' ',"nobullet","No bullet on first item level",glocal.nobullet,false); setarg (' ',"nosubbullet","No bullet on second level",glocal.nosubbullet,false); int ret = -1; if (argc != 1){ usage(); }else{ // Read the input file glocal string title; glocal vector items; glocal vector comments; (argv[0],true); const char *skip = str_skip(line); if (skip[0] == '#'){ glocal.comments.push_back(str_skip(skip+1)); }else if (line[0] != '\0'){ if (strncmp(line,"title:",6)==0){ glocal.title = str_skip(line+6); }else if (strncmp(line,"bullet:",7)==0){ glocal.nobullet = strcmp(str_skip(line+7),"on")!=0; }else if (strncmp(line,"subbullet:",10)==0){ glocal.nosubbullet = strcmp(str_skip(line+10),"on")!=0; }else if (*skip == '-'){ no_first (glocal.items); ITEM &item = glocal.items[glocal.items.size()-1]; item.subs.push_back(skip+1); }else if (isspace(*line)){ no_first (glocal.items); ITEM &item = glocal.items[glocal.items.size()-1]; unsigned item_subs_size = item.subs.size(); if (item_subs_size > 0){ item.subs[item_subs_size-1] += string(" ") + line; }else{ item.item += string (" ") + line; } }else if (skip[0] != '\0'){ glocal.items.push_back (ITEM(line)); } } return 0; navigation_setsteps(glocal.items.size()); glocal int highlit = navigation_gethighlit(); glocal int nbshow = navigation_getnbshow(); if (navigation_getshowtitle()){ printf ("%s\n",glocal.title.c_str()); exit (0); }else if (navigation_getcomments()){ for (unsigned i=0; i%s\n",glocal.comments[i].c_str()); } exit (0); } printf ("\n"); printf ("\n"); navigation_print (argv[0],glocal.items.size()); printf ("\t\n"); printf ("\n"); printf ("\n"); int viewwidth = util_get_viewwidth(); if (viewwidth < 700){ glocal.itemsize = 1; }else if (viewwidth < 1900){ glocal.itemsize = 4; } util_format_title (glocal.title.c_str()); printf ("
\n"); printf ("
\n"); for (int i=0; i<10; i++) printf (" "); printf ("\n"); printf ("\t
    \n"); for (unsigned i=0; i%s\n",i+1,glocal.itemsize,tmp.c_str()); if (item.subs.size() > 0){ printf ("\t\t
      \n"); for (unsigned j=0; j%s\n",i+1,j+1,glocal.itemsize ,tmp.c_str()); } printf ("\t\t
    \n"); } } printf ("\t
\n"); printf ("
\n"); //printf ("\n"); printf ("\n"); printf ("\n"); } return ret; return glocal.ret; }