File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ < pre id =result > working</ pre >
2+ < script type =module >
3+
4+ // curl -s http://ward.dojo.fed.wiki/patterns-on-wiki-1996.json | jq -r '.story[]|select(.type=="graphviz")|.text' | perl -e '$_ = join("", <STDIN>);s/label="[^"]*?\n.*?"/($& =~ s/\\n/\\\n/)/g; print;'
5+
6+ const page = await fetch ( 'http://ward.dojo.fed.wiki/patterns-on-wiki-1996.json' ) . then ( res => res . json ( ) )
7+ const item = page . story . find ( item => item . type == 'graphviz' )
8+ const text = item . text
9+ let openquote = false
10+
11+ window . result . innerText = text . split ( / \n / ) . reduce ( fixer , '' )
12+
13+ function fixer ( sum , each ) {
14+ if ( openquote ) {
15+ if ( each . match ( / " / ) ) openquote = false
16+ return sum + "\\n" + each
17+ } else if ( each . match ( / \[ l a b e l = " [ ^ " ] * $ / ) ) {
18+ openquote = true
19+ return sum + "\n" + each
20+ } else {
21+ return sum + "\n" + each
22+ }
23+ }
24+
25+ </ script >
You can’t perform that action at this time.
0 commit comments