tsunami
log in
email
password
links
newest items
tag list
syntax reference
tag:tsunami
history
skepticism and atheism
Mono.GetOptions
C# 3.0: Anonymous Cheating
C# Code Standards
Christianity: NT says read OT
Luke's recommended book list
tsunami technology
Predicate
Firefox quicksearches
item name
tags
==introduction There is no built-in functionality to make writing [[tsunami syntax]] easier. It is easier to write "powershell functions"[1] for now, so that's what I'm doing. At some point, javascript versions with nice UIs will be required. [2]http://luke.breuer.com/time/tag/powershell-function.aspx ==functions {{ # renumber (or add numbers to) all "hyperlinks"[2] and "references"[] within a section # # [] A # [2] B # # in the example above, hyperlinks would now be linked to A, and references to B # # NOTE: does not support referencing the same hyperlink multiple times, and will # re-number out-of-orderness as exists a bit, which might break things! function Quote-Tsunami { # pull input from stdin if it's there, otherwise use the clipboard $s = Join-String $input -Newline if ($s) { $clip = $false; } else { $clip = $true; $s = Get-Clipboard; } # parameterize Foreach-Object (%) $lambda = { $i = 1; $s = "" }, { $s += "$_$i"; $i++; }, { $s = $s.SubString(0, $s.Length - "$i".Length); $s; } # remove existing numbering $s = $s -replace '(?<="\[)[^\]]+', '' $s = $s -replace '(?m)(?<=^\[)[^\]]+', '' # add new numbering $s = [Regex]::Split($s, '(?<="\[)(?=\])') | % $lambda[0] $lambda[1] $lambda[2] $s = [Regex]::Split($s, "(?m)(?<=^\[)(?=\])") | % $lambda[0] $lambda[1] $lambda[2] # dump to clipboard if we pulled from there, otherwise dump to stdout if ($clip) { $s | Write-Clipboard } else { $s } } }}
some permissive license goes here
contact