Hacker News new | past | comments | ask | show | jobs | submit login
Reading the Washington Post Without JavaScript (yy091)
1 point by 1vuio0pswjnm7 26 days ago | hide | past | favorite | 1 comment
.

    /*
     needs testing
     washington post
    */

    int fileno (FILE *);
    #define jmp (yy_start) = 1 + 2 *
    int d,e,h,l,x;
    int mode;
   %option nounput noinput noyywrap
   %s W
   %%
   
   "<!DOCTYPE html>" d=0;e=0;h=0;l=0;
   \"@type\":\"NewsArticle\"
   \"@type\":\"LiveBlogPosting\" {
    fwrite("live blog: use yy059\n",1,20,stderr);
    yyterminate();
    }
   \"headline\":\"[^\"]+ if(!h){
    h++;
    fwrite("\n<meta charset=utf-8/>\n",1,23,yyout);
    fwrite("<p>",1,3,yyout);
    for(x=12;x<yyleng;x++)putc(yytext[x],yyout);
    fwrite("</p>",1,4,yyout);
    }
   \"datePublished\":\"[^\"]+ if(!d){
    d++;
    for(x=17;x<yyleng;x++)putc(yytext[x],yyout);
    }
   
   \"content\":\" fwrite("<p>",1,3,yyout);jmp W;
   \"byline\":\" fwrite("<p>",1,3,yyout);jmp W;
   \"location\":\" fwrite("<p>",1,3,yyout);l++;jmp W;
   \"education\":\[\{ e++;
   \"name\":\" if(e){fwrite("<p>",1,3,yyout);jmp W;};
   
   <W>\",\" fwrite("</p>\n",1,5,yyout);if(l)e=0;jmp 0;
   <W>\"\},\{\" if(e){fwrite("</p>\n",1,5,yyout);jmp 0;};
   <W>\"\}\] if(e){fwrite("</p>\n",1,5,yyout);e=0;jmp 0;};
   <W>\\u003c putc(60,yyout);
   <W>\\u003e putc(62,yyout);
   <W>\\n putc(10,yyout);
   <W>[^\134] putc(yytext[0],yyout);
   
   .|\n
   %%
    int main(){
    yylex();
    exit(0);
    }



.

    links -dump https://news.ycombinator.com/item?id=40361859 > 091.l
    sed '1,9d;61,$d;s/^.\{6\}//' 091.l \
    |flex -t8Cem /dev/stdin \
    |cc -std=c89 -W -Wall -pipe -xc -static -s -o yy091 /dev/stdin




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: