#!/usr/local/bin/bee -s # version 1.3 problems : keeps in htm, nesting # call "txtools.bee" # in the same directory # if ( ! shell.ParseArgs("s",{"split"}) ) quit Help() if(Nof(shell.args)==0) shell.args[1] = "stdin" read string shell.args[1] name="s"; s = " <>\n"+ s + "\n\n"; # # Splitting the document into blocks of code and non-code # Replace(s, '\nnnn(.*?)\nnnn':n "\n" ) >> # nnn multi-line comments Replace(@, '\n// .*', "" ) >> # ^// comment PreprocessAll => s if(!(shell.options.split | shell.options.s)) then # normal case Replace(s, 'left....er:\s+\{(.+?)\}':n,'\1') >> Replace(@, 'right....er:\s+\{(.+?)\}':n,'') => s endif Split(s,'') => ss for i=1,Nof(ss) k=Index(ss[i],'<>')-1 # a=(i>1)?InCode( ss[i,1:k]):ss[i,1:k] # code block (small) # Replace(ss[i,k+3:Nof(ss[i])], '\n(: .*?)\n', field=1, InSyntax ) >> # syntax lines InTx >> Replace(@, '\n \n', "\n
\n") >> #
Replace(@, '\n\n', "\n

\n") => b #

ss[i]=a+b endfor s = Sum( ss, "\n") Replace(s, '\n(.*?)\n<>':n, field=1, InDl ) >> # in

list Replace(@, '\n(.*?)\n<>':n, field=1, InDl1 ) >> # in
list Replace(@, '\n(.*?)\n<>':n, field=1, InUl ) >> # in
    block Replace(@, '\n(.*?)\n<>':n, field=1, InOl ) >> # in
      block Replace(@, '\n(.*?)\n<>':n, field=1, InTab ) >> # in block Replace(@, '\n(.*?)\n<>':n, field=1, InTab1 ) >> # in
      block Replace(@, '\n(.*?)\n<>':n, field=1, InBrBlock ) >> # in
      block Replace(@, '\n<[dxotTn]?>', "" ) >> PostprocessAll => s # if(shell.options.split | shell.options.s) then show s else show HtmlHeader()+s+"" endif quit