Index: pikchr.y ================================================================== --- pikchr.y +++ pikchr.y @@ -335,10 +335,11 @@ unsigned int nIn; /* Number of bytes in zIn */ char *zOut; /* Result accumulates here */ unsigned int nOut; /* Bytes written to zOut[] so far */ unsigned int nOutAlloc; /* Space allocated to zOut[] */ unsigned char eDir; /* Current direction */ + unsigned int mFlags; /* Flags passed to pikchr() */ PElem *cur; /* Element under construction */ PEList *list; /* Element list under construction */ PVar *pVar; /* Application-defined variables */ PBox bbox; /* Bounding box around all elements */ /* Cache of layout values. <=0.0 for unknown... */ @@ -1960,11 +1961,11 @@ /* Append a style="..." text. But, leave the quote unterminated, in case ** the caller wants to add some more. */ static void pik_append_style(Pik *p, PElem *pElem){ - pik_append(p, "style=\"", -1); + pik_append(p, " style=\"", -1); if( pElem->fill>=0 ){ pik_append_clr(p, "fill:", pElem->fill, ";"); }else{ pik_append(p,"fill:none;",-1); } @@ -2247,11 +2248,11 @@ /* ** Process an "assert( place1 == place2 )" statement. Always return NULL. */ static PElem *pik_place_assert(Pik *p, PPoint *e1, PToken *pEq, PPoint *e2){ - char zE1[100], zE2[100], zMsg[200]; + char zE1[100], zE2[100], zMsg[210]; /* Convert the numbers to strings using %g for comparison. This ** limits the precision of the comparison to account for rounding error. */ snprintf(zE1, sizeof(zE1), "(%g,%g)", e1->x, e1->y); zE1[sizeof(zE1)-1] = 0; snprintf(zE2, sizeof(zE2), "(%g,%g)", e2->x, e2->y); zE1[sizeof(zE2)-1] = 0; @@ -3842,10 +3843,23 @@ h = p->bbox.ne.y - p->bbox.sw.y; p->wSVG = (int)(p->rScale*w); p->hSVG = (int)(p->rScale*h); pik_append_dis(p, " viewBox=\"0 0 ",w,""); pik_append_dis(p, " ",h,"\">\n"); + if(1){ + /* emit original pikchr source code as metadata */ + /* FIXME: emit this only if a certain p->mFlags is set. */ + pik_append(p, "\n", 11); + pik_append(p, "\n", + -1); + pik_append(p, "zIn, (int)p->nIn); + pik_append(p, "]]>\n", 17); + pik_append(p, "\n", 17); + pik_append(p, "\n", 12); + } pik_elist_render(p, pEList); pik_append(p,"\n", -1); }else{ p->wSVG = -1; p->hSVG = -1; @@ -4313,10 +4327,11 @@ memset(&s, 0, sizeof(s)); s.zIn = zText; s.nIn = (unsigned int)strlen(zText); s.eDir = DIR_RIGHT; s.zClass = zClass; + s.mFlags = mFlags; pik_parserInit(&sParse, &s); #if 0 pik_parserTrace(stdout, "parser: "); #endif for(i=0; zText[i] && s.nErr==0; i+=sz){