diff --git a/Doxyfile b/Doxyfile index d12875a58..cf025f1b1 100644 --- a/Doxyfile +++ b/Doxyfile @@ -274,6 +274,8 @@ ALIASES += "span{2}=\2" ALIASES += "spcl{2}=\2" ALIASES += "bksl{1}=\\\1" +ALIASES += "pcnt{1}=\%\1" +ALIASES += "atat{1}=\@" # This tag can be used to specify a number of word-keyword mappings (TCL only). # A mapping has the form "name=value". For example adding "class=itcl::class" diff --git a/Doxyfile.help b/Doxyfile.help index 979074144..ec4a97c44 100644 --- a/Doxyfile.help +++ b/Doxyfile.help @@ -274,6 +274,8 @@ ALIASES += "span{2}=\2" ALIASES += "spcl{2}=\2" ALIASES += "bksl{1}=\\\1" +ALIASES += "pcnt{1}=\%\1" +ALIASES += "atat{1}=\@" # This tag can be used to specify a number of word-keyword mappings (TCL only). # A mapping has the form "name=value". For example adding "class=itcl::class" diff --git a/Doxyfile.user b/Doxyfile.user index 96c3bc228..ea2752465 100644 --- a/Doxyfile.user +++ b/Doxyfile.user @@ -274,6 +274,8 @@ ALIASES += "span{2}=\2" ALIASES += "spcl{2}=\2" ALIASES += "bksl{1}=\\1" +ALIASES += "pcnt{1}=%\1" +ALIASES += "atat{1}=@" # This tag can be used to specify a number of word-keyword mappings (TCL only). # A mapping has the form "name=value". For example adding "class=itcl::class" diff --git a/Makefile.in b/Makefile.in index 98b8a11ca..ede69b0fd 100644 --- a/Makefile.in +++ b/Makefile.in @@ -103,7 +103,7 @@ FISH_OBJS := obj/function.o obj/builtin.o obj/complete.o obj/env.o obj/exec.o \ obj/parse_productions.o obj/parse_execution.o obj/pager.o obj/utf8.o \ obj/fish_version.o obj/wcstringutil.o -FISH_INDENT_OBJS := obj/fish_indent.o obj/print_help.o $(FISH_OBJS) +FISH_INDENT_OBJS := obj/fish_indent.o obj/print_help.o $(FISH_OBJS) # # Additional files used by builtin.o @@ -276,9 +276,9 @@ doc: $(HDR_FILES_SRC) Doxyfile.user $(HTML_SRC) $(HELP_SRC) doc.h \ (cat Doxyfile.user; echo INPUT_FILTER=./lexicon_filter; \ echo PROJECT_NUMBER=$(FISH_BUILD_VERSION) | $(SED) "s/-.*//") | \ doxygen - && touch user_doc; \ - cd user_doc/html && rm -f bc_s.png bdwn.png closed.png ftv2*.png \ - nav*.png open.png sync_*.png tab*.* doxygen.* dynsections.js \ - jquery.js pages.html + cd user_doc/html && rm -f arrow*.png bc_s.png bdwn.png closed.png \ + doc.png folder*.png ftv2*.png nav*.png open.png splitbar.png \ + sync_*.png tab*.* doxygen.* dynsections.js jquery.js pages.html # # PDF version of the source code documentation. diff --git a/doc_src/FORMATTING.md b/doc_src/FORMATTING.md index 0ae1c81e1..df6de6f8d 100644 --- a/doc_src/FORMATTING.md +++ b/doc_src/FORMATTING.md @@ -160,6 +160,8 @@ The following can be used in \\fish blocks to render some fish scenarios. These - ``: \This would be shown as an error.\ - ``: \This test will not be parsed for fish markup.\ - ``: \This would be rendered as command/script output.\ +- ``: Render the contents with a preceding backslash. Useful when presenting output. +- `{{` and `}}`: Required when wanting curly braces in regular expression example. ### Prompts and cursors diff --git a/doc_src/fish_right_prompt.txt b/doc_src/fish_right_prompt.txt index 21b4a1954..87de31139 100644 --- a/doc_src/fish_right_prompt.txt +++ b/doc_src/fish_right_prompt.txt @@ -20,7 +20,7 @@ A simple right prompt: \fish function fish_right_prompt -d "Write out the right prompt" - date "+%m/%d/%y" + date '+%m/%d/%y' end \endfish diff --git a/doc_src/index.hdr.in b/doc_src/index.hdr.in index 15c67c379..a42fb6498 100644 --- a/doc_src/index.hdr.in +++ b/doc_src/index.hdr.in @@ -528,22 +528,24 @@ The above code demonstrates how to use multiple '`$`' symbols to expand the valu Lists adjacent to other lists or strings are expanded as cartesian products: Examples: -\fish -echo {good,bad}" apples" -# Outputs 'good apples bad apples' +\fish{cli-dark} +>_ echo {good,bad}" apples" +good apples bad apples -set -l a x y z -set -l b 1 2 3 -echo $a$b -# Outputs 'x1 y1 z1 x2 y2 z2 x3 y3 z3' -echo $a"-"$b -# Outputs 'x-1 y-1 z-1 x-2 y-2 z-2 x-3 y-3 z-3' +>_ set -l a x y z +>_ set -l b 1 2 3 -echo {x,y,z}$b -# Outputs 'x1 y1 z1 x2 y2 z2 x3 y3 z3' +>_ echo $a$b +x1 y1 z1 x2 y2 z2 x3 y3 z3 -echo {$b}word -# Outputs '1word 2word 3word' +>_ echo $a"-"$b +x-1 y-1 z-1 x-2 y-2 z-2 x-3 y-3 z-3 + +>_ echo {x,y,z}$b +x1 y1 z1 x2 y2 z2 x3 y3 z3 + +>_ echo {$b}word +1word 2word 3word \endfish Be careful when you try to use braces to separate variable names from text. The dangers noted in the last example above can be avoided by wrapping the variable in double quotes instead of braces (`echo "$b"word`). diff --git a/doc_src/printf.txt b/doc_src/printf.txt index ce7796c85..5e22db986 100644 --- a/doc_src/printf.txt +++ b/doc_src/printf.txt @@ -60,7 +60,7 @@ This file has been imported from the printf in GNU Coreutils version 6.9. If you \subsection printf-example Example \fish -printf '\%s\\t\%s\n' flounder fish +printf '%s\\t%s\\n' flounder fish \endfish Will print "flounder fish" (separated with a tab character), followed by a newline character. This is useful for writing completions, as fish expects completion scripts to output the option followed by the description, separated with a tab character. diff --git a/doc_src/prompt_pwd.txt b/doc_src/prompt_pwd.txt index 7161d8aa9..0eafbf994 100644 --- a/doc_src/prompt_pwd.txt +++ b/doc_src/prompt_pwd.txt @@ -13,16 +13,19 @@ To change the number of characters per path component, set $fish_prompt_pwd_dir_ \subsection prompt_pwd-example Examples -\fish +\fish{cli-dark} >_ cd ~/ >_ echo $PWD -/home/alfa +/home/alfa + >_ prompt_pwd -~ +~ + >_ cd /tmp/banana/sausage/with/mustard >_ prompt_pwd -/t/b/s/w/mustard +/t/b/s/w/mustard + >_ set -g fish_prompt_pwd_dir_length 3 >_ prompt_pwd -/tmp/ban/sau/wit/mustard +/tmp/ban/sau/wit/mustard \endfish diff --git a/doc_src/string.txt b/doc_src/string.txt index 37d244353..fd77da945 100644 --- a/doc_src/string.txt +++ b/doc_src/string.txt @@ -3,18 +3,13 @@ \subsection string-synopsis Synopsis \fish{synopsis} string length [(-q | --quiet)] [STRING...] -string sub [(-s | --start) START] [(-l | --length) LENGTH] - [(-q | --quiet)] [STRING...] -string split [(-m | --max) MAX] [(-r | --right)] [(-q | --quiet)] - SEP [STRING...] +string sub [(-s | --start) START] [(-l | --length) LENGTH] [(-q | --quiet)] [STRING...] +string split [(-m | --max) MAX] [(-r | --right)] [(-q | --quiet)] SEP [STRING...] string join [(-q | --quiet)] SEP [STRING...] -string trim [(-l | --left)] [(-r | --right)] [(-c | --chars CHARS)] - [(-q | --quiet)] [STRING...] +string trim [(-l | --left)] [(-r | --right)] [(-c | --chars CHARS)] [(-q | --quiet)] [STRING...] string escape [(-n | --no-quoted)] [STRING...] -string match [(-a | --all)] [(-i | --ignore-case)] [(-r | --regex)] - [(-n | --index)] [(-q | --quiet)] PATTERN [STRING...] -string replace [(-a | --all)] [(-i | --ignore-case)] [(-r | --regex)] - [(-q | --quiet)] PATTERN REPLACEMENT [STRING...] +string match [(-a | --all)] [(-i | --ignore-case)] [(-r | --regex)] [(-n | --index)] [(-q | --quiet)] PATTERN [STRING...] +string replace [(-a | --all)] [(-i | --ignore-case)] [(-r | --regex)] [(-q | --quiet)] PATTERN REPLACEMENT [STRING...] \endfish @@ -51,150 +46,129 @@ The following subcommands are available: \subsection string-example Examples -\fish -string length 'hello, world' -# Output: -# 12 +\fish{cli-dark} +>_ string length 'hello, world' +12 -string length -q $str +>_ set str foo +>_ string length -q $str; echo $status +1 # Equivalent to test -n $str \endfish -\fish -string sub --length 2 abcde -# Output: -# ab +\fish{cli-dark} +>_ string sub --length 2 abcde +ab -string sub -s 2 -l 2 abcde -# Output: -# bc +>_ string sub -s 2 -l 2 abcde +bc -string sub --start=-2 abcde -# Output: -# de +>_ string sub --start=-2 abcde +de \endfish -\fish -string split . example.com -# Output: -# example -# com +\fish{cli-dark} +>_ string split . example.com +example +com -string split -r -m1 / /usr/local/bin/fish -# Output: -# /usr/local/bin -# fish +>_ string split -r -m1 / /usr/local/bin/fish +/usr/local/bin +fish -string split '' abc -# Output: -# a -# b -# c +>_ string split '' abc +a +b +c \endfish -\fish -seq 3 | string join ... -# Output: -# 1...2...3 +\fish{cli-dark} +>_ seq 3 | string join ... +1...2...3 \endfish -\fish -string trim ' abc ' -# Output: -# abc +\fish{cli-dark} +>_ string trim ' abc ' +abc -string trim --right --chars=yz xyzzy zany -# Output: -# x -# zan +>_ string trim --right --chars=yz xyzzy zany +x +zan \endfish -\fish -echo \x07 | string escape -# Output: -# \\cg +\fish{cli-dark} +>_ echo \\x07 | string escape +cg \endfish -\fish -# string match glob examples +\subsection string-example-match-glob Match Glob Examples -string match '?' a -# Output: -# a +\fish{cli-dark} +>_ string match '?' a +a -string match 'a*b' axxb -# Output: -# axxb +>_ string match 'a*b' axxb +axxb -string match -i 'a??B' Axxb -# Output: -# Axxb +>_ string match -i 'a??B' Axxb +Axxb -echo 'ok?' | string match '*\\?' -# Output: -# ok? - -# string match regex examples - -string match -r 'cat|dog|fish' 'nice dog' -# Output: -# dog - -string match -r '(\\d\\d?):(\\d\\d):(\\d\\d)' 2:34:56 -# Output: -# 2:34:56 -# 2 -# 34 -# 56 - -string match -r '^(\\w{2,4})\\g1$' papa mud murmur -# Output: -# papa -# pa -# murmur -# mur - -string match -r -a -n at ratatat -# Output: -# 2 2 -# 4 2 -# 6 2 - -string match -r -i '0x[0-9a-f]{1,8}' 'int magic = 0xBadC0de;' -# Output: -# 0xBadC0de +>_ echo 'ok?' | string match '*\\?' +>_ ok? \endfish -\fish +\subsection string-example-match-regex Match Regex Examples -# string replace literal examples +\fish{cli-dark} +>_ string match -r 'cat|dog|fish' 'nice dog' +dog -string replace is was 'blue is my favorite' -# Output: -# blue was my favorite +>_ string match -r '(\\d\\d?):(\\d\\d):(\\d\\d)' 2:34:56 +2:34:56 +2 +34 +56 -string replace 3rd last 1st 2nd 3rd -# Output: -# 1st -# 2nd -# last +>_ string match -r '^(\\w{{2,4}})\\g1$' papa mud murmur +papa +pa +murmur +mur -string replace -a ' ' _ 'spaces to underscores' -# Output: -# spaces_to_underscores +>_ string match -r -a -n at ratatat +2 2 +4 2 +6 2 -# string replace regex examples - -string replace -r -a '[^\\d.]+' ' ' '0 one two 3.14 four 5x' -# Output: -# 0 3.14 5 - -string replace -r '(\\w+)\\s+(\\w+)' '$2 $1 $$' 'left right' -# Output: -# right left $ - -string replace -r '\\s*newline\\s*' '\n' 'put a newline here' -# Output: -# put a -# here +>_ string match -r -i '0x[0-9a-f]{{1,8}}' 'int magic = 0xBadC0de;' +0xBadC0de +\endfish + +\subsection string-example-replace-literal Replace Literal Examples + +\fish{cli-dark} +>_ string replace is was 'blue is my favorite' +blue was my favorite + +>_ string replace 3rd last 1st 2nd 3rd +1st +2nd +last + +>_ string replace -a ' ' _ 'spaces to underscores' +spaces_to_underscores +\endfish + +\subsection string-example-replace-Regex Replace Regex Examples + +\fish{cli-dark} +>_ string replace -r -a '[^\\d.]+' ' ' '0 one two 3.14 four 5x' +0 3.14 5 + +>_ string replace -r '(\\w+)\\s+(\\w+)' '$2 $1 $$' 'left right' +right left $ + +>_ string replace -r '\\s*newline\\s*' '\\n' 'put a newline here' +put a +here \endfish diff --git a/doc_src/type.txt b/doc_src/type.txt index 2f55d72ab..2da88c94d 100644 --- a/doc_src/type.txt +++ b/doc_src/type.txt @@ -26,7 +26,7 @@ The following options are available: \subsection type-example Example -\fish -type fg -# Outputs the string 'fg is a shell builtin'. +\fish{cli-dark} +>_ type fg +fg is a builtin \endfish diff --git a/doc_src/user_doc.css b/doc_src/user_doc.css index ba1362e22..2ac484ca0 100644 --- a/doc_src/user_doc.css +++ b/doc_src/user_doc.css @@ -174,8 +174,8 @@ tt, code, pre, .fish { .comment, .suggest { color: #555; } .command, .function, .binary { color: #223aa4; } .argument, .path, .file { color: #5961cf; } -.string { color: #6c6d08; } .operator, .variable, .match, .history { color: #1c8885; } +.string, .string .operator { color: #858904; } /* Synopsis variant */ .synopsis { diff --git a/lexicon_filter.in b/lexicon_filter.in index 7583cc4ac..e9555e8f2 100644 --- a/lexicon_filter.in +++ b/lexicon_filter.in @@ -46,7 +46,12 @@ # Then if it's inline. Remove and process immediately... /^\\fish.*$/ { # Catch @ symbol - s/@/(at)/ + s/@/@at/g + # Catch & symbol + s/&\([^a-z]\)/@amp\1/g + # Catch {{ & }} symbols + s/{{/@curlyL/g + s/}}/@curlyR/g s/^\\fish// s/\\endfish// b html @@ -56,7 +61,12 @@ # Inside \fish block. Process... /\\endfish/!{ # Catch @ symbol - s/@/((d))/ + s/@/@at/g + # Catch & symbol + s/&\([^a-z]\)/@amp\1/g + # Catch {{ & }} symbols + s/{{/@curlyL/g + s/}}/@curlyR/g # Preprocess HTML and HTML-like formatting /<[^>]*>/ { b html @@ -103,6 +113,9 @@ s||}| s||@undr{| s|]*>|@undr{| s||}| +# Backslash (when escaping output) +s||@bksl{| +s||}| t html #. # Some handy non-standard extensions @@ -224,11 +237,11 @@ s/ \\$/ @bksl{ }/ #. # Normal Directory s|mkdir |mkdir :| -s|\([~/:][/]*[.A-Za-z_0-9/-]*\)\\ |\1=|g -s| \([~/][/]*[.A-Za-z_0-9/=-]*\)| \\\ +s|\([~/:][/]*[.A-Za-z_0-9*/-]*\)\\ |\1=|g +s| \([~/][/]*[.A-Za-z_0-9*/=-]*\)| \\\ <@path{\1}\ |g -s| \(:[/]*[.A-Za-z_0-9/=-]*\)| \\\ +s| \(:[/]*[.A-Za-z_0-9*/=-]*\)| \\\ <@path{\1}\ |g t protect @@ -255,6 +268,7 @@ s|^\([a-zA-Z][{},a-zA-Z0-9%*._/?!-]*\)|@args{\1}|g # Pick up loose text after markup. s/\([})]\)\([a-zA-Z0-9+%*.,][,a-zA-Z0-9%*._/?!-]*\);/\1@args{\2};/g s/\([})]\)\([a-zA-Z0-9+%*.,][,a-zA-Z0-9%*._/?!-]*\)$/\1@args{\2}/g +s/\([})]\)\([a-zA-Z0-9+%*.,][,a-zA-Z0-9%*._/?!-]*\)@EOL/\1@args{\2}/g #. # Uncomment the following 2 lines (ss) to log the pattern buffer. s/^.*$/Pattern : &/w lexicon.log @@ -279,6 +293,8 @@ s,\([^\\ ]*\)\\\n\([^<]*\)<\(@[^}]*[}\\]\),\1\3\2, t join # Clean up stray new lines s/\n//g +# Clean up past @EOL +s/@EOL.*$//g #. # Uncomment the folowing two lines (ss) to log the buffer before 'cleaning'. s/^.*$/PreClean: &/w lexicon.log @@ -475,16 +491,17 @@ x #. # Mark up sesitive character entities. #. -# We comment out this target because it isn't referenced and if we don't we -# get warnings about "unused label 'entities'". -#:entities s//\>/g -s/((d))/@/g +s/@amp/\&/g +s/@curlyL/\{/g +s/@curlyR/\}/g +s/@at/@atat{ }/g #. # Final post processing s/};\([^]]\)/}@redr{;}\1/g s/};$/}@redr{;}/ +s/@sglq{}/''/ s/ \[\([@(]\)/ @args{[}\1/g s/ \[\([A-Z]*\) / @args{[\1} /g s/@args{\([a-zA-Z0-9_.]*\)}\]/@args{\1]}/g @@ -496,7 +513,9 @@ s/ \]$/ @args{]}/g s/\]}\]$/]]}/ s/\\\([()]\)/@optr{@bksl{\1}}/g s/\([()]\)/@optr{\1}/g +s/\\\\\([cdgnstwx?]\)/@bksl{\1}/g s/\\n/@bksl{n}/ +s/%\([diouxXfgGeEsbmy]\)/@pcnt{\1}/g s/ \\$// #. # Uncomment the folowing two lines (ss) to log the final output, sent to Doxygen. @@ -516,6 +535,8 @@ b #. # Move protected content to hold space and mark up other entities. :protect +# Add an 'End of Line' marker +s/$/@EOL/ s/^.*$/Input : &/w lexicon.log s/^Input : // h @@ -536,6 +557,7 @@ x s/[^\<]*// s/^ *\\\n//g s/\n *\\//g + s/\n@EOL//g s/[()] \\//g s/^[^\<][^@][^\\]*// s/\n[]|;) ][^\\]*\\// @@ -559,11 +581,13 @@ s/^[a-z][a-z]* \n// # Swap the buffers back. x #. -# A special case. Tidy up after commands. +# A special case. Tidy up after performing command substitution. # Redirectors s/\([^{|] *\)|/\1@redr{|}/g -s/&$/@redr{\&}/ -s/\([^{&] *\)&[^a-z]/\1@redr{\&}/g +s/\&@EOL$/@redr{@amp}@EOL/g +s/@amp@EOL$/@redr{@amp}@EOL/g +s/\([<>]\)@amp\([0-9]\)/@redr{\1@amp\2}/g +s/\([^{&] *\)&[^@a-z]/\1@redr{\&}/g s/\([^{<>^] *\)\([0-9]* *[<>^][<>^]*[^@][a-zA-Z0-9./_-]*\)/\1@redr{\2}/g s/\\}/}\\/g #. @@ -575,11 +599,9 @@ s/[[][0-9$a-zA-Z_;. -]*]/@args{&}/g s/\($[$]*\)\([A-Za-z_0-9][A-Za-z_0-9]*\)/@vars{@optr{\1}\2}/g #. # Files -s/\([^@]\)\([A-Za-z0-9_-][A-Za-z0-9_-]*\.[a-z0-9*][a-z0-9*]*\)/\1@fsfo{\2}/g -#. -# We comment out this target because it isn't referenced and if we don't we -# get warnings about "unused label 'commands'". -#:commands +/@at/ ! { + s/\([A-Za-z0-9_*-][A-Za-z0-9_*-]*\.[a-z0-9*][a-z0-9*]*\)/@fsfo{\1}/g +} #. #### This section is built in the Makefile. Just some formatting examples. ##### #.