*! 11jul2013 * @@ Written by Elliott Lowy, mostly on the US government's dime (17 US Code ยง 105). program projix version 11 mata: DoIt() end version 11 mata: void DoIt() { //>>def func<< class tabel scalar t class recentle_proj scalar prj class dataset_dta scalar ds prj.get() if (!truish(prj.prjdir)) errel("projix cannot run outside of a defined project") scmd=subcmdl(main=st_local("0"),("define","compile"),"oknone") if (scmd=="define") { clearl() vars="heading","cell","tip","link" (void) st_addvar(("str10","str10","str10","byte"),vars) charset(vars,"projix",vars) savel(prj.prjdir+"projix") return } syntaxl(main,(&(usedta="using"))) if (truish(usedta)) usedta=pcanon(usedta,"fex") else usedta=prj.prjdir+"projix.dta" ds.with("d") ds.readfile(usedta) //4vars: title,text,link,tip files=expand(subfiles(prj.prjdir,("*.htm","*.html")),2) for (fi=1;fi<=rows(files);fi++) { bit=ftostr(files[fi,1]) if (regexm(bit,">def func<< bits=strtoreal(tokel(spec,",")) if (length(bits)==1) bits=bits,bits subs=paths:*0 for (p=1;p<=rows(paths);p++) subs[p]=untokenpath(cut(tokenpath(paths[p]),bits[1],bits[2])) return(subs) } string colvector Msub(string scalar spec, string colvector metas) { //>>def func<< subs=metas:*0 spec=ocanon("meta field",spec,("t:itle","r:evision","d:escription")) for (m=1;m<=rows(metas);m++) { tokd=tokenfunc(metas[m],spec) subs[m]=cut(select(tokd[1,],tru2(tokd[2,])),.,1,1) } return(subs) } end