Lexicon filter: fix 'if' and 'for' special cases

This commit is contained in:
Mark Griffiths 2014-08-03 02:22:23 +01:00
parent 8ca88f14f7
commit 7e3382340e
3 changed files with 54 additions and 17 deletions

View File

@ -257,10 +257,10 @@ ALIASES += "strg{1}=<span class=\"string\">\1</span>"
ALIASES += "sglq{1}=<span class=\"string\">'\1'</span>" ALIASES += "sglq{1}=<span class=\"string\">'\1'</span>"
ALIASES += "dblq{1}=<span class=\"string\">\"\1\"</span>" ALIASES += "dblq{1}=<span class=\"string\">\"\1\"</span>"
ALIASES += "prmt{1}=<span class=\"prompt\">\1 </span>" ALIASES += "prmt{1}=<span class=\"prompt\"\1</span>"
ALIASES += "sgst{1}=<span class=\"suggest\">\1</span>" ALIASES += "sgst{1}=<span class=\"suggest\"\1</span>"
ALIASES += "eror{1}=<span class=\"error\">\1</span>" ALIASES += "eror{1}=<span class=\"error\"\1</span>"
ALIASES += "curs{1}=<span class=\"cursor\">\1</span>" ALIASES += "curs{1}=<span class=\"cursor\"\1</span>"
ALIASES += "bold{1}=<strong>\1</strong>" ALIASES += "bold{1}=<strong>\1</strong>"
ALIASES += "emph{1}=<em>\1</em>" ALIASES += "emph{1}=<em>\1</em>"

View File

@ -32,7 +32,7 @@
#. #.
# It's most easily tested by passing test strings into the compiled script: # It's most easily tested by passing test strings into the compiled script:
#. #.
# echo "Line to test" | ./fish_lexicon_filter # echo "/fish Line to test" | ./fish_lexicon_filter
#. #.
# The, at times, archiac looking regex is down to ensuring portable sed BREs # The, at times, archiac looking regex is down to ensuring portable sed BREs
#. #.
@ -137,7 +137,7 @@ t html
#. #.
# Comments: # Comments:
# Capture full line comments # Capture full line comments
/^[ ]*#.*$/ { /^ *#.*$/ {
# Assume any line starting with a # is complete # Assume any line starting with a # is complete
s//@blah{&}/ s//@blah{&}/
t t
@ -237,13 +237,34 @@ s/\n//g
# Find the initial command, and change any others to arguments, up to a |, ( or ; # Find the initial command, and change any others to arguments, up to a |, ( or ;
# Assumes that a valid line will start with either a builtin, a function or a binary. # Assumes that a valid line will start with either a builtin, a function or a binary.
#. #.
s/^\([ ]*\)@cmnd\(.*\)/\1@xcmd\ # 'if' and 'for' seem to be special cases
/@cmnd{if}/ {
s//@xcmd\
{if}/
s/@cmnd{else}/@xcmd\
{else}/
s/@cmnd{not}/@xcmd\
{not}/
s/$}@cmnd{status}/$}status/
b nextcmnd
}
/@cmnd{for}/ {
s/@cmnd{for}/@xcmd\
{for}/
s/[[:<:]]in[[:>:]]/@args{in}/
b castargs
}
#.
# Find initial command
#.
s/^\( *\)@cmnd\(.*\)/\1@xcmd\
\2/ \2/
t castargs t castargs
s/^\([ ]*\)@func\(.*\)/\1@xfnc\ s/^\( *\)@func\(.*\)/\1@xfnc\
\2/ \2/
t castargs t castargs
s/^\([ ]*\)@sbin\(.*\)/\1@xbin\ s/^\( *\)@sbin\(.*\)/\1@xbin\
\2/ \2/
t castargs t castargs
:nextcmnd :nextcmnd
@ -270,22 +291,37 @@ t castargs
s/\n\([^@]*\)@sbin\(.*\)/\1@args\ s/\n\([^@]*\)@sbin\(.*\)/\1@args\
\2/ \2/
t castargs t castargs
s/\n\([^@]*\)@\(....\)\(.*\)/\1@\2\
\3/
t castargs
:cleancmd :cleancmd
s/xcmd/cmnd/g s/xcmd/cmnd/g
s/xfnc/func/g s/xfnc/func/g
s/xbin/sbin/g s/xbin/sbin/g
s/\n//g s/\n//g
# Character Entities
#. #.
# Mark up a few sesitive characters. # Remove any args after echo
#.
/@cmnd{echo}/ {
s//\
&\
/
:cleanecho
s/\n\([^@]*\)@args{\([^}]*\)}/\1\2/
t cleanecho
s/\n//g
w debug-lexicon.log
}
#.
# Mark up sesitive character entities.
#. #.
:entities :entities
s/</\&lt;/g s/</\&lt;/g
s/>/\&gt;/g s/>/\&gt;/g
#. #.
# Uncomment the folowing two lines (ss) to log the final output, sent to Doxygen. # Uncomment the folowing two lines (ss) to log the final output, sent to Doxygen.
s/^.*$/OUT : &/w debug-lexicon.log # s/^.*$/OUT : &/w debug-lexicon.log
s/^OUT : // # s/^OUT : //
#. #.
# Lines are reassembled, so branch to end # Lines are reassembled, so branch to end
b b
@ -306,8 +342,8 @@ s/\n$//
# characters. Basically the inverse of the 'patternflush' action, with # characters. Basically the inverse of the 'patternflush' action, with
# additional trailing characters stripped. # additional trailing characters stripped.
x x
s/^[ ]*[^<][^@][^}]*$// s/^ *[^<][^@][^}]*$//
s/^[ ]*[^<][^@][^\\]*[\\ ()]*\n// s/^ *[^<][^@][^\\]*[\\ ()]*\n//
:holdflush :holdflush
s/}[)(\\ ][)(\\ ]*/}/ s/}[)(\\ ][)(\\ ]*/}/
s/\n[];)|* -][^\\]*[\\]*// s/\n[];)|* -][^\\]*[\\]*//
@ -335,7 +371,6 @@ s/\([A-Za-z*][A-Za-z]*\.[a-z0-9][a-z0-9]*\)/@fsfo{\1}/g
#. #.
# Manually add a few commands not harvested from source files. # Manually add a few commands not harvested from source files.
#. #.
s,[[:<:]]in[[:>:]],@args{in},g
s,[[:<:]]whoami[[:>:]],@sbin{whoami},g s,[[:<:]]whoami[[:>:]],@sbin{whoami},g
s,[[:<:]]fishd[[:>:]],@sbin{fishd},g s,[[:<:]]fishd[[:>:]],@sbin{fishd},g
#. #.

View File

@ -197,9 +197,11 @@ h1 > code, h2 > code, h3 > code {
.underline { text-decoration: underline; }*/ .underline { text-decoration: underline; }*/
.synopsis { .synopsis {
background-color: #fafafa;
border: none; border: none;
color: #333; color: #333;
background-color: #fafafa;
/*color: #00afff;*/
/*background-color: #111;*/
} }
/* Console variants */ /* Console variants */
.cli-dark { .cli-dark {