Skip to content
Snippets Groups Projects
Select Git revision
  • 3182c64253c574028da2d5487061a273c2059a52
  • master default protected
  • 9.0
  • marcus/wix3
  • 8.0
  • nt-tools
  • 7.8
  • 7.6
  • 7.4
  • 7.2
  • 7.0
  • 0.6
  • rosuav/latex-markdown-renderer
  • rxnpatch/rxnpatch
  • marcus/gobject-introspection
  • rxnpatch/8.0
  • rosuav/pre-listening-ports
  • rosuav/async-annotations
  • rosuav/pgsql-ssl
  • rxnpatch/rxnpatch-broken/2023-10-06T094250
  • grubba/fdlib
  • v8.0.2020
  • v8.0.2018
  • v8.0.2016
  • v8.0.2014
  • v8.0.2012
  • v8.0.2008
  • v8.0.2006
  • v8.0.2004
  • v8.0.2002
  • v8.0.2000
  • v8.0.1998
  • v8.0.1996
  • v8.0.1994
  • v8.0.1992
  • v8.0.1990
  • v8.0.1988
  • v8.0.1986
  • rxnpatch/clusters/8.0/2025-04-29T124414
  • rxnpatch/2025-04-29T124414
  • v8.0.1984
41 results

wmml_to_html

Blame
  • wmml_to_html 8.83 KiB
    #!/usr/local/bin/pike
    
    import Stdio;
    import spider;
    import Array;
    
    mapping(int:mapping) links=([]);
    
    string p1(string data);
    
    /* Note: destructive ! */
    string *srt(string *foo)
    {
      sort(map(foo,lower_case),foo);
      return foo;
    }
    
    string quote_param(string s)
    {
      string ret="";
      while(sscanf(s,"%[-a-zA-Z0-9/()*,.]%c%s",string a, int c,s)==3)
        ret+=sprintf("%s%%02x",a,c);
    
      return ret+s;
    }
    
    string unquote_param(string s)
    {
      string *tmp=s/"%";
      for(int e=1;e<sizeof(tmp);e++)
        if(sscanf(tmp[e],"%2x%s",int x, string rest))
          tmp[e]=sprintf("%c%s",x,rest);
    
      return tmp*"";
    }
    
    string code_params(mapping s)
    {
      string ret="";
      foreach(indices(s), string data)
        ret+=" "+data+"="+quote_param(s[data]);
      return ret;
    }
    
    /* Index handling */
    
    void _add_to(mapping foo, string bar, string full)
    {
      mapping m;
      if(!bar)
      {
        if(foo[0])
        {
          foo[0]|=({full});
        }else{
          foo[0]=({full});
        }
        return;
      }
      sscanf(bar,"%s.%s",bar,string rest);
      if(!(m=foo[bar])) m=foo[bar]=([]);
      _add_to(m, rest,full);
    }
    
    void add_to(string bar, string full)
    {
      sscanf(lower_case(unquote_param(bar)),"%*[_ ]%c",int c);
      mapping m;
      if(!(m=links[c])) m=links[c]=([]);
      _add_to(m, bar, full);