Last edit
Summary: text.2.wiki.awk
Changed:
< #: Converts n spaces to (n -1) #nbsp; followed by a space.\\
< #: Converts literal {{{\}}}240 to the character {{{\}}}240 == \xa0 - non breaking space.\\
to
> #: Converts n spaces to (n -1) &nbsp; followed by a space.\\
> #: Converts literal \240 to the character \240 == \xa0 - non breaking space.\\
Changed:
< #: Remember to escape | \\ // * # == etc. eg {{{|}}}\\
< #: Use **{{{|}}}** to make bold; [[..|link]] use for spaces.\\
< #: To escape text; use {{{ for .txt files or #:{{{ for .awk files\\
< #: or ::{{{ for .cmd files or ;{{{ for .ini files.\\
< #: (end with the corresponding ..}}})\\
to
> {{{ #: Remember to escape | \\ // * # == etc. eg {{{|}}} }}} \\
> #: Use **{{{|}}}** to make bold; [[..|link]] use for spaces.\\
> #: To escape text; use {{{ for .txt files or #{{{ for .awk files\\
> #: or ::{{{ for .cmd files or ;{{{ for .ini files.\\
> #: (end with the corresponding ..}}})\\
Changed:
< #: test.text.2.wiki.awk.txt == http://awkpaste.blisted.org/cgi/paste.cgi?id=2874#view=text\\
to
> #: test.text.2.wiki.awk.txt == http://awkpaste.blisted.org/cgi/paste.cgi?id=2874&view=text\\
Changed:
< **{{{ }}}**\\
< **{{{ $1 = _in_escape = t = ""; _esc1 = "{\173{"; _esc2 = "}\175}"; }}}**\\
< **{{{ _splat2 = "**"; _bs2 = "\\\\"; }}}**\\
< **{{{ _prefix = _prefix "|#|::|;|//|"; }}}**\\
< **{{{ n = split(_prefix, B, "|"); }}}**\\
to
> \\
> $1 = _in_escape = t = ""; _esc1 = "{\173{"; _esc2 = "}\175}";\\
> _splat2 = "**"; _bs2 = "\\\\";\\
> _prefix = _prefix "|#|::|;|//|";\\
> n = split(_prefix, B, "|");\\
Changed:
< if((! _in_escape) ## (A[i] == _esc1)) {\\
to
> if((! _in_escape) && (A[i] == _esc1)) {\\
Changed:
< #: next;\\
< } else if(_in_escape ## (A[i] == _esc2)) {\\
to
> if($0 == "") next;\\
> } else if(_in_escape && (A[i] == _esc2)) {\\
Changed:
< #: next;\\
to
> if($0 == "") next;\\
Changed:
< s = _splat2 _esc1 " " $0 " " _esc2 _splat2 _bs2;\\
to
> s = _esc1 " " $0 " " _esc2 " " _bs2;\\
Deleted:
< **{{{ }}}**\\
< **{{{ if($0 ~ /\\\\$/) { }}}**\\
< **{{{ s = $0; }}}**\\
< **{{{ } else if($0 ~ /`$/) { }}}**\\
< **{{{ s = substr($0, 1, length($0) - 1); }}}**\\
< **{{{ } else s = $0 "\\\\"; }}}**\\
< **{{{ }}}**\\
< **{{{ gsub("\&", "\\#", s); }}}**\\
< **{{{ gsub("\t", " ", s); }}}**\\
< **{{{ while(gsub(" ", " \\ ", s)) ; }}}**\\
< **{{{ #: & Special in gsub, use "\\&" }}}**\\
< **{{{ }}}**\\
< **{{{ while(gsub("\ \ ", \ }}}**\\
< **{{{ "\\ \\ \\ ", s)) ; }}}**\\
< **{{{ }}}**\\
< **{{{ gsub("\\\\240", "\240", s); }}}**\\
< **{{{ #: if(s ~ /^#/) s = _esc1 "#" _esc2 substr(s, 2); }}}**\\
< **{{{ if(s ~ "^\043") sub("\043", "\\#", s); }}}**\\
< **{{{ }}}**\\
< **{{{ if(s ~ /\\\\$/) { }}}**\\
< **{{{ s = substr(s, 1, length(s) - 2); }}}**\\
< **{{{ gsub("\\\\", "\\\", s); }}}**\\
< **{{{ s = s "\134\134"; }}}**\\
< **{{{ } else gsub("\\\\", "\\\", s); }}}**\\
< **{{{ }}}**\\
Added:
> if($0 ~ /\\\\$/) {\\
> s = $0;\\
> } else if($0 ~ /`$/) {\\
> s = substr($0, 1, length($0) - 1);\\
> } else s = $0 "\\\\";\\
> \\
> gsub("\&", "\\&#38;", s);\\
> gsub("\t", " ", s);\\
> while(gsub(" ", " \\&nbsp; ", s)) ;\\
> #: & Special in gsub, use "\\&"\\
> \\
> while(gsub("\&nbsp; \&nbsp;", \\\
> "\\&nbsp;\\&nbsp;\\&nbsp;", s)) ;\\
> \\
> gsub("\\\ ", " ", s);\\
> gsub("{{{\\\\}}}", "\\", s);\\
> if($1 ~ "^\043") sub("\043", "\\&#35;", s); #: the #\\
> \\
> if(s ~ /\\\\$/) {\\
> s = substr(s, 1, length(s) - 2);\\
> gsub("\\\\", "\\&#92;", s);\\
> s = s "\134\134"; #: the back slash\\
> } else gsub("\\\\", "\\&#92;", s);\\
> \\
> i = index(s, "[["); j = index(s, "\|"); k = index(s, "]]"); \\
> if( 0 < i && i < j && j < k) s = substr(s, 1, j - 1) "\377" substr(s, j + 1);\\
> gsub("\\\052\\\052", "\\&#42;\\&#42;", s); #: **\\
> gsub("\\\173\\\173\\\173", "\\&#123;\\&#123;\\&#123", s); #: {{{\\
> gsub("\\\175\\\175\\\175", "\\&#125;\\&#125;\\&#125", s); #: }}}\\
> gsub("\\\377", "\|", s);\\
Changed:
< **{{{ }}}**\\
< **{{{ c = (c ? c : (_u ? _u : "%u%")) "\\gclip.exe"; }}}**\\
< **{{{ printf("%s", s) | c; }}}**\\
< \\
to
> c = (c ? c : (_u ? _u : "%u%")) "\\gclip.exe";\\
> printf("%s", s) | c;\\
Changed:
< **{{{ }}}**\\
< **{{{ #: regular expression metacharacters: \ ^ $ . [ ] | ( ) * + ? escape with \ }}}**\\
< **{{{ #: filenames may Not contain: \ / : * ? " < > | }}}**\\
< **{{{ #: cmd.exe special: & " ^ % < > | = ( ) @ }}}**\\
< **{{{ #: start ["title"] [/min|/max] [/low|/high] [/wait] [/b] cmd }}}**\\
< **{{{ #: start /wait exefile & call echo.^%ERRORLEVEL^% }}}**\\
< **{{{ #: %u%nircmd.exe exec show|hide|min|max exefile opts }}}**\\
< **{{{ #: shexec open|print filename }}}**\\
< **{{{ #: \a \007 sp\040 !\041 "\042 #\043 $\044 %\045 &\046 }}}**\\
< **{{{ #: '\047 *\052 +\053 -\055 .\056 /\057 <\074 =\075 >\076 }}}**\\
< **{{{ #: ?\077 @\100 \\134 ^\136 `\140 |\174 ~\176 ' '\240 }}}**\\
< \\
to
> {{{ #: regular expression metacharacters: \ ^ $ . [ ] | ( ) * + ? escape with \ }}} \\
> {{{ #: filenames may Not contain: \ / : * ? " < > | }}} \\
> {{{ #: cmd.exe special: & " ^ % < > | = ( ) @ }}} \\
> {{{ #: start ["title"] [/min|/max] [/low|/high] [/wait] [/b] cmd }}} \\
> {{{ #: start /wait exefile & call echo.^%ERRORLEVEL^% }}} \\
> {{{ #: %u%nircmd.exe exec show|hide|min|max exefile opts }}} \\
> {{{ #: shexec open|print filename }}} \\
> {{{ #: \a \007 sp\040 !\041 "\042 #\043 $\044 %\045 &\046 }}} \\
> {{{ #: '\047 *\052 +\053 -\055 .\056 /\057 <\074 =\075 >\076 }}} \\
> {{{ #: ?\077 @\100 \\134 ^\136 `\140 |\174 ~\176 ' '\240 }}} \\
#: C:\#\awk\lib\text.2.wiki.awk
#: 2012-09-23 13:39:45 #:rod.t_2012
#: This file is http://awk.freeshell.org/text.2.wiki.awk (g0ph3r_)
#: Converts text to a format for the awk wiki: http://awk.freeshell.org
#: See: http://awk.freeshell.org/How_to_edit
#: Adds a \\ to end of every line to force line break
#: except those ending in ` or \\ (removes the `)
#: Converts tabs \t to four spaces.
#: Converts n spaces to (n -1) followed by a space.
#: Converts literal \240 to the character \240 == \xa0 - non breaking space.
#: Prints results to stdout and copies to the clipboard. #: Remember to escape | \\ // * # == etc. eg {{{|
}}}
#: Use **{{{|}}}** to make bold; [[..?|link]] use for spaces.
#: To escape text; use {{{ for .txt files or #{{{ for .awk files
#: or ::{{{ for .cmd files or ;{{{ for .ini files.
#: (end with the corresponding ..}}})
#: %gawk% --lint -f C:\#\awk\lib\text.2.wiki.awk -v _prefix="@rem |<!--"
#: -v _clip=1 -v _debug=1 -- C:\#\awk\#awk_wiki\test.text.2.wiki.awk.txt
#: test.text.2.wiki.awk.txt == http://awkpaste.blisted.org/cgi/paste.cgi?id=2874&view=text
#: insert a -v _clip=1 to copy results to the clipboard
## _____________________________________________
BEGIN {
$1 = _in_escape = t = ""; _esc1 = "{\173{"; _esc2 = "}\175}";
_splat2 = "**"; _bs2 = "\\\\";
_prefix = _prefix "|#|::|;||";
n = split(_prefix, B, "|");
if(_debug) for(i in B) { print(_qt_(++j, "B[]", i, B[i])); fflush(); }
for(i in B) {
A[(B[i] _esc1)] = _esc1;
A[(B[i] _esc2)] = _esc2;
}
if(_debug) for(i in A) { print(_qt_(++k, "A[]", i, A[i])); fflush(); }
}
{
for(i in A) if(tolower($1) == i) {
if((! _in_escape) && (A[i] == _esc1)) {
_in_escape = 1;
$1 = "";
#: t = t ? (t "\n" A[i] "\n") : (A[i] "\n");
if(_debug) { print(_qt_("_in_escape:", _in_escape, t, "end")); fflush(); }
if($0 == "") next;
} else if(_in_escape && (A[i] == _esc2)) {
_in_escape = "";
$1 = "";
#: t = t ? (t "\n" A[i] "\n") : (A[i] "\n");
if(_debug) { print(_qt_("_in_escape:", _in_escape, t, "end")); fflush(); }
if($0 == "") next;
}
}
if(_in_escape) {
s = _esc1 " " $0 " " _esc2 " " _bs2;
t = t ? (t "\n" s) : s;
next;
}
if($0 ~ /\\\\$/) {
s = $0;
} else if($0 ~ /`$/) {
s = substr($0, 1, length($0) - 1);
} else s = $0 "\\\\";
gsub("\&", "\\&", s);
gsub("\t", " ", s);
while(gsub(" ", " \\ ", s)) ;
#: & Special in gsub, use "\\&"
while(gsub("\ \ ", \
"\\ \\ \\ ", s)) ;
gsub("\\\ ", " ", s);
gsub("{{{\\\\}}}", "\\", s);
if($1 ~ "^\043") sub("\043", "\\#", s); #: the #
if(s ~ /\\\\$/) {
s = substr(s, 1, length(s) - 2);
gsub("\\\\", "\\\", s);
s = s "\134\134"; #: the back slash
} else gsub("\\\\", "\\\", s);
i = index(s, "[["); j = index(s, "\|"); k = index(s, "]]");
if( 0 < i && i < j && j < k) s = substr(s, 1, j - 1) "\377" substr(s, j + 1);
gsub("\\\052\\\052", "\\*\\*", s); #: **
gsub("\\\173\\\173\\\173", "\\{\\{\\{", s); #: {{{
gsub("\\\175\\\175\\\175", "\\}\\}\\}", s); #: }}}
gsub("\\\377", "\|", s);
t = t ? (t "\n" s) : s;
}
END {
print(t);
if(_clip) _put2clip(t);
}
function _put2clip(s, c) {
c = (c ? c : (_u ? _u : "%u%")) "\\gclip.exe";
printf("%s", s) | c;
return(close(c));
}
function _qt_(s, t, u, v, ss) {
ss = "1: `" s; ss = ss "`\t2: `" t;
ss = ss "`\t3: `" u; ss = ss "`\t4: `" v;
return((ss "`"));
}
## _____________________________________________
#: Comments: 2012-09-09 15:46:51
#: paradigm: A, B.. arrays; s..v strings; i..n integers; w..z reals #: regular expression metacharacters: \ ^ $ . [ ] | ( ) * + ? escape with \
#: filenames may Not contain: \ / : * ? " < > |
#: cmd.exe special: & " ^ % < > | = ( ) @
#: start ["title"] [/min|/max] [/low|/high] [/wait] [/b] cmd
#: start /wait exefile & call echo.^%ERRORLEVEL^%
#: %u%nircmd.exe exec show|hide|min|max exefile opts
#: shexec open|print filename
#: \a \007 sp\040 !\041 "\042 #\043 $\044 %\045 &\046
#: '\047 *\052 +\053 -\055 .\056 /\057 <\074 =\075 >\076
#: ?\077 @\100 \\134 ^\136 `\140 |\174 ~\176 ' '\240
## _____________________________________________
#: EOF