Repository: dongweiming/sed_and_awk Branch: master Commit: b897455361b7 Files: 66 Total size: 169.5 KB Directory structure: gitextract_1q6_hbc5/ ├── .gitignore ├── LICENSE ├── README.md ├── code/ │ ├── answer_awk.txt │ ├── answer_sed.txt │ ├── arguments.awk │ ├── array-for-loop.awk │ ├── asort.awk │ ├── asorti.awk │ ├── bits.awk │ ├── dowhile.awk │ ├── environ.awk │ ├── files.txt │ ├── for.awk │ ├── function-debug.awk │ ├── items-sold.txt │ ├── items.txt │ ├── label.sed │ ├── numbers.txt │ ├── path.txt │ ├── printf-width.awk │ ├── question_awk.txt │ ├── question_awk3.txt │ ├── question_awk4.txt │ ├── question_awk5_1.txt │ ├── question_awk5_2.txt │ ├── question_awk6_1.txt │ ├── question_awk6_2.txt │ ├── question_awk7.txt │ ├── sed_example_1.sed │ ├── source-multiple-fs.txt │ ├── source-one-line.txt │ ├── source-star.txt │ ├── source.txt │ ├── source2.txt │ ├── srand.awk │ ├── string.awk │ ├── testscript.sed │ ├── total-star.awk │ └── while.awk ├── css/ │ ├── print/ │ │ ├── paper.css │ │ └── pdf.css │ ├── reveal.css │ ├── shaders/ │ │ ├── tile-flip.fs │ │ └── tile-flip.vs │ └── theme/ │ └── default.css ├── index.html ├── lib/ │ ├── css/ │ │ └── zenburn.css │ ├── font/ │ │ └── league_gothic_license │ └── js/ │ ├── classList.js │ └── html5shiv.js ├── plugin/ │ ├── highlight/ │ │ └── highlight.js │ ├── markdown/ │ │ ├── markdown.js │ │ └── showdown.js │ ├── notes/ │ │ ├── notes.html │ │ └── notes.js │ ├── notes-server/ │ │ ├── client.js │ │ ├── index.js │ │ └── notes.html │ ├── postmessage/ │ │ ├── example.html │ │ └── postmessage.js │ ├── print-pdf/ │ │ └── print-pdf.js │ ├── remotes/ │ │ └── remotes.js │ └── zoom-js/ │ └── zoom.js ├── requirements.txt └── run.py ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ *.py[cod] # C extensions *.so # Packages *.egg *.egg-info dist build eggs parts bin var sdist develop-eggs .installed.cfg lib64 __pycache__ # Installer logs pip-log.txt # Unit test / coverage reports .coverage .tox nosetests.xml # Translations *.mo # Mr Developer .mr.developer.cfg .project .pydevproject ================================================ FILE: LICENSE ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "{}" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright {yyyy} {name of copyright owner} Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: README.md ================================================ sed_and_awk =========== An online presentation for sed & awk. You can see [http://dongweiming.github.io/sed_and_awk](http://dongweiming.github.io/sed_and_awk) How to use -------- * For site. You can start a web app with [Flask](https://github.com/mitsuhiko/flask), You can install following this: ``` sudo pip install -r requirements.txt ``` or ``` sudo easy_install flask ``` then ``` sudo python run.py ``` * For html. If you want direct use browser open it. for example on osx. ``` open index.html ``` ================================================ FILE: code/answer_awk.txt ================================================ 1. netstat -nat |grep 27018|awk '{print $5}'|awk -F ':' '{a[$1]++} END {for (j in a) print a[j], j}' 2. awk '{a[sprintf("%s %s", substr($4,2,14),$1)]++} END{for(i in a){print "ip: " i,"count: " a[i]}}' access.log |sort -rnk 5 3. awk '/Addy/{ P=1; next } /Mattt/ {exit} P' question_awk3.txt 4. awk '!a[$1]++' question_awk4.txt 5. awk '{a[$1]=$2}NR>FNR{print $1,a[$1], a[$2]}' question_awk5_2.txt question_awk5_1.txt 6. awk 'NR == FNR{a[$0]} !($0 in a)' question_awk6_2.txt question_awk6_1.txt ================================================ FILE: code/answer_sed.txt ================================================ 1. echo "This is 123"|sed "s/[0-9]\{3\}/[&]/" 2. 打印匹配2和她后面的2行 3. 把匹配2的行改成4 4. echo "This is UPPER"|/usr/local/bin/sed "s/\(.*\) \(.*\) \(.*\)/\U\2,\E\u\1,\E\L\3/" 5. 把前面的哪行叠加到本行 6. sed -n '1!G;h;$p' ================================================ FILE: code/arguments.awk ================================================ BEGIN { print "ARGC=",ARGC for (i = 0; i < ARGC; i++) print ARGV[i] } ================================================ FILE: code/array-for-loop.awk ================================================ BEGIN { item[101]="Github"; item[21]="Google"; for (x in item) print item[x]; } ================================================ FILE: code/asort.awk ================================================ BEGIN { item[101]="Github"; item[22]="Whim"; item[50]="Google"; print "------Before asort------" for (x in item) print "Index",x,"contains",item[x]; total = asort(item); print "------After asort------" for (x in item) print "Index",x,"contains",item[x]; print "Return value from asort:", total; } ================================================ FILE: code/asorti.awk ================================================ BEGIN { item[101]="Github"; item[22]="Whim"; item[50]="Google"; print "----- Function: asort -----" total = asort(item,itemdesc); for (i=1; i<= total; i++) print "Index",i,"contains",itemdesc[i]; print "----- Function: asorti -----" total = asorti(item,itemabbr); for (i=1; i<= total; i++) print "Index",i,"contains",itemabbr[i]; } ================================================ FILE: code/bits.awk ================================================ BEGIN { number1=15 number2=25 print "AND: " and(number1,number2); print "OR: " or(number1,number2) print "XOR: " xor(number1,number2) print "LSHIFT: " lshift(number1,2) print "RSHIFT: " rshift(number1,2) } ================================================ FILE: code/dowhile.awk ================================================ { i=2; total=0; do { total = total + $i; i++; } while (i <= NF) print "Item", $1, ":", total, "quantities sold"; } ================================================ FILE: code/environ.awk ================================================ BEGIN { OFS="=" for(x in ENVIRON) print x,ENVIRON[x]; } ================================================ FILE: code/files.txt ================================================ /etc/passwd /etc/group ================================================ FILE: code/for.awk ================================================ { total=0; for (i=2; i <= NF; i++) total = total + $i; print "Item", $1, ":", total, "quantities sold"; } ================================================ FILE: code/function-debug.awk ================================================ function mydebug (message) { print ("Debug Time:" strftime("%a %b %d %H:%M:%S %Z %Y", systime())) print (message) } { mydebug($NF) } ================================================ FILE: code/items-sold.txt ================================================ 101 2 10 5 8 10 12 102 0 1 4 3 0 2 103 10 6 11 20 5 13 104 2 3 4 0 6 5 105 10 2 5 7 12 6 ================================================ FILE: code/items.txt ================================================ 101,HD Camcorder,Video,210,10 102,Refrigerator,Appliance,850,2 103,MP3 Player,Audio,270,15 104,Tennis Racket,Sports,190,20 105,Laser Printer,Office,475,5 ================================================ FILE: code/label.sed ================================================ #!/usr/local/bin/sed -nf h;n;H;x s/\n/:/ /Github/!b end s/^/*/ :end p ================================================ FILE: code/numbers.txt ================================================ 1 12 123 1234 12345 123456 ================================================ FILE: code/path.txt ================================================ reading /usr/local/bin directory ================================================ FILE: code/printf-width.awk ================================================ BEGIN { FS="," printf "%3s\t%10s\t%10s\t%5s\t%3s\n", "Num","Description","Type","Price","Qty" printf "-----------------------------------------------------\n" } { printf "%3d\t%10s\t%10s\t%g\t%d\n", $1,$2,$3,$4,$5 } ================================================ FILE: code/question_awk.txt ================================================ 1 2 3 4 5 6 7 8 9 10 11 12 1 3 5 7 2 4 6 8 ================================================ FILE: code/question_awk3.txt ================================================ Ian Bicking Hakim El Hattab Paul Irish Addy Osmani Chris Wanstrath Mattt Thompson Ask Solem Hoel ================================================ FILE: code/question_awk4.txt ================================================ 1 22 133 12 22 1 ================================================ FILE: code/question_awk5_1.txt ================================================ 101 Addy 102 Mattt 103 Ask ================================================ FILE: code/question_awk5_2.txt ================================================ Ask 1024 Mattt 2570 Addy 578 ================================================ FILE: code/question_awk6_1.txt ================================================ 123 1 11 1254 ================================================ FILE: code/question_awk6_2.txt ================================================ 123 12 1234 1 1232 ================================================ FILE: code/question_awk7.txt ================================================ 101,/etc/passwd 102,/etc/group ================================================ FILE: code/sed_example_1.sed ================================================ /^root/ p /^nobody/ p ================================================ FILE: code/source-multiple-fs.txt ================================================ 101,Ian Bicking:Mozilla% 102,Hakim El Hattab:Whim% 103,Paul Irish:Google% 104,Addy Osmani:Google% 105,Chris Wanstrath:Github% 106,Mattt Thompson:Heroku% 107,Ask Solem Hoel:VMware% ================================================ FILE: code/source-one-line.txt ================================================ 1,one:2,two:3,three:4,four ================================================ FILE: code/source-star.txt ================================================ 101,Ian Bicking,Mozilla,1204 102,Hakim El Hattab,Whim,4029 103,Paul Irish,Google,7200 104,Addy Osmani,Google,2201 105,Chris Wanstrath,Github,1002 106,Mattt Thompson,Heroku,890 107,Ask Solem Hoel,VMware,2109 ================================================ FILE: code/source.txt ================================================ 101,Ian Bicking,Mozilla 102,Hakim El Hattab,Whim 103,Paul Irish,Google 104,Addy Osmani,Google 105,Chris Wanstrath,Github 106,Mattt Thompson,Heroku 107,Ask Solem Hoel,VMware ================================================ FILE: code/source2.txt ================================================ Ian Bicking Mozilla Hakim El Hattab Whim Paul Irish Google Chris Wanstrath Github Mattt Thompson Heroku ================================================ FILE: code/srand.awk ================================================ BEGIN { srand(5); count=0; max=30; while (count < 5) { # 随机数范围为5-30 rnd = int(rand() * max); print rnd; count++; } } ================================================ FILE: code/string.awk ================================================ BEGIN { FS=","; OFS=","; string1="GO"; string2="OGLE"; numberstring="100"; string3=string1 string2; print "Concatenate string is:" string3; numberstring=numberstring+1; print "String to number:" numberstring; } ================================================ FILE: code/testscript.sed ================================================ #!/usr/bin/sed -nf /root/ p /nobody/ p ================================================ FILE: code/total-star.awk ================================================ BEGIN { FS=","; total=0; } { print $2 "'s star is: " $4; total=total+$4 } END { print "---\nTotal star = $"total; } ================================================ FILE: code/while.awk ================================================ { i=2; total=0; while (i <= NF) { total = total + $i; i++; } print "Item", $1, ":", total, "quantities sold"; } ================================================ FILE: css/print/paper.css ================================================ /* Default Print Stylesheet Template by Rob Glazebrook of CSSnewbie.com Last Updated: June 4, 2008 Feel free (nay, compelled) to edit, append, and manipulate this file as you see fit. */ /* SECTION 1: Set default width, margin, float, and background. This prevents elements from extending beyond the edge of the printed page, and prevents unnecessary background images from printing */ body { background: #fff; font-size: 13pt; width: auto; height: auto; border: 0; margin: 0 5%; padding: 0; float: none !important; overflow: visible; } html { background: #fff; width: auto; height: auto; overflow: visible; } /* SECTION 2: Remove any elements not needed in print. This would include navigation, ads, sidebars, etc. */ .nestedarrow, .controls, .reveal .progress, .reveal.overview, .fork-reveal, .share-reveal, .state-background { display: none !important; } /* SECTION 3: Set body font face, size, and color. Consider using a serif font for readability. */ body, p, td, li, div, a { font-size: 16pt!important; font-family: Georgia, "Times New Roman", Times, serif !important; color: #000; } /* SECTION 4: Set heading font face, sizes, and color. Diffrentiate your headings from your body text. Perhaps use a large sans-serif for distinction. */ h1,h2,h3,h4,h5,h6 { color: #000!important; height: auto; line-height: normal; font-family: Georgia, "Times New Roman", Times, serif !important; text-shadow: 0 0 0 #000 !important; text-align: left; letter-spacing: normal; } /* Need to reduce the size of the fonts for printing */ h1 { font-size: 26pt !important; } h2 { font-size: 22pt !important; } h3 { font-size: 20pt !important; } h4 { font-size: 20pt !important; font-variant: small-caps; } h5 { font-size: 19pt !important; } h6 { font-size: 18pt !important; font-style: italic; } /* SECTION 5: Make hyperlinks more usable. Ensure links are underlined, and consider appending the URL to the end of the link for usability. */ a:link, a:visited { color: #000 !important; font-weight: bold; text-decoration: underline; } /* .reveal a:link:after, .reveal a:visited:after { content: " (" attr(href) ") "; color: #222 !important; font-size: 90%; } */ /* SECTION 6: more reveal.js specific additions by @skypanther */ ul, ol, div, p { visibility: visible; position: static; width: auto; height: auto; display: block; overflow: visible; margin: auto; text-align: left !important; } .reveal .slides { position: static; width: auto; height: auto; left: auto; top: auto; margin-left: auto; margin-top: auto; padding: auto; overflow: visible; display: block; text-align: center; -webkit-perspective: none; -moz-perspective: none; -ms-perspective: none; perspective: none; -webkit-perspective-origin: 50% 50%; /* there isn't a none/auto value but 50-50 is the default */ -moz-perspective-origin: 50% 50%; -ms-perspective-origin: 50% 50%; perspective-origin: 50% 50%; } .reveal .slides>section, .reveal .slides>section>section { visibility: visible !important; position: static !important; width: 90% !important; height: auto !important; display: block !important; overflow: visible !important; left: 0% !important; top: 0% !important; margin-left: 0px !important; margin-top: 0px !important; padding: 20px 0px !important; opacity: 1 !important; -webkit-transform-style: flat !important; -moz-transform-style: flat !important; -ms-transform-style: flat !important; transform-style: flat !important; -webkit-transform: none !important; -moz-transform: none !important; -ms-transform: none !important; transform: none !important; } .reveal section { page-break-after: always !important; display: block !important; } .reveal section .fragment { opacity: 1 !important; visibility: visible !important; -webkit-transform: none !important; -moz-transform: none !important; -ms-transform: none !important; transform: none !important; } .reveal section:last-of-type { page-break-after: avoid !important; } .reveal section img { display: block; margin: 15px 0px; background: rgba(255,255,255,1); border: 1px solid #666; box-shadow: none; } ================================================ FILE: css/print/pdf.css ================================================ /* Default Print Stylesheet Template by Rob Glazebrook of CSSnewbie.com Last Updated: June 4, 2008 Feel free (nay, compelled) to edit, append, and manipulate this file as you see fit. */ /* SECTION 1: Set default width, margin, float, and background. This prevents elements from extending beyond the edge of the printed page, and prevents unnecessary background images from printing */ * { -webkit-print-color-adjust: exact; } body { font-size: 18pt; width: auto; height: auto; border: 0; margin: 0 5%; padding: 0; float: none !important; overflow: visible; background-image: none !important; } html { width: auto; height: auto; overflow: visible; } /* SECTION 2: Remove any elements not needed in print. This would include navigation, ads, sidebars, etc. */ .nestedarrow, .controls, .reveal .progress, .reveal.overview, .fork-reveal, .share-reveal, .state-background { display: none !important; } /* SECTION 3: Set body font face, size, and color. Consider using a serif font for readability. */ body, p, td, li, div { font-size: 18pt; } /* SECTION 4: Set heading font face, sizes, and color. Diffrentiate your headings from your body text. Perhaps use a large sans-serif for distinction. */ h1,h2,h3,h4,h5,h6 { text-shadow: 0 0 0 #000 !important; } /* SECTION 5: Make hyperlinks more usable. Ensure links are underlined, and consider appending the URL to the end of the link for usability. */ a:link, a:visited { font-weight: bold; text-decoration: underline; } /* SECTION 6: more reveal.js specific additions by @skypanther */ ul, ol, div, p { visibility: visible; position: static; width: auto; height: auto; display: block; overflow: visible; margin: auto; } .reveal .slides { position: static; width: 100%; height: auto; left: auto; top: auto; margin-left: auto; margin-right: auto; margin-top: auto; padding: auto; overflow: visible; display: block; text-align: center; -webkit-perspective: none; -moz-perspective: none; -ms-perspective: none; perspective: none; -webkit-perspective-origin: 50% 50%; /* there isn't a none/auto value but 50-50 is the default */ -moz-perspective-origin: 50% 50%; -ms-perspective-origin: 50% 50%; perspective-origin: 50% 50%; } .reveal .slides section { page-break-after: always !important; visibility: visible !important; position: static !important; width: 100% !important; height: auto !important; min-height: initial !important; display: block !important; overflow: visible !important; left: 0 !important; top: 0 !important; margin-left: 0px !important; margin-top: 50px !important; padding: 20px 0px !important; opacity: 1 !important; -webkit-transform-style: flat !important; -moz-transform-style: flat !important; -ms-transform-style: flat !important; transform-style: flat !important; -webkit-transform: none !important; -moz-transform: none !important; -ms-transform: none !important; transform: none !important; } .reveal section.stack { margin: 0px !important; padding: 0px !important; page-break-after: avoid !important; } .reveal section .fragment { opacity: 1 !important; visibility: visible !important; -webkit-transform: none !important; -moz-transform: none !important; -ms-transform: none !important; transform: none !important; } .reveal img { box-shadow: none; } .reveal .roll { overflow: visible; line-height: 1em; } .reveal small a { font-size: 16pt !important; } ================================================ FILE: css/reveal.css ================================================ @charset "UTF-8"; /*! * reveal.js * http://lab.hakim.se/reveal-js * MIT licensed * * Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se */ /********************************************* * RESET STYLES *********************************************/ html, body, .reveal div, .reveal span, .reveal applet, .reveal object, .reveal iframe, .reveal h1, .reveal h2, .reveal h3, .reveal h4, .reveal h5, .reveal h6, .reveal p, .reveal blockquote, .reveal pre, .reveal a, .reveal abbr, .reveal acronym, .reveal address, .reveal big, .reveal cite, .reveal code, .reveal del, .reveal dfn, .reveal em, .reveal img, .reveal ins, .reveal kbd, .reveal q, .reveal s, .reveal samp, .reveal small, .reveal strike, .reveal strong, .reveal sub, .reveal sup, .reveal tt, .reveal var, .reveal b, .reveal u, .reveal i, .reveal center, .reveal dl, .reveal dt, .reveal dd, .reveal ol, .reveal ul, .reveal li, .reveal fieldset, .reveal form, .reveal label, .reveal legend, .reveal table, .reveal caption, .reveal tbody, .reveal tfoot, .reveal thead, .reveal tr, .reveal th, .reveal td, .reveal article, .reveal aside, .reveal canvas, .reveal details, .reveal embed, .reveal figure, .reveal figcaption, .reveal footer, .reveal header, .reveal hgroup, .reveal menu, .reveal nav, .reveal output, .reveal ruby, .reveal section, .reveal summary, .reveal time, .reveal mark, .reveal audio, video { margin: 0; padding: 0; border: 0; font-size: 100%; font: inherit; vertical-align: baseline; } .reveal article, .reveal aside, .reveal details, .reveal figcaption, .reveal figure, .reveal footer, .reveal header, .reveal hgroup, .reveal menu, .reveal nav, .reveal section { display: block; } /********************************************* * GLOBAL STYLES *********************************************/ html, body { width: 100%; height: 100%; overflow: hidden; } body { position: relative; line-height: 1; } ::selection { background: #FF5E99; color: #fff; text-shadow: none; } @media screen and (max-width: 900px), (max-height: 600px) { .reveal .slides { font-size: 0.82em; } } @media screen and (max-width: 700px), (max-height: 400px) { .reveal .slides { font-size: 0.66em; } } /********************************************* * HEADERS *********************************************/ .reveal h1, .reveal h2, .reveal h3, .reveal h4, .reveal h5, .reveal h6 { -webkit-hyphens: auto; -moz-hyphens: auto; hyphens: auto; word-break: break-all; word-break: break-word; } .reveal h1 { font-size: 3.77em; } .reveal h2 { font-size: 2.11em; } .reveal h3 { font-size: 1.55em; } .reveal h4 { font-size: 1em; } /********************************************* * VIEW FRAGMENTS *********************************************/ .reveal .slides section .fragment { opacity: 0; -webkit-transition: all .2s ease; -moz-transition: all .2s ease; -ms-transition: all .2s ease; -o-transition: all .2s ease; transition: all .2s ease; } .reveal .slides section .fragment.visible { opacity: 1; } .reveal .slides section .fragment.grow { opacity: 1; } .reveal .slides section .fragment.grow.visible { -webkit-transform: scale( 1.3 ); -moz-transform: scale( 1.3 ); -ms-transform: scale( 1.3 ); -o-transform: scale( 1.3 ); transform: scale( 1.3 ); } .reveal .slides section .fragment.shrink { opacity: 1; } .reveal .slides section .fragment.shrink.visible { -webkit-transform: scale( 0.7 ); -moz-transform: scale( 0.7 ); -ms-transform: scale( 0.7 ); -o-transform: scale( 0.7 ); transform: scale( 0.7 ); } .reveal .slides section .fragment.roll-in { opacity: 0; -webkit-transform: rotateX( 90deg ); -moz-transform: rotateX( 90deg ); -ms-transform: rotateX( 90deg ); -o-transform: rotateX( 90deg ); transform: rotateX( 90deg ); } .reveal .slides section .fragment.roll-in.visible { opacity: 1; -webkit-transform: rotateX( 0 ); -moz-transform: rotateX( 0 ); -ms-transform: rotateX( 0 ); -o-transform: rotateX( 0 ); transform: rotateX( 0 ); } .reveal .slides section .fragment.fade-out { opacity: 1; } .reveal .slides section .fragment.fade-out.visible { opacity: 0; } .reveal .slides section .fragment.highlight-red, .reveal .slides section .fragment.highlight-green, .reveal .slides section .fragment.highlight-blue { opacity: 1; } .reveal .slides section .fragment.highlight-red.visible { color: #ff2c2d } .reveal .slides section .fragment.highlight-green.visible { color: #17ff2e; } .reveal .slides section .fragment.highlight-blue.visible { color: #1b91ff; } /********************************************* * DEFAULT ELEMENT STYLES *********************************************/ /* Fixes issue in Chrome where italic fonts did not appear when printing to PDF */ .reveal:after { content: ''; font-style: italic; } /* Preserve aspect ratio and scale image so it's bound within the section */ .reveal img, .reveal iframe { max-width: 100%; max-height: 100%; } .reveal strong, .reveal b { font-weight: bold; } .reveal em, .reveal i { font-style: italic; } .reveal ol, .reveal ul { display: inline-block; text-align: left; margin: 0 0 0 1em; } .reveal ol { list-style-type: decimal; } .reveal ul { list-style-type: disc; } .reveal ul ul { list-style-type: square; } .reveal ul ul ul { list-style-type: circle; } .reveal ul ul, .reveal ul ol, .reveal ol ol, .reveal ol ul { display: block; margin-left: 40px; } .reveal .slides p { font-size: 1.1em; } .reveal p { margin-bottom: 10px; line-height: 1.2em; } .reveal q, .reveal blockquote { quotes: none; } .reveal blockquote { display: block; position: relative; width: 70%; margin: 5px auto; padding: 5px; font-style: italic; background: rgba(255, 255, 255, 0.05); box-shadow: 0px 0px 2px rgba(0,0,0,0.2); } .reveal blockquote p:first-child, .reveal blockquote p:last-child { display: inline-block; } .reveal blockquote:before { content: '\201C'; } .reveal blockquote:after { content: '\201D'; } .reveal q { font-style: italic; } .reveal q:before { content: '\201C'; } .reveal q:after { content: '\201D'; } .reveal pre { display: block; position: relative; width:110%; margin: 15px auto; text-align: left; font-size: 0.9em; font-family: monospace; line-height: 1.2em; word-wrap: break-word; box-shadow: 0px 0px 6px rgba(0,0,0,0.3); } .reveal pre code { padding: 5px; } .reveal code { font-family: monospace; overflow: auto; max-height: 400px; } .reveal table th, .reveal table td { text-align: left; padding-right: .3em; } .reveal table th { text-shadow: rgb(255,255,255) 1px 1px 2px; } .reveal sup { vertical-align: super; } .reveal sub { vertical-align: sub; } .reveal small { display: inline-block; font-size: 0.6em; line-height: 1.2em; vertical-align: top; } .reveal small * { vertical-align: top; } /********************************************* * CONTROLS *********************************************/ .reveal .controls { display: none; position: fixed; width: 110px; height: 110px; z-index: 30; right: 10px; bottom: 10px; } .reveal .controls div { position: absolute; opacity: 0.1; width: 0; height: 0; border: 12px solid transparent; -webkit-transition: opacity 0.2s ease; -moz-transition: opacity 0.2s ease; -ms-transition: opacity 0.2s ease; -o-transition: opacity 0.2s ease; transition: opacity 0.2s ease; } .reveal .controls div.enabled { opacity: 0.6; cursor: pointer; } .reveal .controls div.enabled:active { margin-top: 1px; } .reveal .controls div.navigate-left { top: 42px; border-right-width: 22px; border-right-color: #eee; } .reveal .controls div.navigate-right { left: 74px; top: 42px; border-left-width: 22px; border-left-color: #eee; } .reveal .controls div.navigate-up { left: 42px; border-bottom-width: 22px; border-bottom-color: #eee; } .reveal .controls div.navigate-down { left: 42px; top: 74px; border-top-width: 22px; border-top-color: #eee; } /********************************************* * PROGRESS BAR *********************************************/ .reveal .progress { position: fixed; display: none; height: 3px; width: 100%; bottom: 0; left: 0; z-index: 10; } .reveal .progress:after { content: ''; display: 'block'; position: absolute; height: 20px; width: 100%; top: -20px; } .reveal .progress span { display: block; height: 100%; width: 0px; -webkit-transition: width 800ms cubic-bezier(0.260, 0.860, 0.440, 0.985); -moz-transition: width 800ms cubic-bezier(0.260, 0.860, 0.440, 0.985); -ms-transition: width 800ms cubic-bezier(0.260, 0.860, 0.440, 0.985); -o-transition: width 800ms cubic-bezier(0.260, 0.860, 0.440, 0.985); transition: width 800ms cubic-bezier(0.260, 0.860, 0.440, 0.985); } /********************************************* * ROLLING LINKS *********************************************/ .reveal .roll { display: inline-block; line-height: 1.2; overflow: hidden; vertical-align: top; -webkit-perspective: 400px; -moz-perspective: 400px; -ms-perspective: 400px; perspective: 400px; -webkit-perspective-origin: 50% 50%; -moz-perspective-origin: 50% 50%; -ms-perspective-origin: 50% 50%; perspective-origin: 50% 50%; } .reveal .roll:hover { background: none; text-shadow: none; } .reveal .roll span { display: block; position: relative; padding: 0 2px; pointer-events: none; -webkit-transition: all 400ms ease; -moz-transition: all 400ms ease; -ms-transition: all 400ms ease; transition: all 400ms ease; -webkit-transform-origin: 50% 0%; -moz-transform-origin: 50% 0%; -ms-transform-origin: 50% 0%; transform-origin: 50% 0%; -webkit-transform-style: preserve-3d; -moz-transform-style: preserve-3d; -ms-transform-style: preserve-3d; transform-style: preserve-3d; -webkit-backface-visibility: hidden; -moz-backface-visibility: hidden; backface-visibility: hidden; } .reveal .roll:hover span { background: rgba(0,0,0,0.5); -webkit-transform: translate3d( 0px, 0px, -45px ) rotateX( 90deg ); -moz-transform: translate3d( 0px, 0px, -45px ) rotateX( 90deg ); -ms-transform: translate3d( 0px, 0px, -45px ) rotateX( 90deg ); transform: translate3d( 0px, 0px, -45px ) rotateX( 90deg ); } .reveal .roll span:after { content: attr(data-title); display: block; position: absolute; left: 0; top: 0; padding: 0 2px; -webkit-transform-origin: 50% 0%; -moz-transform-origin: 50% 0%; -ms-transform-origin: 50% 0%; transform-origin: 50% 0%; -webkit-transform: translate3d( 0px, 110%, 0px ) rotateX( -90deg ); -moz-transform: translate3d( 0px, 110%, 0px ) rotateX( -90deg ); -ms-transform: translate3d( 0px, 110%, 0px ) rotateX( -90deg ); transform: translate3d( 0px, 110%, 0px ) rotateX( -90deg ); } /********************************************* * SLIDES *********************************************/ .reveal { position: relative; width: 100%; height: 100%; min-height: 640px; /* min height + 40 to account for padding */ } .reveal .slides { position: absolute; max-width: 900px; min-height: 600px; width: 80%; left: 50%; top: 50%; overflow: visible; z-index: 1; text-align: center; -webkit-transition: -webkit-perspective .4s ease; -moz-transition: -moz-perspective .4s ease; -ms-transition: -ms-perspective .4s ease; -o-transition: -o-perspective .4s ease; transition: perspective .4s ease; -webkit-perspective: 600px; -moz-perspective: 600px; -ms-perspective: 600px; perspective: 600px; -webkit-perspective-origin: 0px -100px; -moz-perspective-origin: 0px -100px; -ms-perspective-origin: 0px -100px; perspective-origin: 0px -100px; } .reveal .slides>section, .reveal .slides>section>section { display: none; position: absolute; width: 100%; padding: 20px 0px; z-index: 10; line-height: 1.2em; font-weight: normal; -webkit-transform-style: preserve-3d; -moz-transform-style: preserve-3d; -ms-transform-style: preserve-3d; transform-style: preserve-3d; -webkit-transition: -webkit-transform-origin 800ms cubic-bezier(0.260, 0.860, 0.440, 0.985), -webkit-transform 800ms cubic-bezier(0.260, 0.860, 0.440, 0.985), visibility 800ms cubic-bezier(0.260, 0.860, 0.440, 0.985), opacity 800ms cubic-bezier(0.260, 0.860, 0.440, 0.985); -moz-transition: -moz-transform-origin 800ms cubic-bezier(0.260, 0.860, 0.440, 0.985), -moz-transform 800ms cubic-bezier(0.260, 0.860, 0.440, 0.985), visibility 800ms cubic-bezier(0.260, 0.860, 0.440, 0.985), opacity 800ms cubic-bezier(0.260, 0.860, 0.440, 0.985); -ms-transition: -ms-transform-origin 800ms cubic-bezier(0.260, 0.860, 0.440, 0.985), -ms-transform 800ms cubic-bezier(0.260, 0.860, 0.440, 0.985), visibility 800ms cubic-bezier(0.260, 0.860, 0.440, 0.985), opacity 800ms cubic-bezier(0.260, 0.860, 0.440, 0.985); -o-transition: -o-transform-origin 800ms cubic-bezier(0.260, 0.860, 0.440, 0.985), -o-transform 800ms cubic-bezier(0.260, 0.860, 0.440, 0.985), visibility 800ms cubic-bezier(0.260, 0.860, 0.440, 0.985), opacity 800ms cubic-bezier(0.260, 0.860, 0.440, 0.985); transition: transform-origin 800ms cubic-bezier(0.260, 0.860, 0.440, 0.985), transform 800ms cubic-bezier(0.260, 0.860, 0.440, 0.985), visibility 800ms cubic-bezier(0.260, 0.860, 0.440, 0.985), opacity 800ms cubic-bezier(0.260, 0.860, 0.440, 0.985); } .reveal .slides>section { left: -60%; top: -50%; } .reveal .slides>section.present, .reveal .slides>section>section.present { display: block; z-index: 11; opacity: 1; } .reveal.center, .reveal.center .slides, .reveal.center .slides section { min-height: auto !important; } /********************************************* * DEFAULT TRANSITION *********************************************/ .reveal .slides>section.past { display: block; opacity: 0; -webkit-transform: translate3d(-100%, 0, 0) rotateY(-90deg) translate3d(-100%, 0, 0); -moz-transform: translate3d(-100%, 0, 0) rotateY(-90deg) translate3d(-100%, 0, 0); -ms-transform: translate3d(-100%, 0, 0) rotateY(-90deg) translate3d(-100%, 0, 0); transform: translate3d(-100%, 0, 0) rotateY(-90deg) translate3d(-100%, 0, 0); } .reveal .slides>section.future { display: block; opacity: 0; -webkit-transform: translate3d(100%, 0, 0) rotateY(90deg) translate3d(100%, 0, 0); -moz-transform: translate3d(100%, 0, 0) rotateY(90deg) translate3d(100%, 0, 0); -ms-transform: translate3d(100%, 0, 0) rotateY(90deg) translate3d(100%, 0, 0); transform: translate3d(100%, 0, 0) rotateY(90deg) translate3d(100%, 0, 0); } .reveal .slides>section>section.past { display: block; opacity: 0; -webkit-transform: translate3d(0, -300px, 0) rotateX(70deg) translate3d(0, -300px, 0); -moz-transform: translate3d(0, -300px, 0) rotateX(70deg) translate3d(0, -300px, 0); -ms-transform: translate3d(0, -300px, 0) rotateX(70deg) translate3d(0, -300px, 0); transform: translate3d(0, -300px, 0) rotateX(70deg) translate3d(0, -300px, 0); } .reveal .slides>section>section.future { display: block; opacity: 0; -webkit-transform: translate3d(0, 300px, 0) rotateX(-70deg) translate3d(0, 300px, 0); -moz-transform: translate3d(0, 300px, 0) rotateX(-70deg) translate3d(0, 300px, 0); -ms-transform: translate3d(0, 300px, 0) rotateX(-70deg) translate3d(0, 300px, 0); transform: translate3d(0, 300px, 0) rotateX(-70deg) translate3d(0, 300px, 0); } /********************************************* * CONCAVE TRANSITION *********************************************/ .reveal.concave .slides>section.past { -webkit-transform: translate3d(-100%, 0, 0) rotateY(90deg) translate3d(-100%, 0, 0); -moz-transform: translate3d(-100%, 0, 0) rotateY(90deg) translate3d(-100%, 0, 0); -ms-transform: translate3d(-100%, 0, 0) rotateY(90deg) translate3d(-100%, 0, 0); transform: translate3d(-100%, 0, 0) rotateY(90deg) translate3d(-100%, 0, 0); } .reveal.concave .slides>section.future { -webkit-transform: translate3d(100%, 0, 0) rotateY(-90deg) translate3d(100%, 0, 0); -moz-transform: translate3d(100%, 0, 0) rotateY(-90deg) translate3d(100%, 0, 0); -ms-transform: translate3d(100%, 0, 0) rotateY(-90deg) translate3d(100%, 0, 0); transform: translate3d(100%, 0, 0) rotateY(-90deg) translate3d(100%, 0, 0); } .reveal.concave .slides>section>section.past { -webkit-transform: translate3d(0, -80%, 0) rotateX(-70deg) translate3d(0, -80%, 0); -moz-transform: translate3d(0, -80%, 0) rotateX(-70deg) translate3d(0, -80%, 0); -ms-transform: translate3d(0, -80%, 0) rotateX(-70deg) translate3d(0, -80%, 0); transform: translate3d(0, -80%, 0) rotateX(-70deg) translate3d(0, -80%, 0); } .reveal.concave .slides>section>section.future { -webkit-transform: translate3d(0, 80%, 0) rotateX(70deg) translate3d(0, 80%, 0); -moz-transform: translate3d(0, 80%, 0) rotateX(70deg) translate3d(0, 80%, 0); -ms-transform: translate3d(0, 80%, 0) rotateX(70deg) translate3d(0, 80%, 0); transform: translate3d(0, 80%, 0) rotateX(70deg) translate3d(0, 80%, 0); } /********************************************* * ZOOM TRANSITION *********************************************/ .reveal.zoom .slides>section.past { opacity: 0; visibility: hidden; -webkit-transform: scale(16); -moz-transform: scale(16); -ms-transform: scale(16); -o-transform: scale(16); transform: scale(16); } .reveal.zoom .slides>section.future { opacity: 0; visibility: hidden; -webkit-transform: scale(0.2); -moz-transform: scale(0.2); -ms-transform: scale(0.2); -o-transform: scale(0.2); transform: scale(0.2); } .reveal.zoom .slides>section>section.past { -webkit-transform: translate(0, -150%); -moz-transform: translate(0, -150%); -ms-transform: translate(0, -150%); -o-transform: translate(0, -150%); transform: translate(0, -150%); } .reveal.zoom .slides>section>section.future { -webkit-transform: translate(0, 150%); -moz-transform: translate(0, 150%); -ms-transform: translate(0, 150%); -o-transform: translate(0, 150%); transform: translate(0, 150%); } /********************************************* * LINEAR TRANSITION *********************************************/ .reveal.linear .slides>section.past { -webkit-transform: translate(-150%, 0); -moz-transform: translate(-150%, 0); -ms-transform: translate(-150%, 0); -o-transform: translate(-150%, 0); transform: translate(-150%, 0); } .reveal.linear .slides>section.future { -webkit-transform: translate(150%, 0); -moz-transform: translate(150%, 0); -ms-transform: translate(150%, 0); -o-transform: translate(150%, 0); transform: translate(150%, 0); } .reveal.linear .slides>section>section.past { -webkit-transform: translate(0, -150%); -moz-transform: translate(0, -150%); -ms-transform: translate(0, -150%); -o-transform: translate(0, -150%); transform: translate(0, -150%); } .reveal.linear .slides>section>section.future { -webkit-transform: translate(0, 150%); -moz-transform: translate(0, 150%); -ms-transform: translate(0, 150%); -o-transform: translate(0, 150%); transform: translate(0, 150%); } /********************************************* * CUBE TRANSITION *********************************************/ .reveal.cube .slides { -webkit-perspective: 1300px; -moz-perspective: 1300px; -ms-perspective: 1300px; perspective: 1300px; } .reveal.cube .slides section { padding: 30px; min-height: 600px; -webkit-backface-visibility: hidden; -moz-backface-visibility: hidden; -ms-backface-visibility: hidden; backface-visibility: hidden; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } .reveal.center.cube .slides section { min-height: auto; } .reveal.cube .slides section:not(.stack):before { content: ''; position: absolute; display: block; width: 100%; height: 100%; left: 0; top: 0; background: rgba(0,0,0,0.1); border-radius: 4px; -webkit-transform: translateZ( -20px ); -moz-transform: translateZ( -20px ); -ms-transform: translateZ( -20px ); -o-transform: translateZ( -20px ); transform: translateZ( -20px ); } .reveal.cube .slides section:not(.stack):after { content: ''; position: absolute; display: block; width: 90%; height: 30px; left: 5%; bottom: 0; background: none; z-index: 1; border-radius: 4px; box-shadow: 0px 95px 25px rgba(0,0,0,0.2); -webkit-transform: translateZ(-90px) rotateX( 65deg ); -moz-transform: translateZ(-90px) rotateX( 65deg ); -ms-transform: translateZ(-90px) rotateX( 65deg ); -o-transform: translateZ(-90px) rotateX( 65deg ); transform: translateZ(-90px) rotateX( 65deg ); } .reveal.cube .slides>section.stack { padding: 0; background: none; } .reveal.cube .slides>section.past { -webkit-transform-origin: 100% 0%; -moz-transform-origin: 100% 0%; -ms-transform-origin: 100% 0%; transform-origin: 100% 0%; -webkit-transform: translate3d(-100%, 0, 0) rotateY(-90deg); -moz-transform: translate3d(-100%, 0, 0) rotateY(-90deg); -ms-transform: translate3d(-100%, 0, 0) rotateY(-90deg); transform: translate3d(-100%, 0, 0) rotateY(-90deg); } .reveal.cube .slides>section.future { -webkit-transform-origin: 0% 0%; -moz-transform-origin: 0% 0%; -ms-transform-origin: 0% 0%; transform-origin: 0% 0%; -webkit-transform: translate3d(100%, 0, 0) rotateY(90deg); -moz-transform: translate3d(100%, 0, 0) rotateY(90deg); -ms-transform: translate3d(100%, 0, 0) rotateY(90deg); transform: translate3d(100%, 0, 0) rotateY(90deg); } .reveal.cube .slides>section>section.past { -webkit-transform-origin: 0% 100%; -moz-transform-origin: 0% 100%; -ms-transform-origin: 0% 100%; transform-origin: 0% 100%; -webkit-transform: translate3d(0, -100%, 0) rotateX(90deg); -moz-transform: translate3d(0, -100%, 0) rotateX(90deg); -ms-transform: translate3d(0, -100%, 0) rotateX(90deg); transform: translate3d(0, -100%, 0) rotateX(90deg); } .reveal.cube .slides>section>section.future { -webkit-transform-origin: 0% 0%; -moz-transform-origin: 0% 0%; -ms-transform-origin: 0% 0%; transform-origin: 0% 0%; -webkit-transform: translate3d(0, 100%, 0) rotateX(-90deg); -moz-transform: translate3d(0, 100%, 0) rotateX(-90deg); -ms-transform: translate3d(0, 100%, 0) rotateX(-90deg); transform: translate3d(0, 100%, 0) rotateX(-90deg); } /********************************************* * PAGE TRANSITION *********************************************/ .reveal.page .slides { -webkit-perspective-origin: 0% 50%; -moz-perspective-origin: 0% 50%; -ms-perspective-origin: 0% 50%; perspective-origin: 0% 50%; -webkit-perspective: 3000px; -moz-perspective: 3000px; -ms-perspective: 3000px; perspective: 3000px; } .reveal.page .slides section { padding: 30px; min-height: 600px; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } .reveal.page .slides section.past { z-index: 12; } .reveal.page .slides section:not(.stack):before { content: ''; position: absolute; display: block; width: 100%; height: 100%; left: 0; top: 0; background: rgba(0,0,0,0.1); -webkit-transform: translateZ( -20px ); -moz-transform: translateZ( -20px ); -ms-transform: translateZ( -20px ); -o-transform: translateZ( -20px ); transform: translateZ( -20px ); } .reveal.page .slides section:not(.stack):after { content: ''; position: absolute; display: block; width: 90%; height: 30px; left: 5%; bottom: 0; background: none; z-index: 1; border-radius: 4px; box-shadow: 0px 95px 25px rgba(0,0,0,0.2); -webkit-transform: translateZ(-90px) rotateX( 65deg ); } .reveal.page .slides>section.stack { padding: 0; background: none; } .reveal.page .slides>section.past { -webkit-transform-origin: 0% 0%; -moz-transform-origin: 0% 0%; -ms-transform-origin: 0% 0%; transform-origin: 0% 0%; -webkit-transform: translate3d(-40%, 0, 0) rotateY(-80deg); -moz-transform: translate3d(-40%, 0, 0) rotateY(-80deg); -ms-transform: translate3d(-40%, 0, 0) rotateY(-80deg); transform: translate3d(-40%, 0, 0) rotateY(-80deg); } .reveal.page .slides>section.future { -webkit-transform-origin: 100% 0%; -moz-transform-origin: 100% 0%; -ms-transform-origin: 100% 0%; transform-origin: 100% 0%; -webkit-transform: translate3d(0, 0, 0); -moz-transform: translate3d(0, 0, 0); -ms-transform: translate3d(0, 0, 0); transform: translate3d(0, 0, 0); } .reveal.page .slides>section>section.past { -webkit-transform-origin: 0% 0%; -moz-transform-origin: 0% 0%; -ms-transform-origin: 0% 0%; transform-origin: 0% 0%; -webkit-transform: translate3d(0, -40%, 0) rotateX(80deg); -moz-transform: translate3d(0, -40%, 0) rotateX(80deg); -ms-transform: translate3d(0, -40%, 0) rotateX(80deg); transform: translate3d(0, -40%, 0) rotateX(80deg); } .reveal.page .slides>section>section.future { -webkit-transform-origin: 0% 100%; -moz-transform-origin: 0% 100%; -ms-transform-origin: 0% 100%; transform-origin: 0% 100%; -webkit-transform: translate3d(0, 0, 0); -moz-transform: translate3d(0, 0, 0); -ms-transform: translate3d(0, 0, 0); transform: translate3d(0, 0, 0); } /********************************************* * TILE-FLIP TRANSITION (CSS shader) *********************************************/ .reveal.tileflip .slides section.present { -webkit-transform: none; -webkit-transition-duration: 800ms; -webkit-filter: custom( url(shaders/tile-flip.vs) mix(url(shaders/tile-flip.fs) multiply source-atop), 10 10 border-box detached, transform perspective(1000) scale(1) rotateX(0deg) rotateY(0deg) rotateZ(0deg), amount 0, randomness 0, flipAxis 0 1 0, tileOutline 1 ); } .reveal.tileflip .slides section.past { -webkit-transform: none; -webkit-transition-duration: 800ms; -webkit-filter: custom( url(shaders/tile-flip.vs) mix(url(shaders/tile-flip.fs) multiply source-atop), 10 10 border-box detached, transform perspective(1000) scale(1) rotateX(0deg) rotateY(0deg) rotateZ(0deg), amount 1, randomness 0, flipAxis 0 1 0, tileOutline 1 ); } .reveal.tileflip .slides section.future { -webkit-transform: none; -webkit-transition-duration: 800ms; -webkit-filter: custom( url(shaders/tile-flip.vs) mix(url(shaders/tile-flip.fs) multiply source-atop), 10 10 border-box detached, transform perspective(1000) scale(1) rotateX(0deg) rotateY(0deg) rotateZ(0deg), amount 1, randomness 0, flipAxis 0 1 0, tileOutline 1 ); } .reveal.tileflip .slides>section>section.present { -webkit-filter: custom( url(shaders/tile-flip.vs) mix(url(shaders/tile-flip.fs) multiply source-atop), 10 10 border-box detached, transform perspective(1000) scale(1) rotateX(0deg) rotateY(0deg) rotateZ(0deg), amount 0, randomness 2, flipAxis 1 0 0, tileOutline 1 ); } .reveal.tileflip .slides>section>section.past { -webkit-filter: custom( url(shaders/tile-flip.vs) mix(url(shaders/tile-flip.fs) multiply source-atop), 10 10 border-box detached, transform perspective(1000) scale(1) rotateX(0deg) rotateY(0deg) rotateZ(0deg), amount 1, randomness 2, flipAxis 1 0 0, tileOutline 1 ); } .reveal.tileflip .slides>section>section.future { -webkit-filter: custom( url(shaders/tile-flip.vs) mix(url(shaders/tile-flip.fs) multiply source-atop), 10 10 border-box detached, transform perspective(1000) scale(1) rotateX(0deg) rotateY(0deg) rotateZ(0deg), amount 1, randomness 2, flipAxis 1 0 0, tileOutline 1 ); } /********************************************* * NO TRANSITION *********************************************/ .reveal.none .slides section { -webkit-transform: none; -moz-transform: none; -ms-transform: none; -o-transform: none; transform: none; -webkit-transition: none; -moz-transition: none; -ms-transition: none; -o-transition: none; transition: none; } /********************************************* * OVERVIEW *********************************************/ .reveal.overview .slides { -webkit-perspective-origin: 0% 0%; -moz-perspective-origin: 0% 0%; -ms-perspective-origin: 0% 0%; perspective-origin: 0% 0%; -webkit-perspective: 700px; -moz-perspective: 700px; -ms-perspective: 700px; perspective: 700px; } .reveal.overview .slides section { height: 600px; overflow: hidden; opacity: 1!important; visibility: visible!important; cursor: pointer; background: rgba(0,0,0,0.1); } .reveal.overview .slides section .fragment { opacity: 1; } .reveal.overview .slides section:after, .reveal.overview .slides section:before { display: none !important; } .reveal.overview .slides section>section { opacity: 1; cursor: pointer; } .reveal.overview .slides section:hover { background: rgba(0,0,0,0.3); } .reveal.overview .slides section.present { background: rgba(0,0,0,0.3); } .reveal.overview .slides>section.stack { padding: 0; background: none; overflow: visible; } /********************************************* * PAUSED MODE *********************************************/ .reveal .pause-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: black; visibility: hidden; opacity: 0; z-index: 100; -webkit-transition: all 1s ease; -moz-transition: all 1s ease; -ms-transition: all 1s ease; -o-transition: all 1s ease; transition: all 1s ease; } .reveal.paused .pause-overlay { visibility: visible; opacity: 1; } /********************************************* * FALLBACK *********************************************/ .no-transforms { overflow-y: auto; } .no-transforms .slides { top: 0; left: 50%; margin: 0; text-align: center; } .no-transforms .slides section { display: block!important; opacity: 1!important; position: relative!important; height: auto; min-height: auto; top: 0; left: -50%; margin: 70px 0; -webkit-transform: none; -moz-transform: none; -ms-transform: none; transform: none; } .no-transforms .slides section section { left: 0; } .no-transition { -webkit-transition: none; -moz-transition: none; -ms-transition: none; -o-transition: none; transition: none; } /********************************************* * BACKGROUND STATES *********************************************/ .reveal .state-background { position: absolute; width: 100%; height: 100%; background: rgba( 0, 0, 0, 0 ); -webkit-transition: background 800ms ease; -moz-transition: background 800ms ease; -ms-transition: background 800ms ease; -o-transition: background 800ms ease; transition: background 800ms ease; } .alert .reveal .state-background { background: rgba( 200, 50, 30, 0.6 ); } .soothe .reveal .state-background { background: rgba( 50, 200, 90, 0.4 ); } .blackout .reveal .state-background { background: rgba( 0, 0, 0, 0.6 ); } /********************************************* * RTL SUPPORT *********************************************/ .reveal.rtl .slides, .reveal.rtl .slides h1, .reveal.rtl .slides h2, .reveal.rtl .slides h3, .reveal.rtl .slides h4, .reveal.rtl .slides h5, .reveal.rtl .slides h6 { direction: rtl; font-family: sans-serif; } .reveal.rtl pre, .reveal.rtl code { direction: ltr; } .reveal.rtl ol, .reveal.rtl ul { text-align: right; } /********************************************* * SPEAKER NOTES *********************************************/ .reveal aside.notes { display: none; } /********************************************* * ZOOM PLUGIN *********************************************/ .zoomed .reveal *, .zoomed .reveal *:before, .zoomed .reveal *:after { -webkit-transform: none !important; -moz-transform: none !important; -ms-transform: none !important; transform: none !important; -webkit-backface-visibility: visible !important; -moz-backface-visibility: visible !important; -ms-backface-visibility: visible !important; backface-visibility: visible !important; } .zoomed .reveal .progress, .zoomed .reveal .controls { opacity: 0; } .zoomed .reveal .roll span { background: none; } .zoomed .reveal .roll span:after { visibility: hidden; } ================================================ FILE: css/shaders/tile-flip.fs ================================================ /* * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. * Copyright (c) 2012 Branislav Ulicny * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ precision mediump float; // Uniform values from CSS uniform float amount; uniform float tileOutline; // Built-in uniforms uniform vec2 u_meshSize; uniform vec2 u_textureSize; // Varyings passed in from vertex shader varying float v_depth; varying vec2 v_uv; // Main void main() { // FIXME: Must swap x and y as a workaround for: // https://bugs.webkit.org/show_bug.cgi?id=96285 vec2 u_meshSize = u_meshSize.yx; vec4 c = vec4(1.0); // Fade out. c.a = 1.0 - v_depth; // Show grid outline. if (tileOutline >= 0.5) { float cell_width = u_textureSize.x / u_meshSize.y; float cell_height = u_textureSize.y / u_meshSize.x; float dd = 1.0; if (mod(v_uv.x * u_textureSize.x + dd, cell_width) < 2.0 || mod(v_uv.y * u_textureSize.y + dd, cell_height) < 2.0) { if (amount > 0.0) c.rgb = vec3(1.0 - sqrt(amount)); } } css_ColorMatrix = mat4(c.r, 0.0, 0.0, 0.0, 0.0, c.g, 0.0, 0.0, 0.0, 0.0, c.b, 0.0, 0.0, 0.0, 0.0, c.a); } ================================================ FILE: css/shaders/tile-flip.vs ================================================ /* * Copyright (c)2012 Adobe Systems Incorporated. All rights reserved. * Copyright (c)2012 Branislav Ulicny * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ precision mediump float; // Built-in attributes attribute vec4 a_position; attribute vec2 a_texCoord; attribute vec3 a_triangleCoord; // Built-in uniforms uniform mat4 u_projectionMatrix; uniform vec2 u_meshSize; uniform vec2 u_textureSize; // Uniform passed in from CSS uniform mat4 transform; uniform float amount; uniform float randomness; uniform vec3 flipAxis; // Varyings varying float v_depth; varying vec2 v_uv; // Constants const float PI2 = 1.5707963267948966; // Create perspective matrix mat4 perspectiveMatrix(float p) { float perspective = - 1.0 / p; return mat4( 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, perspective, 0.0, 0.0, 0.0, 1.0 ); } // Rotate vector vec3 rotateVectorByQuaternion(vec3 v, vec4 q) { vec3 dest = vec3(0.0); float x = v.x, y = v.y, z = v.z; float qx = q.x, qy = q.y, qz = q.z, qw = q.w; // Calculate quaternion * vector. float ix = qw * x + qy * z - qz * y, iy = qw * y + qz * x - qx * z, iz = qw * z + qx * y - qy * x, iw = -qx * x - qy * y - qz * z; // Calculate result * inverse quaternion. dest.x = ix * qw + iw * -qx + iy * -qz - iz * -qy; dest.y = iy * qw + iw * -qy + iz * -qx - ix * -qz; dest.z = iz * qw + iw * -qz + ix * -qy - iy * -qx; return dest; } // Convert rotation. vec4 axisAngleToQuaternion(vec3 axis, float angle) { vec4 dest = vec4(0.0); float halfAngle = angle / 2.0; float s = sin(halfAngle); dest.x = axis.x * s; dest.y = axis.y * s; dest.z = axis.z * s; dest.w = cos(halfAngle); return dest; } // Random function based on the tile coordinate. // This will return the same value for all the vertices in the same tile (i.e. two triangles). float random(vec2 scale) { // Use the fragment position as a different seed per-pixel. return fract(sin(dot(vec2(a_triangleCoord.x, a_triangleCoord.y), scale)) * 4000.0); } // Main void main() { // FIXME: We must swap x and y as a workaround for: // https://bugs.webkit.org/show_bug.cgi?id=96285 vec2 u_meshSize = u_meshSize.yx; vec4 pos = a_position; float aspect = u_textureSize.x / u_textureSize.y; float cx = a_triangleCoord.x / u_meshSize.y - 0.5 + 0.5 / u_meshSize.y; float cy = a_triangleCoord.y / u_meshSize.x - 0.5 + 0.5 / u_meshSize.x; vec3 centroid = vec3(cx, cy, 0.0); float r = random(vec2(10.0, 80.0)); float rr = mix(0.0, PI2, amount * (1.0 + randomness * r)); vec4 rotation = vec4(flipAxis, rr); vec4 qRotation = axisAngleToQuaternion(normalize(rotation.xyz), rotation.w); vec3 newPosition = rotateVectorByQuaternion((pos.xyz - centroid)* vec3(aspect, 1., 1.0), qRotation) * vec3(1.0 / aspect, 1.0, 1.0) + centroid; pos.xyz = newPosition; gl_Position = u_projectionMatrix * transform * pos; // Pass varyings to the fragment shader. v_depth = abs(rr)/ PI2; v_uv = a_texCoord; } ================================================ FILE: css/theme/default.css ================================================ @import url(http://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic); /** * Default theme for reveal.js. * * Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se */ @font-face { font-family: 'League Gothic'; src: url("../../lib/font/league_gothic-webfont.eot"); src: url("../../lib/font/league_gothic-webfont.eot?#iefix") format("embedded-opentype"), url("../../lib/font/league_gothic-webfont.woff") format("woff"), url("../../lib/font/league_gothic-webfont.ttf") format("truetype"), url("../../lib/font/league_gothic-webfont.svg#LeagueGothicRegular") format("svg"); font-weight: normal; font-style: normal; } /********************************************* * GLOBAL STYLES *********************************************/ body { background: #1c1e20; background: -moz-radial-gradient(center, circle cover, #555a5f 0%, #1c1e20 100%); background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%, #555a5f), color-stop(100%, #1c1e20)); background: -webkit-radial-gradient(center, circle cover, #555a5f 0%, #1c1e20 100%); background: -o-radial-gradient(center, circle cover, #555a5f 0%, #1c1e20 100%); background: -ms-radial-gradient(center, circle cover, #555a5f 0%, #1c1e20 100%); background: radial-gradient(center, circle cover, #555a5f 0%, #1c1e20 100%); background-color: #2b2b2b; } .reveal { /** font-family: "Lato", Times, "Times New Roman", serif; **/ font-family: '微软雅黑', "Lato", Times, "Times New Roman", serif; font-size: 36px; font-weight: 200; letter-spacing: -0.02em; color: #eeeeee; } ::selection { color: white; background: #ff5e99; text-shadow: none; } /********************************************* * HEADERS *********************************************/ .reveal h1, .reveal h2, .reveal h3, .reveal h4, .reveal h5, .reveal h6 { margin: 0 0 20px 0; color: #eeeeee; font-family: "League Gothic", Impact, sans-serif; line-height: 0.9em; letter-spacing: 0.02em; text-transform: uppercase; text-shadow: 0px 0px 6px rgba(0, 0, 0, 0.2); } .reveal h1 { text-shadow: 0 1px 0 #cccccc, 0 2px 0 #c9c9c9, 0 3px 0 #bbbbbb, 0 4px 0 #b9b9b9, 0 5px 0 #aaaaaa, 0 6px 1px rgba(0, 0, 0, 0.1), 0 0 5px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.3), 0 3px 5px rgba(0, 0, 0, 0.2), 0 5px 10px rgba(0, 0, 0, 0.25), 0 20px 20px rgba(0, 0, 0, 0.15); } /********************************************* * LINKS *********************************************/ .reveal a:not(.image) { color: #13daec; text-decoration: none; -webkit-transition: color .15s ease; -moz-transition: color .15s ease; -ms-transition: color .15s ease; -o-transition: color .15s ease; transition: color .15s ease; } .reveal a:not(.image):hover { color: #71e9f4; text-shadow: none; border: none; } .reveal .roll span:after { color: #fff; background: #0d99a5; } /********************************************* * IMAGES *********************************************/ .reveal section img { margin: 15px 0px; background: rgba(255, 255, 255, 0.12); border: 0px solid #eeeeee; box-shadow: 0 0 10px rgba(0, 0, 0, 0.15); -webkit-transition: all .2s linear; -moz-transition: all .2s linear; -ms-transition: all .2s linear; -o-transition: all .2s linear; transition: all .2s linear; } .reveal a:hover img { background: rgba(255, 255, 255, 0.2); border-color: #13daec; box-shadow: 0 0 20px rgba(0, 0, 0, 0.55); } /********************************************* * NAVIGATION CONTROLS *********************************************/ .reveal .controls div.navigate-left, .reveal .controls div.navigate-left.enabled { border-right-color: #13daec; } .reveal .controls div.navigate-right, .reveal .controls div.navigate-right.enabled { border-left-color: #13daec; } .reveal .controls div.navigate-up, .reveal .controls div.navigate-up.enabled { border-bottom-color: #13daec; } .reveal .controls div.navigate-down, .reveal .controls div.navigate-down.enabled { border-top-color: #13daec; } .reveal .controls div.navigate-left.enabled:hover { border-right-color: #71e9f4; } .reveal .controls div.navigate-right.enabled:hover { border-left-color: #71e9f4; } .reveal .controls div.navigate-up.enabled:hover { border-bottom-color: #71e9f4; } .reveal .controls div.navigate-down.enabled:hover { border-top-color: #71e9f4; } /********************************************* * PROGRESS BAR *********************************************/ .reveal .progress { background: rgba(0, 0, 0, 0.2); } .reveal .progress span { background: #13daec; -webkit-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985); -moz-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985); -ms-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985); -o-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985); transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985); } .reveal .dongwmhead { font-size: 48.0pt; } .reveal .dongwmtitle { font-size: 40.0pt; } .reveal .dongwmcsm { font-family:'comic sans ms'; } .reveal .dongwmblue { color: rgb(32,117,165); font-weight: bold; text-transform: uppercase; } .reveal .dongwmmenu { font-family:'comic sans ms'; color: #CC0066; font-size: 110px; text-transform: uppercase; } .reveal .dongwmleft { margin-left: 250px; text-align: left; } .reveal .dongwmgreen { font-weight: bold; color: #009242; text-transform: uppercase; } .reveal .dongwmfoot { font-size: 48.0pt;color: rgb(32,117,165);text-transform: uppercase;font-weight: bold; } .reveal .dongwmright { margin-left: 450px; text-align: left; } .reveal #rightimg { float: right; width: 120px; height: 50px; vertical-align:text-bottom; } .reveal #leftimg { position: relative; float: left; width: 100px; height: 40px; left: 160px; bottom: -250px; } .reveal iframe { margin-bottom: -150px; } ================================================ FILE: index.html ================================================ sed & awk

sed & awk



姓名:董伟明

日期:2013-12-09

(一)sed

学完本章的后果

  1. 把123变成[123](不要sed "s/\([0-9]\{3\}\)/[\1]/")
  2. 这是什么意思: echo "1\n2\n3\n4"|sed -n "/2/, +2p"(gnu sed)
  3. 这是什么意思: echo "1\n2\n3"|sed '2 c 4' (gnu sed)
  4. 把This is UPPER变成IS,This,upper(gnu sed)
  5. 这是什么意思: sed 'H;x;s/^\(.*\)\n\(.*\)/\2\1/'
  6. 实现tac命令的功能

语法1


sed [options] {sed-commands} {input-file}
						

例子


# -n表示取消默认输出,p表示打印行
$sed -n 'p' /etc/passwd
# 只打印第三行
$sed -n '3p' /etc/passwd
# 打印1,3行
$sed -n '1,3p' /etc/passwd
						

语法2


$sed [options] -f {sed-commands-in-a-file} {input-file}
						

例子


# 打印以root开头或者nobody开头的行
$cat sed_example_1.sed
/^root/ p
/^nobody/ p

$ sed -n -f sed_example_1.sed /etc/passwd
						

语法3


sed [options] -e {sed-command-1} -e {sed-command-2} {input-file}
						

例子


# 打印以root开头或者nobody开头的行
$sed -n -e '/^root/ p' -e '/^nobody/ p' /etc/passwd

#或者
$sed -n \
-e '/^root/ p' \
-e '/^nobody/ p' \
/etc/passwd
						

语法4


sed [options] '{
sed-command-1
sed-command-2
}' input-file
						

例子


# 打印以root开头或者nobody结尾的行
sed -n '{
/^root/ p
/nobody$/ p
}' /etc/passwd
						

sed流


  1. 执行
  2. 打印
  3. 重复

源文件


101,Ian Bicking,Mozilla
102,Hakim El Hattab,Whim
103,Paul Irish,Google
104,Addy Osmani,Google
105,Chris Wanstrath,Github
106,Mattt Thompson,Heroku
107,Ask Solem Hoel,VMware
						

范围


# 在freebsd版sed不能用
$/usr/local/bin/sed -n '1~2 p' source.txt 
101,Ian Bicking,Mozilla
103,Paul Irish,Google
105,Chris Wanstrath,Github
107,Ask Solem Hoel,VMware

# 在freebsd版sed不能用
$/usr/local/bin/sed -n '2~3 p' source.txt 
102,Hakim El Hattab,Whim
105,Chris Wanstrath,Github
						

模式匹配


# 寻找包含Paul的行
$sed -n '/Paul/ p' source.txt
103,Paul Irish,Google
# 从第一行开始到第五行, 从找到开始打印到第五行
$sed -n '/Paul/,5 p' source.txt
103,Paul Irish,Google
104,Addy Osmani,Google
105,Chris Wanstrath,Github

# 从匹配Paul行打印达匹配Addy的行
$sed -n '/Paul/,/Addy/ p' source.txt
103,Paul Irish,Google
104,Addy Osmani,Google
# 在freebsd版sed不能用 匹配Paul行再多输出2行
$/usr/local/bin/sed -n '/Paul/,+2 p' source.txt
103,Paul Irish,Google
104,Addy Osmani,Google
105,Chris Wanstrath,Github
						

删除行


# 删除所有行
$sed 'd' source.txt 
# 只删除第二行
$sed '2 d' source.txt 
...
# 删除第一到第四行
$sed '1,4 d' source.txt
105,Chris Wanstrath,Github
106,Mattt Thompson,Heroku
107,Ask Solem Hoel,VMware
# 删除奇数行
$/usr/local/bin/sed '1~2 d' source.txt
102,Hakim El Hattab,Whim
104,Addy Osmani,Google
106,Mattt Thompson,Heroku
# 删除符合Paul到Addy的行
$sed '/Paul/,/Addy/d' source.txt
101,Ian Bicking,Mozilla
102,Hakim El Hattab,Whim
105,Chris Wanstrath,Github
106,Mattt Thompson,Heroku
107,Ask Solem Hoel,VMware
# 删除空行
$sed '/^$/ d' source.txt
# 删除评论行
$sed '/^#/ d' source.txt
						

重定向


# 将source.txt内容重定向写到output.txt
$sed 'w output.txt' source.txt
# 和上面一样,但是没有在终端显示
$sed -n 'w output.txt' source.txt
# 只写第二行
$ sed -n '2 w output.txt' source.txt
# 写一到四行到output.txt
$sed -n '1,4 w output.txt'
# 写匹配Ask的行到结尾行到output.txt
$sed -n '/Ask/,$ w output.txt'
						

替换


sed '[address-range|pattern-range] s/original-
string/replacement-string/[substitute-flags]' inputfile
						

例子


# 替换Google为Github
$sed 's/Google/Github/' source.txt
101,Ian Bicking,Mozilla
102,Hakim El Hattab,Whim
103,Paul Irish,Github
104,Addy Osmani,Github
105,Chris Wanstrath,Github
106,Mattt Thompson,Heroku
107,Ask Solem Hoel,VMware
# 替换匹配Addy的行里面的Google为Github
$sed '/Addy/s/Google/Github/' source.txt
101,Ian Bicking,Mozilla
102,Hakim El Hattab,Whim
103,Paul Irish,Google
104,Addy Osmani,Github
105,Chris Wanstrath,Github
106,Mattt Thompson,Heroku
107,Ask Solem Hoel,VMware
# 默认s只会替换一行中的第一个匹配项
$sed '1s/a/A/'  source.txt|head -1
101,IAn Bicking,Mozilla
# g可以替换每行的全部符合
$sed '1s/a/A/g'  source.txt|head -1
101,IAn Bicking,MozillA
# 可以直接指定想要替换的第N个匹配项,这里是第二个
$sed '1s/a/A/2'  source.txt|head -1
101,Ian Bicking,MozillA
# 使用w将能够替换的行重定向写到output.txt
$sed -n 's/Mozilla/Github/w output.txt' source.txt
$cat output.txt 
101,Ian Bicking,Github
# 还可以使用i忽略匹配的大小写,看来freebsd的不能用
$/usr/local/bin/sed '1s/ian/IAN/i'  source.txt|head -1
101,IAN Bicking,Mozilla
# 这里有个新的文件
$cat files.txt 
/etc/passwd
/etc/group
# 给每行前和后都添加点字符
$sed 's/\(.*\)/ls -l \1|head -1/' files.txt
ls -l /etc/passwd|head -1
ls -l /etc/group|head -1
# 我要用sed执行这个字符串命令了 无奈..mac上得sed都不行
dongwm@bj-1:~$ sed 's/^/ls -l /e' files.txt
-rw-r--r-- 1 root root 1627 Oct 14 14:30 /etc/passwd
-rw-r--r-- 1 root root 807 Oct 14 14:30 /etc/group
# sed分隔符不只可以使用'/'
$sed 's|/usr/local/bin|/usr/bin|' path.txt
$sed 's^/usr/local/bin^/usr/bin^' path.txt
$sed 's@/usr/local/bin@/usr/bin@' path.txt
$sed 's!/usr/local/bin!/usr/bin!' path.txt
						

替换覆盖


sed '{
s/Google/Github/
s/Git/git/ 
}' source.txt 
101,Ian Bicking,Mozilla
102,Hakim El Hattab,Whim
103,Paul Irish,github
104,Addy Osmani,github
105,Chris Wanstrath,github
106,Mattt Thompson,Heroku
107,Ask Solem Hoel,VMware
						

神奇的&


$sed 's/^[0-9][0-9][0-9]/[&]/g'
[101],Ian Bicking,Mozilla
[102],Hakim El Hattab,Whim
[103],Paul Irish,Google
[104],Addy Osmani,Google
[105],Chris Wanstrath,Github
[106],Mattt Thompson,Heroku
[107],Ask Solem Hoel,VMware
$sed 's/^.*/<\&>/' source.txt 
<101,Ian Bicking,Mozilla>
<102,Hakim El Hattab,Whim>
<103,Paul Irish,Google>
<104,Addy Osmani,Google>
<105,Chris Wanstrath,Github>
<106,Mattt Thompson,Heroku>
<107,Ask Solem Hoel,VMware>
						

正则


# ^表示匹配以什么开头
$sed -n '/^101/ p' source.txt      
101,Ian Bicking,Mozilla
# $表示匹配以什么结尾
$sed -n '/Github$/ p' source.txt 
105,Chris Wanstrath,Github
# .表示单个字符,下面的匹配一个逗号然后I然后2个单字符
$sed -n '/,I../ p' source.txt
101,Ian Bicking,Mozilla
# *表示匹配0个或者多个, \+表示匹配一个或者多个, \?表示匹配0个或者1个
# [0-9]表示匹配数字,下面匹配包含3或者4的行
$sed -n '/[34]/ p ' source.txt      
103,Paul Irish,Google
104,Addy Osmani,Google
# -表示范围,这里匹配3,4,5
$sed -n '/[3-5]/ p ' source.txt
103,Paul Irish,Google
104,Addy Osmani,Google
105,Chris Wanstrath,Github
# |表示或者的关系
$/usr/local/bin/sed -n '/102\|103/ p ' source.txt
102,Hakim El Hattab,Whim
103,Paul Irish,Google
# 看一个文件
$cat numbers.txt 
1
12
123
1234
12345
123456
# {m} 表示前面的匹配的重复次数
$sed -n '/^[0-9]\{5\}$/ p' numbers.txt
12345
#{m,n } 表示匹配m-n的次数都算
sed -n '/^[0-9]\{3,5\}$/ p' numbers.txt
123
1234
12345
# 删除所有注释行和空行
$sed -e 's/#.*//' -e '/^$/ d' /etc/profile							
# 转化windows文件到unix格式
$sed 's/.$//' filename								
							
#\1表示第一个正则匹配到的数据
$sed 's/\([^,]*\).*/\1/g' source.txt |head -1
101
#给每个单词第一个字母加括号
$echo "Dong Wei Ming" | /usr/local/bin/sed 's/\(\b[A-Z]\)/\(\1\)/g'
(D)ong (W)ei (M)ing
$/usr/local/bin/sed 's/\(^\|[^0-9.]\)\([0-9]\+\)\([0-9]\{3\}\)/\1\2,\3/g' numbers.txt
1
12
123
1,234
12,345
123,456
# 只取第一和第三列,并且换了他们的位置
$sed 's/\([^,]*\),\([^,]*\),\([^,]*\).*/\3,\1/g' source.txt
Mozilla,101
Whim,102
Google,103
Google,104
Github,105
Heroku,106
VMware,107

						

Gnu sed


# \l能将后面的一个字符变成小写
$sed 's/Ian/IAN/' source.txt|head -1               
101,IAN Bicking,Mozilla
$/usr/local/bin/sed 's/Ian/IA\lN/' source.txt|head -1 
101,IAn Bicking,Mozilla
# \L能将后面的字符都变成小写
$/usr/local/bin/sed 's/Ian/I\LAN/' source.txt|head -1
101,Ian Bicking,Mozilla
# \u能将后面的一个字符变成大写
$/usr/local/bin/sed 's/Ian/IA\un/' source.txt|head -1
101,IAN Bicking,Mozilla
# \U能将后面的字都变成大写
$/usr/local/bin/sed 's/Ian/\Uian/' source.txt|head -1 
101,IAN Bicking,Mozilla
# \E能打断\L或者\U改变大小写
$/usr/local/bin/sed 's/Ian/\Uia\En/' source.txt|head -1
101,IAn Bicking,Mozilla
# 使用以上功能:调换前2列,把名字列全部大写,公司列全部小写
$/usr/local/bin/sed 's/\([^,]*\),\([^,]*\),\(.*\).*/\U\2\E,\1,\L\3/g' source.txt
IAN BICKING,101,mozilla
HAKIM EL HATTAB,102,whim
PAUL IRISH,103,google
ADDY OSMANI,104,google
CHRIS WANSTRATH,105,github
MATTT THOMPSON,106,heroku
ASK SOLEM HOEL,107,vmware



						

sed可执行脚本


$cat testscript.sed
#!/usr/bin/sed -nf
/root/ p
/nobody/ p
$chmod u+x testscript.sed
$./testscript.sed /etc/passwd 
nobody:*:-2:-2:Unprivileged User:/var/empty:/usr/bin/false
root:*:0:0:System Administrator:/var/root:/bin/sh
daemon:*:1:1:System Services:/var/root:/usr/bin/false
_cvmsroot:*:212:212:CVMS Root:/var/empty:/usr/bin/false
						

sed修改源文件和备份


#-i会修改源文件,但是可以同时使用bak备份
$sed -ibak 's/Ian/IAN/' source.txt 
# or
sed --in-place=bak 's/Ian/IAN/' source.txt 
# 这样会存在一个文件source.txtbak
						

行后增加语法


sed '[address] a the-line-to-append' input-file
						

例子


$/usr/local/bin/sed '2 a 108,Donald Stufft, Nebula' source.txt
101,IAN Bicking,Mozilla
102,Hakim El Hattab,Whim
108,Donald Stufft, Nebula
103,Paul Irish,Google
104,Addy Osmani,Google
105,Chris Wanstrath,Github
106,Mattt Thompson,Heroku
107,Ask Solem Hoel,VMware
						

行前插入语法


sed '[address] i the-line-to-insert' input-file
						

例子


$/usr/local/bin/sed '2 i 108,Donald Stufft, Nebula' source.txt
101,IAN Bicking,Mozilla
108,Donald Stufft, Nebula
102,Hakim El Hattab,Whim
103,Paul Irish,Google
104,Addy Osmani,Google
105,Chris Wanstrath,Github
106,Mattt Thompson,Heroku
107,Ask Solem Hoel,VMware
						

修改行语法


sed '[address] c the-line-to-insert' input-file
						

例子


							# 修改符合Paul行为...
$/usr/local/bin/sed '/Paul/ c 108,Donald Stufft, Nebula' source.txt
101,IAN Bicking,Mozilla
102,Hakim El Hattab,Whim
108,Donald Stufft, Nebula
104,Addy Osmani,Google
105,Chris Wanstrath,Github
106,Mattt Thompson,Heroku
107,Ask Solem Hoel,VMware
						

sed其他


# -l会显示隐藏字符比如'\t', = 可以显示行号
$sed -l = source.txt
# y或翻译你要转换的字符,这里I会转化成i,B转换成b
$sed 'y/IB/ib/' source.txt |head -1
101,iAN bicking,Mozilla
							
						

(二)Sed高级话题

保持空间和模式空间

源码


#先看一个文件
$cat source2.txt 
Ian Bicking
Mozilla
Hakim El Hattab
Whim
Paul Irish
Google
Chris Wanstrath
Github
Mattt Thompson
Heroku							
						

交换模式空间


# 通过公司找到这个人, x命令交换当前行到保持空间,
# n读取下一行到模式空间; 匹配这个模式空间, 假如符合,再交换模式空间,打印
$/usr/local/bin/sed  -n -e 'x;n' -e '/Whim/{x;p}' source2.txt  
Hakim El Hattab					
						

拷贝模式空间到保持空间


# 还是前面的需求.h拷贝模式空间到保持空间, 
# 如果当前模式空间不匹配, 就拷贝空间到保持空间. 他们会一样
# 但是当Whim匹配保持空间还是上面一行关于名字的缓存
$/usr/local/bin/sed  -n -e '/Whim/!h' -e '/Whim/{x;p}' source2.txt  
Hakim El Hattab			
						

增加模式空间到保持空间


# 当我根据Whim想显示他的名字和公司名字呢? - 给保持空间多加一个
# H表示增加模式空间到保持空间
$/usr/local/bin/sed -n -e '/Whim/!h' -e '/Whim/{H;x;p}' source2.txt 
Hakim El Hattab
Whim
# 显示的好看一点
$/usr/local/bin/sed -n -e '/Whim/!h' -e '/Whim/{H;x;s/\n/:/;p}' source2.txt 
Hakim El Hattab:Whim
		
						

拷贝保持空间到模式空间


# 还是前面的需求.g拷贝保持空间到模式空间
$/usr/local/bin/sed  -n -e '/Whim/!h' -e '/Whim/{g;p}' source2.txt   
Hakim El Hattab
						

增加保持空间到模式空间

 
# 前面的前面, 输出是Hakim El Hattab:Whim 怎么样翻转呢?
# G就是反向的
$/usr/local/bin/sed -n -e '/Whim/!h' -e '/Whim/{G;s/\n/:/;p}' source2.txt  
Whim:Hakim El Hattab		
						

增加下一行到模式空间

 
$/usr/local/bin/sed -e '{N;s/\n/:/}' source2.txt
Ian Bicking:Mozilla
Hakim El Hattab:Whim
Paul Irish:Google
Chris Wanstrath:Github
Mattt Thompson:Heroku
						

label


# 给匹配Github的行,在使用名字:公司的前面加一个*, 
#只有匹配Github的模式空间和保持空间才会执行s/^/*/
$cat label.sed 
#!/usr/local/bin/sed -nf
h;n;H;x
s/\n/:/
/Github/!b end
s/^/*/
:end p
$chmod u+x label.sed
./label.sed source2.txt
Ian Bicking:Mozilla
Hakim El Hattab:Whim
Paul Irish:Google
*Chris Wanstrath:Github
Mattt Thompson:Heroku
						

例子


# 把mac地址的冒号替换掉
"130531170341903612","259594",2013-05-31T09:04:25Z,"1c:b0:94:b2:85:bd"
						
  1. sed "s/\([0-9a-zA-Z]\{2\}\):\([0-9a-zA-Z]\{2\}\):\([0-9a-zA-Z]\{2\}\):\([0-9a-zA-Z]\{2\}\):\([0-9a-zA-Z]\{2\}\):\([0-9a-zA-Z]\{2\}\)/\1\2\3\4\5\6/"
  2. sed "s/\(.*\):\(.*\):\(.*\):\(.*\):\(.*\):\(.*\)/\1\2\3\4\5\6/"
  3. sed -e "s/T\(.*\):\(.*\):\(.*\)Z/\1#\2#\3/" -e "s/://g" -e "s/#/:/g"

(三)awk

学完本章的后果

  1. 获取来连接mongodb的各服务器产生的连接数
  2. 获取nginx日志ip访问数在一个小时里面,从多到少的总次数排行(排行用到了sort)
  3. 打印question_awk3.txt包含Addy和Mattt之间的行
  4. 不使用sort过滤重复行
  5. 将2个文件合并成一行,但username不一定在2个文件同一行
  6. 输出2个文件1中有,2中没有的行
  7. 这是什么意思: gawk -vcmd='ls -l' 'BEGIN{while ( (cmd | getline var) > 0) {print var} close(cmd)}'

语法1


awk -Fs '/pattern/ {action}' input-file
#or
awk -Fs '{action}' intput-file
# -F表示设置分隔符,不指定就是默认为空字符
						

例子


# 用:分割,查找匹配mail的行并且打印冒号分割后的第一部分
awk -F: '/mail/ {print $1}' /etc/passwd
_mailman
_clamav
_amavisd
						

awk数据结构


# 1 BEGIN { awk-commands } 在执行awk body之前执行这个awk-commands,而且只一次
# 2 /pattern/ {action} body部分,也就是awk要执行的主体,比如十行,那么这个主体就调用10次
# 3 END { awk-commands } 在执行完body之后执行,也是只一次
$awk 'BEGIN { FS=":";print "---header---" } /mail/ {print $1} \
END { print "---footer---"}' /etc/passwd
---header---
_mailman
_clamav
_amavisd
---footer---
# 当然可以只有其中一种或者集中数据结构
awk -F: 'BEGIN { print "UID"} { print $3 }' /etc/passwd |\
sed -e '/^$/ d'|head -2
UID
-2
$ awk 'BEGIN { print "Hello World!" }'
Hello World!
						

源码2


# 这是一个文件,分别是id, 描述, 价钱和库存
$cat items.txt 
101,HD Camcorder,Video,210,10
102,Refrigerator,Appliance,850,2
103,MP3 Player,Audio,270,15
104,Tennis Racket,Sports,190,20
105,Laser Printer,Office,475,5
						

源码3


# 这是一个销售数据,分别是id和1-6月的销售情况
$cat items-sold.txt
101 2 10 5 8 10 12
102 0 1 4 3 0 2
103 10 6 11 20 5 13
104 2 3 4 0 6 5
105 10 2 5 7 12 6
						

print

 
# 默认print就是打印文件全文到终端
$awk '{print}' source.txt
# 下面是通过,分割,输出第二段。$0表示全行,类似shell用法
$awk -F ',' '{print $2}' source.txt
Ian Bicking
Hakim El Hattab
Paul Irish
Addy Osmani
Chris Wanstrath
Mattt Thompson
Ask Solem Hoel
# or
$awk -F "," '{print $2}' source.txt
$awk -F, '{print $2}' source.txt
# 一个格式化更好看些的效果
awk -F ',' 'BEGIN \                         
{ print "-------------\nName\tComp\n-------------"} \
{ print $2,"\t",$3;} \  
END { print "-------------"; }' source.txt 
-------------
Name	Comp
-------------
Ian Bicking 	 Mozilla
Hakim El Hattab 	 Whim
Paul Irish 	 Google
Addy Osmani 	 Google
Chris Wanstrath 	 Github
Mattt Thompson 	 Heroku
Ask Solem Hoel 	 VMware
-------------
						

模式匹配


# 用逗号做分隔符, 打印第二和第三列
$awk -F ',' '/Whim/ {print $2, $3}' source.txt
Hakim El Hattab Whim
# 可以加点格式化语句
$awk -F ',' '/Whim/ {print "Whim\"s name:", $2}' source.txt
Whim"s name: Hakim El Hattab
						

awk内置变量 - FS


$awk -F ',' '{print $2, $3}' source.txt  
Ian Bicking Mozilla
Hakim El Hattab Whim
Paul Irish Google
Addy Osmani Google
Chris Wanstrath Github
Mattt Thompson Heroku
Ask Solem Hoel VMware
# 可以使用内置的FS - 输入字段分隔符 实现相同的功能
$awk 'BEGIN {FS=","} {print $2, $3}' source.txt
# 先看一个文件
$cat source-multiple-fs.txt 
101,Ian Bicking:Mozilla%
102,Hakim El Hattab:Whim%
103,Paul Irish:Google%
104,Addy Osmani:Google%
105,Chris Wanstrath:Github%
106,Mattt Thompson:Heroku%
107,Ask Solem Hoel:VMware%
# 发现上面的分隔符有三种:逗号分号和百分号,这样就可以这样使用
# awk 'BEGIN {FS="[,:%]"} {print $2, $3}' source-multiple-fs.txt
						

awk内置变量 - OFS


$awk -F ',' '{print $2, ":", $3}' source.txt 
Ian Bicking : Mozilla
Hakim El Hattab : Whim
Paul Irish : Google
Addy Osmani : Google
Chris Wanstrath : Github
Mattt Thompson : Heroku
Ask Solem Hoel : VMware
# 其实可以用内置的OFS - 输出字段分隔符
$awk -F ',' 'BEGIN { OFS=":" } { print $2, $3 }' source.txt
					

awk内置变量 - RS


$cat source-one-line.txt 
1,one:2,two:3,three:4,four
# 现在我想分割成(1,one),(2, two)这样的效果
$awk -F, '{print $2}' source-one-line.txt 
one:2
# 这个没有实现我想要的效果
# 使用RS - 记录分隔符, 他能帮你把单行内容先分割然后再按-F分割
$awk -F, 'BEGIN { RS=":" } { print $2 }' source-one-line.txt
one
two
three
four
						

awk内置变量 - ORS


# RS是输入, ORS就是输出
$awk 'BEGIN { FS=","; OFS="\n";ORS="\n---\n" } \
{print $1,$2,$3}' source.txt|head -8
101
Ian Bicking
Mozilla
---
102
Hakim El Hattab
Whim
---						
						

awk内置变量 - NR


# NR是记录的数目
$awk 'BEGIN {FS=","} \
{print "Emp Id of record number",NR,"is",$1;} \
END {print "Total number of records:",NR}' source.txt
Emp Id of record number 1 is 101
Emp Id of record number 2 is 102
Emp Id of record number 3 is 103
Emp Id of record number 4 is 104
Emp Id of record number 5 is 105
Emp Id of record number 6 is 106
Emp Id of record number 7 is 107
Total number of records: 7		
						

awk内置变量 - FILENAME,FNR


# FILENAME显示了当前文件, FNR关联到当前文件的记录数
awk 'BEGIN {FS=","} \
{print FILENAME ": record number",FNR,"is",$1;} \
END {print "Total number of records:",NR}' \
source.txt source-multiple-fs.txt
source.txt: record number 1 is 101
source.txt: record number 2 is 102
source.txt: record number 3 is 103
source.txt: record number 4 is 104
source.txt: record number 5 is 105
source.txt: record number 6 is 106
source.txt: record number 7 is 107
source-multiple-fs.txt: record number 1 is 101
source-multiple-fs.txt: record number 2 is 102
source-multiple-fs.txt: record number 3 is 103
source-multiple-fs.txt: record number 4 is 104
source-multiple-fs.txt: record number 5 is 105
source-multiple-fs.txt: record number 6 is 106
source-multiple-fs.txt: record number 7 is 107
Total number of records: 14
						

awk变量


# 变量支持数字,字符和下划线
# 这个文件多加了一列star数, 现在我想统计整个文件的star
$cat source-star.txt
101,Ian Bicking,Mozilla,1204
102,Hakim El Hattab,Whim,4029
103,Paul Irish,Google,7200
104,Addy Osmani,Google,2201
105,Chris Wanstrath,Github,1002
106,Mattt Thompson,Heroku,890
107,Ask Solem Hoel,VMware,2109
# 使用awk的变量,在begin的时候声明total,在body体里面
# 累加total值,在end里面打印
$cat total-star.awk 
BEGIN {
    FS=",";
    total=0; }
{
 print $2 "'s star is: " $4;
 total=total+$4
} END {
    print "---\nTotal star = *"total;
}
awk -f total-star.awk source-star.txt
Ian Bicking's star is: 1204
Hakim El Hattab's star is: 4029
Paul Irish's star is: 7200
Addy Osmani's star is: 2201
Chris Wanstrath's star is: 1002
Mattt Thompson's star is: 890
Ask Solem Hoel's star is: 2109
---
Total star = *18635
						

自增长/减少


# 可以使用++或者--,但是注意前后
$awk -F, '{print --$4}' source-star.txt
1203
4028
7199
2200
1001
889
2108
$awk -F, '{print $4--}' source-star.txt 
# 咦 竟然没有变
1204
4029
7200
2201
1002
890
2109
# 想达到--$4的目的就得这样
$awk -F ',' '{$4--; print $4}' source-star.txt
1203
4028
7199
2200
1001
889
2108
						

字符串操作


$cat string.awk
BEGIN {
    FS=",";
    OFS=",";
    string1="GO";
    string2="OGLE";
    numberstring="100";
    string3=string1 string2;
    print "Concatenate string is:" string3;
    numberstring=numberstring+1;
    print "String to number:" numberstring;
}
# 字符串会直接相连, 字符串相加会自动转化成数字相加
$awk -f string.awk 
Concatenate string is:GOOGLE
String to number:101
							
						

复合运算


$cat assignment.awk
BEGIN {
 FS=",";
 OFS=",";
 total1 = total2 = total3 = total4 = total5 = 10;
 total1 += 5; print total1;
 total2 -= 5; print total2;
 total3 *= 5; print total3;
 total4 /= 5; print total4;
 total5 %= 5; print total5;
}
$awk -f assignment.awk
15
5
50
2
0							
						

比较操作


# 只会显示小于1005的行
$awk -F "," '$4 <= 1005' source-star.txt
105,Chris Wanstrath,Github,1002
106,Mattt Thompson,Heroku,890
$awk -F "," '$1 == 103 {print $2}' source-star.txt 
Paul Irish
# 你也可以加多个条件 这里||表示或者  && 表示和
$awk -F "," '$4 > 3000 || $4 <= 880 {print $2}' source-star.txt
Hakim El Hattab
Paul Irish	
						

正则


# ~ 表示匹配, !~ 表示不匹配
$awk -F "," '$3 ~ "Github"' source.txt
105,Chris Wanstrath,Github
$awk -F "," '$3 !~ "Google"' source.txt
101,Ian Bicking,Mozilla
102,Hakim El Hattab,Whim
105,Chris Wanstrath,Github
106,Mattt Thompson,Heroku
107,Ask Solem Hoel,VMware
# NF是分割项数目, $NF表示最后一个分割项, 这里是找最后一个分割项是/bin/sh的就会累加n
$awk -F ':' '$NF ~ /\/bin\/sh/ { n++ }; END { print n \
}' /etc/passwd
						

if语法


if (conditional-expression)
    action
	
if (conditional-expression)
{
action1;
action2; }
						

例子


# 和上面的一个例子一样
$awk -F "," '{ if ($3 ~ "Github") print $0}' source.txt
105,Chris Wanstrath,Github
						

if else语法


if (conditional-expression)
    action1
else
    action2
# or
conditional-expression ? action1 : action2 ;
						

例子


# 打印单行因为%2,奇数取余
$awk 'ORS=NR%2?",":"\n"' source.txt                    
101,Ian Bicking,Mozilla,102,Hakim El Hattab,Whim
103,Paul Irish,Google,104,Addy Osmani,Google
105,Chris Wanstrath,Github,106,Mattt Thompson,Heroku
107,Ask Solem Hoel,VMware,
						

while语法


while(condition)
    actions
						

例子


# 把第二列和其之后的每列加起来
$cat while.awk 
{
    i=2; total=0;
    while (i <= NF) {
        total = total + $i;
        i++;
 }
    print "Item", $1, ":", total, "quantities sold";
}
$awk -f while.awk items-sold.txt
Item 101 : 47 quantities sold
Item 102 : 10 quantities sold
Item 103 : 65 quantities sold
Item 104 : 20 quantities sold
Item 105 : 42 quantities sold
						

do while语法


# do while至少会执行一次
do
action
while(condition)
						

例子


# 用do-while方法实现上一次的例子
$cat dowhile.awk 
{
    i=2; total=0;
 do
 {
     total = total + $i;
     i++;
 } while (i <= NF)
 print "Item", $1, ":", total, "quantities sold";
}
$awk -f dowhile.awk items-sold.txt
Item 101 : 47 quantities sold
Item 102 : 10 quantities sold
Item 103 : 65 quantities sold
Item 104 : 20 quantities sold
Item 105 : 42 quantities sold
						

for语法


for(initialization;condition;increment/decrement)
actions
						

例子


$echo "1 2 3 4" | awk '{ for (i = 1; i <= NF; i++) total = total+$i }; \
END { print total }'  
10
# 再来个for版本的例子
$cat for.awk 
{
    total=0;
    for (i=2; i <= NF; i++)
        total = total + $i;
    print "Item", $1, ":", total, "quantities sold";
}
$awk -f for.awk items-sold.txt
Item 101 : 47 quantities sold
Item 102 : 10 quantities sold
Item 103 : 65 quantities sold
Item 104 : 20 quantities sold
Item 105 : 42 quantities sold
						

break,continue,exit


# 程序一直运行打印Iteration,并且累加x,直到x等于10停止程序-break
$ awk 'BEGIN{
x=1;
while(1)
{
print "Iteration";
if ( x==10 )
break;
x++;
}}'
# x从1到10, 如果x等于5 直接直接累加x而不打印
$awk 'BEGIN{
x=1;
while(x<=10)
{
if(x==5){
x++;
continue;
}
print "Value of x",x;x++;
}
}'
# x从1到10,当x等于5的时候程序直接退出
$awk 'BEGIN{
x=1;
while(x<=10)
{
if(x==5){
exit;}
print "Value of x",x;x++;
}
}'
						

关联数组


# awk 的关联数组中item[101]和item["101"]意义一样
$awk 'BEGIN { item[101]="Github"; print item["101"]}' 
Github
# 可以用in检验是否包含本项
$awk 'BEGIN { item[101]="a"; if ( 101 in item ) print "Has 101"}'
Has 101
# 还可以使用for循环读取列表
$cat array-for-loop.awk
BEGIN {
    item[101]="Github";
    item[21]="Google";
    for (x in item)
        print item[x];
}
$awk -f array-for-loop.awk
Github
Google
# 多维数组, delete可以删除元素.PS item[2,1]这样的格式有问题
# 因为会被翻译成2#2("2\0342"),假设要设置分隔符可以使用SUBSEP=",";
$awk 'BEGIN { item["1,1"]="Github"; item["1,2"]="Google"; \
item["2,1"]="Whim"; delete item["2,1"];
for (x in item)
print "Index",x,"contains",item[x];}'
Index 1,1 contains Github
Index 1,2 contains Google

						

数组排序


# 这里需要gnu awk了 使用了asort排序
$cat asort.awk 
BEGIN {
 item[101]="Github";
 item[22]="Whim";
 item[50]="Google";
 print "------Before asort------"
 for (x in item)
     print "Index",x,"contains",item[x];
 total = asort(item);
 print "------After asort------"
 for (x in item)
     print "Index",x,"contains",item[x];
}

$gawk -f asort.awk
------Before asort------
Index 22 contains Whim
Index 50 contains Google
Index 101 contains Github
------After asort------
Index 1 contains Github
Index 2 contains Google
Index 3 contains Whim
# 大家请注意上面的例子,排序后已经忘记了原来item的index位置
# 而asorti可以帮助你记录这个位置
$cat asorti.awk
BEGIN {
 item[101]="Github";
 item[22]="Whim";
 item[50]="Google";
 print "----- Function: asort -----"
 total = asort(item,itemdesc);
 for (i=1; i<= total; i++)
    print "Index",i,"contains",itemdesc[i];
 print "----- Function: asorti -----"
 total = asorti(item,itemabbr);
 for (i=1; i<= total; i++)
     print "Index",i,"contains",itemabbr[i];
}
$gawk -f asorti.awk
----- Function: asort -----
Index 1 contains Github
Index 2 contains Google
Index 3 contains Whim
----- Function: asorti -----
Index 1 contains 101
Index 2 contains 22
Index 3 contains 50
						

格式化打印


# \n是换行
$awk 'BEGIN { printf "Line 1\nLine 2\n" }'
Line 1
Line 2
# \t是tab
$awk 'BEGIN \
{ printf "Field 1\t\tField 2\tField 3\tField 4\n" }'
Field 1		Field 2	Field 3	Field 4
# \v是垂直tab
$awk 'BEGIN \
{ printf "Field 1\vField 2\vField 3\vField 4\n" }'
Field 1
    Field 2
       Field 3
	  Field 4
# %s字符串; %c单个字符; %d数字; %f浮点数......
$cat printf-width.awk 
BEGIN {
FS=","
printf "%3s\t%10s\t%10s\t%5s\t%3s\n",
    "Num","Description","Type","Price","Qty"
printf "-----------------------------------------------------\n"
}
{
    printf "%3d\t%10s\t%10s\t%g\t%d\n", $1,$2,$3,$4,$5
}
awk -f printf-width.awk items.txt 
Num	Description	      Type	Price	Qty
-----------------------------------------------------
101	HD Camcorder	     Video	210	10
102	Refrigerator	 Appliance	850	2
103	MP3 Player	     Audio	270	15
104	Tennis Racket	    Sports	190	20
105	Laser Printer	    Office	475	5
							

内置函数


# int - 将数字转换成整形, 类似的函数还有sqrt, sin, cos...
$awk 'BEGIN {print int(4.1);print int(-6.22);print int(strings)}'
4
-6
0
# rand - 随机0-1的数字; srand -初始化随机数的初始值
$cat srand.awk 
BEGIN {
    srand(5);
    count=0;
    max=30;
    while (count < 5) {
        # 随机数范围为5-30
        rnd = int(rand() * max);
        print rnd;
        count++;
    }
}
# 使用osx的awk随机范围不对
$gawk -f srand.awk
19
9
21
8
13
# index - 所查字符在字符串中的位置,没找到会返回0
awk 'BEGIN{str="This is a test"; print index(str, "a"); print index(str, "y")}'
9
0
# length - 字符串的长度
$awk -F, '{print length($0)}' source.txt
23
24
21
22
26
25
25
# split - 分片 PS:使用awk分片的顺序有问题;
# split第一个参数是要分割的内容,第二个是分割后的结果保存的数组,第三个是使用的分隔符
$echo "101 arg1:arg2:arg3"|gawk '{split($2,out,":"); for (x in out) print out[x];}'
arg1
arg2
arg3
# substr - 取字符串范围内容;
# 第一个参数是要取的内容, 第二个是开始位置(从1开始),第三个是要取的长度
$echo "This is test"|awk '{print substr($3,2,2);}'
es
# sub - 替换原来的字符串,但是只替换第一个符合项; gsub - 替换全部选择项
$awk 'BEGIN{str="ThIs is test"; sub("[Ii]s","e", str); print str;}'
The is test
$awk 'BEGIN{str="ThIs is test"; gsub("[Ii]s","e", str); print str;}'
The e test
# match - 返回某子字符串是否匹配了某字符串;
# RSTART - awk 自带变量返回匹配的开始位置
# RLENGTH - awk 自带变量返回匹配串的长度
$awk 'BEGIN{str="This is test"; if (match(str, "test")) {print substr(str,RSTART,RLENGTH)}}'  
# tolower/toupper - 把字符串都变成小写/大写
$awk 'BEGIN{str="This is test"; print tolower(str); print toupper(str);}'
this is test
THIS IS TEST
# ARGC - 参数的数量; ARGV参数的数组
$cat arguments.awk
BEGIN {
    print "ARGC=",ARGC
    for (i = 0; i < ARGC; i++)
  print ARGV[i]
}
							

内置变量


# ENVIRON - 系统环境变量
$cat environ.awk
BEGIN {
 OFS="="
 for(x in ENVIRON)
     print x,ENVIRON[x];
}
# IGNORECASE - 设置为1 忽略大小写
$gawk 'BEGIN{IGNORECASE=1} /github/{print}' source.txt
105,Chris Wanstrath,Github
						

位运算


$cat bits.awk
BEGIN {
 number1=15
 number2=25
 print "AND: " and(number1,number2);
 print "OR: " or(number1,number2)
 print "XOR: " xor(number1,number2)
 print "LSHIFT: " lshift(number1,2)
 print "RSHIFT: " rshift(number1,2)
}
$gawk -f bits.awk
AND: 9
OR: 31
XOR: 22
LSHIFT: 60
RSHIFT: 3					
						

自定义函数语法


function fn-name(parameters)
{
 function-body
}
						

例子


# 函数的位置不重要
$cat function-debug.awk 
function mydebug (message) {
    print ("Debug Time:" strftime("%a %b %d %H:%M:%S %Z %Y", systime()))
    print (message)
}
{
    mydebug($NF)
}
$gawk -f function-debug.awk source.txt
Debug Time:Wed Dec 11 22:14:43 CST 2013
Bicking,Mozilla
Debug Time:Wed Dec 11 22:14:43 CST 2013
Hattab,Whim
Debug Time:Wed Dec 11 22:14:43 CST 2013
Irish,Google
Debug Time:Wed Dec 11 22:14:43 CST 2013
Osmani,Google
Debug Time:Wed Dec 11 22:14:43 CST 2013
Wanstrath,Github
Debug Time:Wed Dec 11 22:14:43 CST 2013
Thompson,Heroku
Debug Time:Wed Dec 11 22:14:43 CST 2013
Hoel,VMware
						

系统调用


# 使用system函数可以调用shell命令
$awk 'BEGIN { system("date") }'
Wed Dec 11 22:24:27 CST 2013
# systime 和 strftime上面见过了.处理时间和格式化时间
$gawk 'BEGIN { print strftime("%c",systime()) }'
Wed Dec 11 22:25:32 2013
						

(四)awk高级话题

getline


# awk首先读入一行,接着处理getline函数再获得一行....下面显示的就是奇数行
$awk -F"," '{print $0;getline;}' source.txt 
101,Ian Bicking,Mozilla
103,Paul Irish,Google
105,Chris Wanstrath,Github
107,Ask Solem Hoel,VMware
# 我们使用getline 并把这行变量赋值给tmp
$awk -F, '{getline tmp; print "$0->", $0; print "tmp->", tmp;}' source.txt
$0-> 101,Ian Bicking,Mozilla
tmp-> 102,Hakim El Hattab,Whim
$0-> 103,Paul Irish,Google
tmp-> 104,Addy Osmani,Google
$0-> 105,Chris Wanstrath,Github
tmp-> 106,Mattt Thompson,Heroku
$0-> 107,Ask Solem Hoel,VMware
tmp-> 106,Mattt Thompson,Heroku
# 执行外部程序, close可关闭管道,比如这里必须是`|getline`之前的命令
$awk 'BEGIN{"date"| getline;close("date");print "Timestamp:" $0}'
Timestamp:Wed Dec 11 22:41:52 CST 2013
# or
$awk 'BEGIN{"date"| getline timestamp;close("date");print "Timestamp:" timestamp}'
Timestamp:Wed Dec 11 22:44:08 CST 2013
						

「谢谢」

================================================ FILE: lib/css/zenburn.css ================================================ /* Zenburn style from voldmar.ru (c) Vladimir Epifanov based on dark.css by Ivan Sagalaev */ pre code { display: block; padding: 0.5em; background: #3F3F3F; color: #DCDCDC; } pre .keyword, pre .tag, pre .django .tag, pre .django .keyword, pre .css .class, pre .css .id, pre .lisp .title { color: #E3CEAB; } pre .django .template_tag, pre .django .variable, pre .django .filter .argument { color: #DCDCDC; } pre .number, pre .date { color: #8CD0D3; } pre .dos .envvar, pre .dos .stream, pre .variable, pre .apache .sqbracket { color: #EFDCBC; } pre .dos .flow, pre .diff .change, pre .python .exception, pre .python .built_in, pre .literal, pre .tex .special { color: #EFEFAF; } pre .diff .chunk, pre .ruby .subst { color: #8F8F8F; } pre .dos .keyword, pre .python .decorator, pre .class .title, pre .haskell .label, pre .function .title, pre .ini .title, pre .diff .header, pre .ruby .class .parent, pre .apache .tag, pre .nginx .built_in, pre .tex .command, pre .input_number { color: #efef8f; } pre .dos .winutils, pre .ruby .symbol, pre .ruby .symbol .string, pre .ruby .symbol .keyword, pre .ruby .symbol .keymethods, pre .ruby .string, pre .ruby .instancevar { color: #DCA3A3; } pre .diff .deletion, pre .string, pre .tag .value, pre .preprocessor, pre .built_in, pre .sql .aggregate, pre .javadoc, pre .smalltalk .class, pre .smalltalk .localvars, pre .smalltalk .array, pre .css .rules .value, pre .attr_selector, pre .pseudo, pre .apache .cbracket, pre .tex .formula { color: #CC9393; } pre .shebang, pre .diff .addition, pre .comment, pre .java .annotation, pre .template_comment, pre .pi, pre .doctype { color: #7F9F7F; } pre .xml .css, pre .xml .javascript, pre .xml .vbscript, pre .tex .formula { opacity: 0.5; } ================================================ FILE: lib/font/league_gothic_license ================================================ SIL Open Font License (OFL) http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL ================================================ FILE: lib/js/classList.js ================================================ /*! @source http://purl.eligrey.com/github/classList.js/blob/master/classList.js*/ if(typeof document!=="undefined"&&!("classList" in document.createElement("a"))){(function(j){var a="classList",f="prototype",m=(j.HTMLElement||j.Element)[f],b=Object,k=String[f].trim||function(){return this.replace(/^\s+|\s+$/g,"")},c=Array[f].indexOf||function(q){var p=0,o=this.length;for(;p"}while(y.length||z.length){var v=u().splice(0,1)[0];w+=m(x.substr(r,v.offset-r));r=v.offset;if(v.event=="start"){w+=s(v.node);t.push(v.node)}else{if(v.event=="stop"){var q=t.length;do{q--;var p=t[q];w+=("")}while(p!=v.node);t.splice(q,1);while(q'+m(L[0])+""}else{N+=m(L[0])}P=O.lR.lastIndex;L=O.lR.exec(M)}N+=m(M.substr(P,M.length-P));return N}function K(r,M){if(M.sL&&d[M.sL]){var L=e(M.sL,r);t+=L.keyword_count;return L.value}else{return F(r,M)}}function I(M,r){var L=M.cN?'':"";if(M.rB){q+=L;M.buffer=""}else{if(M.eB){q+=m(r)+L;M.buffer=""}else{q+=L;M.buffer=r}}C.push(M);B+=M.r}function E(O,L,Q){var R=C[C.length-1];if(Q){q+=K(R.buffer+O,R);return false}var M=z(L,R);if(M){q+=K(R.buffer+O,R);I(M,L);return M.rB}var r=w(C.length-1,L);if(r){var N=R.cN?"":"";if(R.rE){q+=K(R.buffer+O,R)+N}else{if(R.eE){q+=K(R.buffer+O,R)+N+m(L)}else{q+=K(R.buffer+O+L,R)+N}}while(r>1){N=C[C.length-2].cN?"":"";q+=N;r--;C.length--}var P=C[C.length-1];C.length--;C[C.length-1].buffer="";if(P.starts){I(P.starts,"")}return R.rE}if(x(L,R)){throw"Illegal"}}var H=d[J];var C=[H.dM];var B=0;var t=0;var q="";try{var v=0;H.dM.buffer="";do{var y=s(D,v);var u=E(y[0],y[1],y[2]);v+=y[0].length;if(!u){v+=y[1].length}}while(!y[2]);if(C.length>1){throw"Illegal"}return{r:B,keyword_count:t,value:q}}catch(G){if(G=="Illegal"){return{r:0,keyword_count:0,value:m(D)}}else{throw G}}}function f(t){var r={keyword_count:0,r:0,value:m(t)};var q=r;for(var p in d){if(!d.hasOwnProperty(p)){continue}var s=e(p,t);s.language=p;if(s.keyword_count+s.r>q.keyword_count+q.r){q=s}if(s.keyword_count+s.r>r.keyword_count+r.r){q=r;r=s}}if(q.language){r.second_best=q}return r}function h(r,q,p){if(q){r=r.replace(/^((<[^>]+>|\t)+)/gm,function(t,w,v,u){return w.replace(/\t/g,q)})}if(p){r=r.replace(/\n/g,"
")}return r}function o(u,x,q){var y=g(u,q);var s=a(u);if(s=="no-highlight"){return}if(s){var w=e(s,y)}else{var w=f(y);s=w.language}var p=b(u);if(p.length){var r=document.createElement("pre");r.innerHTML=w.value;w.value=l(p,b(r),y)}w.value=h(w.value,x,q);var t=u.className;if(!t.match("(\\s|^)(language-)?"+s+"(\\s|$)")){t=t?(t+" "+s):s}if(/MSIE [678]/.test(navigator.userAgent)&&u.tagName=="CODE"&&u.parentNode.tagName=="PRE"){var r=u.parentNode;var v=document.createElement("div");v.innerHTML="
"+w.value+"
";u=v.firstChild.firstChild;v.firstChild.cN=r.cN;r.parentNode.replaceChild(v.firstChild,r)}else{u.innerHTML=w.value}u.className=t;u.result={language:s,kw:w.keyword_count,re:w.r};if(w.second_best){u.second_best={language:w.second_best.language,kw:w.second_best.keyword_count,re:w.second_best.r}}}function k(){if(k.called){return}k.called=true;var r=document.getElementsByTagName("pre");for(var p=0;p|>=|>>|>>=|>>>|>>>=|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~";this.BE={b:"\\\\.",r:0};this.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[this.BE],r:0};this.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[this.BE],r:0};this.CLCM={cN:"comment",b:"//",e:"$"};this.CBLCLM={cN:"comment",b:"/\\*",e:"\\*/"};this.HCM={cN:"comment",b:"#",e:"$"};this.NM={cN:"number",b:this.NR,r:0};this.CNM={cN:"number",b:this.CNR,r:0};this.inherit=function(p,s){var r={};for(var q in p){r[q]=p[q]}if(s){for(var q in s){r[q]=s[q]}}return r}}();hljs.LANGUAGES.cs={dM:{k:{"abstract":1,as:1,base:1,bool:1,"break":1,"byte":1,"case":1,"catch":1,"char":1,checked:1,"class":1,"const":1,"continue":1,decimal:1,"default":1,delegate:1,"do":1,"do":1,"double":1,"else":1,"enum":1,event:1,explicit:1,extern:1,"false":1,"finally":1,fixed:1,"float":1,"for":1,foreach:1,"goto":1,"if":1,implicit:1,"in":1,"int":1,"interface":1,internal:1,is:1,lock:1,"long":1,namespace:1,"new":1,"null":1,object:1,operator:1,out:1,override:1,params:1,"private":1,"protected":1,"public":1,readonly:1,ref:1,"return":1,sbyte:1,sealed:1,"short":1,sizeof:1,stackalloc:1,"static":1,string:1,struct:1,"switch":1,"this":1,"throw":1,"true":1,"try":1,"typeof":1,uint:1,ulong:1,unchecked:1,unsafe:1,ushort:1,using:1,virtual:1,"volatile":1,"void":1,"while":1,ascending:1,descending:1,from:1,get:1,group:1,into:1,join:1,let:1,orderby:1,partial:1,select:1,set:1,value:1,"var":1,where:1,yield:1},c:[{cN:"comment",b:"///",e:"$",rB:true,c:[{cN:"xmlDocTag",b:"///|"},{cN:"xmlDocTag",b:""}]},hljs.CLCM,hljs.CBLCLM,{cN:"string",b:'@"',e:'"',c:[{b:'""'}]},hljs.ASM,hljs.QSM,hljs.CNM]}};hljs.LANGUAGES.ruby=function(){var g="[a-zA-Z_][a-zA-Z0-9_]*(\\!|\\?)?";var a="[a-zA-Z_]\\w*[!?=]?|[-+~]\\@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?";var n={keyword:{and:1,"false":1,then:1,defined:1,module:1,"in":1,"return":1,redo:1,"if":1,BEGIN:1,retry:1,end:1,"for":1,"true":1,self:1,when:1,next:1,until:1,"do":1,begin:1,unless:1,END:1,rescue:1,nil:1,"else":1,"break":1,undef:1,not:1,"super":1,"class":1,"case":1,require:1,yield:1,alias:1,"while":1,ensure:1,elsif:1,or:1,def:1},keymethods:{__id__:1,__send__:1,abort:1,abs:1,"all?":1,allocate:1,ancestors:1,"any?":1,arity:1,assoc:1,at:1,at_exit:1,autoload:1,"autoload?":1,"between?":1,binding:1,binmode:1,"block_given?":1,call:1,callcc:1,caller:1,capitalize:1,"capitalize!":1,casecmp:1,"catch":1,ceil:1,center:1,chomp:1,"chomp!":1,chop:1,"chop!":1,chr:1,"class":1,class_eval:1,"class_variable_defined?":1,class_variables:1,clear:1,clone:1,close:1,close_read:1,close_write:1,"closed?":1,coerce:1,collect:1,"collect!":1,compact:1,"compact!":1,concat:1,"const_defined?":1,const_get:1,const_missing:1,const_set:1,constants:1,count:1,crypt:1,"default":1,default_proc:1,"delete":1,"delete!":1,delete_at:1,delete_if:1,detect:1,display:1,div:1,divmod:1,downcase:1,"downcase!":1,downto:1,dump:1,dup:1,each:1,each_byte:1,each_index:1,each_key:1,each_line:1,each_pair:1,each_value:1,each_with_index:1,"empty?":1,entries:1,eof:1,"eof?":1,"eql?":1,"equal?":1,"eval":1,exec:1,exit:1,"exit!":1,extend:1,fail:1,fcntl:1,fetch:1,fileno:1,fill:1,find:1,find_all:1,first:1,flatten:1,"flatten!":1,floor:1,flush:1,for_fd:1,foreach:1,fork:1,format:1,freeze:1,"frozen?":1,fsync:1,getc:1,gets:1,global_variables:1,grep:1,gsub:1,"gsub!":1,"has_key?":1,"has_value?":1,hash:1,hex:1,id:1,include:1,"include?":1,included_modules:1,index:1,indexes:1,indices:1,induced_from:1,inject:1,insert:1,inspect:1,instance_eval:1,instance_method:1,instance_methods:1,"instance_of?":1,"instance_variable_defined?":1,instance_variable_get:1,instance_variable_set:1,instance_variables:1,"integer?":1,intern:1,invert:1,ioctl:1,"is_a?":1,isatty:1,"iterator?":1,join:1,"key?":1,keys:1,"kind_of?":1,lambda:1,last:1,length:1,lineno:1,ljust:1,load:1,local_variables:1,loop:1,lstrip:1,"lstrip!":1,map:1,"map!":1,match:1,max:1,"member?":1,merge:1,"merge!":1,method:1,"method_defined?":1,method_missing:1,methods:1,min:1,module_eval:1,modulo:1,name:1,nesting:1,"new":1,next:1,"next!":1,"nil?":1,nitems:1,"nonzero?":1,object_id:1,oct:1,open:1,pack:1,partition:1,pid:1,pipe:1,pop:1,popen:1,pos:1,prec:1,prec_f:1,prec_i:1,print:1,printf:1,private_class_method:1,private_instance_methods:1,"private_method_defined?":1,private_methods:1,proc:1,protected_instance_methods:1,"protected_method_defined?":1,protected_methods:1,public_class_method:1,public_instance_methods:1,"public_method_defined?":1,public_methods:1,push:1,putc:1,puts:1,quo:1,raise:1,rand:1,rassoc:1,read:1,read_nonblock:1,readchar:1,readline:1,readlines:1,readpartial:1,rehash:1,reject:1,"reject!":1,remainder:1,reopen:1,replace:1,require:1,"respond_to?":1,reverse:1,"reverse!":1,reverse_each:1,rewind:1,rindex:1,rjust:1,round:1,rstrip:1,"rstrip!":1,scan:1,seek:1,select:1,send:1,set_trace_func:1,shift:1,singleton_method_added:1,singleton_methods:1,size:1,sleep:1,slice:1,"slice!":1,sort:1,"sort!":1,sort_by:1,split:1,sprintf:1,squeeze:1,"squeeze!":1,srand:1,stat:1,step:1,store:1,strip:1,"strip!":1,sub:1,"sub!":1,succ:1,"succ!":1,sum:1,superclass:1,swapcase:1,"swapcase!":1,sync:1,syscall:1,sysopen:1,sysread:1,sysseek:1,system:1,syswrite:1,taint:1,"tainted?":1,tell:1,test:1,"throw":1,times:1,to_a:1,to_ary:1,to_f:1,to_hash:1,to_i:1,to_int:1,to_io:1,to_proc:1,to_s:1,to_str:1,to_sym:1,tr:1,"tr!":1,tr_s:1,"tr_s!":1,trace_var:1,transpose:1,trap:1,truncate:1,"tty?":1,type:1,ungetc:1,uniq:1,"uniq!":1,unpack:1,unshift:1,untaint:1,untrace_var:1,upcase:1,"upcase!":1,update:1,upto:1,"value?":1,values:1,values_at:1,warn:1,write:1,write_nonblock:1,"zero?":1,zip:1}};var h={cN:"yardoctag",b:"@[A-Za-z]+"};var d={cN:"comment",b:"#",e:"$",c:[h]};var c={cN:"comment",b:"^\\=begin",e:"^\\=end",c:[h],r:10};var b={cN:"comment",b:"^__END__",e:"\\n$"};var u={cN:"subst",b:"#\\{",e:"}",l:g,k:n};var p=[hljs.BE,u];var s={cN:"string",b:"'",e:"'",c:p,r:0};var r={cN:"string",b:'"',e:'"',c:p,r:0};var q={cN:"string",b:"%[qw]?\\(",e:"\\)",c:p,r:10};var o={cN:"string",b:"%[qw]?\\[",e:"\\]",c:p,r:10};var m={cN:"string",b:"%[qw]?{",e:"}",c:p,r:10};var l={cN:"string",b:"%[qw]?<",e:">",c:p,r:10};var k={cN:"string",b:"%[qw]?/",e:"/",c:p,r:10};var j={cN:"string",b:"%[qw]?%",e:"%",c:p,r:10};var i={cN:"string",b:"%[qw]?-",e:"-",c:p,r:10};var t={cN:"string",b:"%[qw]?\\|",e:"\\|",c:p,r:10};var e={cN:"function",b:"\\bdef\\s+",e:" |$|;",l:g,k:n,c:[{cN:"title",b:a,l:g,k:n},{cN:"params",b:"\\(",e:"\\)",l:g,k:n},d,c,b]};var f={cN:"identifier",b:g,l:g,k:n,r:0};var v=[d,c,b,s,r,q,o,m,l,k,j,i,t,{cN:"class",b:"\\b(class|module)\\b",e:"$|;",k:{"class":1,module:1},c:[{cN:"title",b:"[A-Za-z_]\\w*(::\\w+)*(\\?|\\!)?",r:0},{cN:"inheritance",b:"<\\s*",c:[{cN:"parent",b:"("+hljs.IR+"::)?"+hljs.IR}]},d,c,b]},e,{cN:"constant",b:"(::)?([A-Z]\\w*(::)?)+",r:0},{cN:"symbol",b:":",c:[s,r,q,o,m,l,k,j,i,t,f],r:0},{cN:"number",b:"(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b",r:0},{cN:"number",b:"\\?\\w"},{cN:"variable",b:"(\\$\\W)|((\\$|\\@\\@?)(\\w+))"},f,{b:"("+hljs.RSR+")\\s*",c:[d,c,b,{cN:"regexp",b:"/",e:"/[a-z]*",i:"\\n",c:[hljs.BE]}],r:0}];u.c=v;e.c[1].c=v;return{dM:{l:g,k:n,c:v}}}();hljs.LANGUAGES.javascript={dM:{k:{keyword:{"in":1,"if":1,"for":1,"while":1,"finally":1,"var":1,"new":1,"function":1,"do":1,"return":1,"void":1,"else":1,"break":1,"catch":1,"instanceof":1,"with":1,"throw":1,"case":1,"default":1,"try":1,"this":1,"switch":1,"continue":1,"typeof":1,"delete":1},literal:{"true":1,"false":1,"null":1}},c:[hljs.ASM,hljs.QSM,hljs.CLCM,hljs.CBLCLM,hljs.CNM,{b:"("+hljs.RSR+"|case|return|throw)\\s*",k:{"return":1,"throw":1,"case":1},c:[hljs.CLCM,hljs.CBLCLM,{cN:"regexp",b:"/",e:"/[gim]*",c:[{b:"\\\\/"}]}],r:0},{cN:"function",b:"\\bfunction\\b",e:"{",k:{"function":1},c:[{cN:"title",b:"[A-Za-z$_][0-9A-Za-z$_]*"},{cN:"params",b:"\\(",e:"\\)",c:[hljs.ASM,hljs.QSM,hljs.CLCM,hljs.CBLCLM]}]}]}};hljs.LANGUAGES.css=function(){var a={cN:"function",b:hljs.IR+"\\(",e:"\\)",c:[{eW:true,eE:true,c:[hljs.NM,hljs.ASM,hljs.QSM]}]};return{cI:true,dM:{i:"[=/|']",c:[hljs.CBLCLM,{cN:"id",b:"\\#[A-Za-z0-9_-]+"},{cN:"class",b:"\\.[A-Za-z0-9_-]+",r:0},{cN:"attr_selector",b:"\\[",e:"\\]",i:"$"},{cN:"pseudo",b:":(:)?[a-zA-Z0-9\\_\\-\\+\\(\\)\\\"\\']+"},{cN:"at_rule",b:"@(font-face|page)",l:"[a-z-]+",k:{"font-face":1,page:1}},{cN:"at_rule",b:"@",e:"[{;]",eE:true,k:{"import":1,page:1,media:1,charset:1},c:[a,hljs.ASM,hljs.QSM,hljs.NM]},{cN:"tag",b:hljs.IR,r:0},{cN:"rules",b:"{",e:"}",i:"[^\\s]",r:0,c:[hljs.CBLCLM,{cN:"rule",b:"[^\\s]",rB:true,e:";",eW:true,c:[{cN:"attribute",b:"[A-Z\\_\\.\\-]+",e:":",eE:true,i:"[^\\s]",starts:{cN:"value",eW:true,eE:true,c:[a,hljs.NM,hljs.QSM,hljs.ASM,hljs.CBLCLM,{cN:"hexcolor",b:"\\#[0-9A-F]+"},{cN:"important",b:"!important"}]}}]}]}]}}}();hljs.LANGUAGES.xml=function(){var b="[A-Za-z0-9\\._:-]+";var a={eW:true,c:[{cN:"attribute",b:b,r:0},{b:'="',rB:true,e:'"',c:[{cN:"value",b:'"',eW:true}]},{b:"='",rB:true,e:"'",c:[{cN:"value",b:"'",eW:true}]},{b:"=",c:[{cN:"value",b:"[^\\s/>]+"}]}]};return{cI:true,dM:{c:[{cN:"pi",b:"<\\?",e:"\\?>",r:10},{cN:"doctype",b:"",r:10,c:[{b:"\\[",e:"\\]"}]},{cN:"comment",b:"",r:10},{cN:"cdata",b:"<\\!\\[CDATA\\[",e:"\\]\\]>",r:10},{cN:"tag",b:"",k:{title:{style:1}},c:[a],starts:{cN:"css",e:"",rE:true,sL:"css"}},{cN:"tag",b:"",k:{title:{script:1}},c:[a],starts:{cN:"javascript",e:"<\/script>",rE:true,sL:"javascript"}},{cN:"vbscript",b:"<%",e:"%>",sL:"vbscript"},{cN:"tag",b:"",c:[{cN:"title",b:"[^ />]+"},a]}]}}}();hljs.LANGUAGES.java={dM:{k:{"false":1,"synchronized":1,"int":1,"abstract":1,"float":1,"private":1,"char":1,"interface":1,"boolean":1,"static":1,"null":1,"if":1,"const":1,"for":1,"true":1,"while":1,"long":1,"throw":1,strictfp:1,"finally":1,"protected":1,"extends":1,"import":1,"native":1,"final":1,"implements":1,"return":1,"void":1,"enum":1,"else":1,"break":1,"transient":1,"new":1,"catch":1,"instanceof":1,"byte":1,"super":1,"class":1,"volatile":1,"case":1,assert:1,"short":1,"package":1,"default":1,"double":1,"public":1,"try":1,"this":1,"switch":1,"continue":1,"throws":1},c:[{cN:"javadoc",b:"/\\*\\*",e:"\\*/",c:[{cN:"javadoctag",b:"@[A-Za-z]+"}],r:10},hljs.CLCM,hljs.CBLCLM,hljs.ASM,hljs.QSM,{cN:"class",b:"(class |interface )",e:"{",k:{"class":1,"interface":1},i:":",c:[{b:"(implements|extends)",k:{"extends":1,"implements":1},r:10},{cN:"title",b:hljs.UIR}]},hljs.CNM,{cN:"annotation",b:"@[A-Za-z]+"}]}};hljs.LANGUAGES.php={cI:true,dM:{k:{and:1,include_once:1,list:1,"abstract":1,global:1,"private":1,echo:1,"interface":1,as:1,"static":1,endswitch:1,array:1,"null":1,"if":1,endwhile:1,or:1,"const":1,"for":1,endforeach:1,self:1,"var":1,"while":1,isset:1,"public":1,"protected":1,exit:1,foreach:1,"throw":1,elseif:1,"extends":1,include:1,__FILE__:1,empty:1,require_once:1,"function":1,"do":1,xor:1,"return":1,"implements":1,parent:1,clone:1,use:1,__CLASS__:1,__LINE__:1,"else":1,"break":1,print:1,"eval":1,"new":1,"catch":1,__METHOD__:1,"class":1,"case":1,exception:1,php_user_filter:1,"default":1,die:1,require:1,__FUNCTION__:1,enddeclare:1,"final":1,"try":1,"this":1,"switch":1,"continue":1,endfor:1,endif:1,declare:1,unset:1,"true":1,"false":1,namespace:1},c:[hljs.CLCM,hljs.HCM,{cN:"comment",b:"/\\*",e:"\\*/",c:[{cN:"phpdoc",b:"\\s@[A-Za-z]+",r:10}]},hljs.CNM,hljs.inherit(hljs.ASM,{i:null}),hljs.inherit(hljs.QSM,{i:null}),{cN:"variable",b:"\\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*"},{cN:"preprocessor",b:"<\\?php",r:10},{cN:"preprocessor",b:"\\?>"}]}};hljs.LANGUAGES.python=function(){var c={cN:"string",b:"(u|b)?r?'''",e:"'''",r:10};var b={cN:"string",b:'(u|b)?r?"""',e:'"""',r:10};var a={cN:"string",b:"(u|r|ur|b|br)'",e:"'",c:[hljs.BE],r:10};var f={cN:"string",b:'(u|r|ur|b|br)"',e:'"',c:[hljs.BE],r:10};var d={cN:"title",b:hljs.UIR};var e={cN:"params",b:"\\(",e:"\\)",c:[c,b,a,f,hljs.ASM,hljs.QSM]};return{dM:{k:{keyword:{and:1,elif:1,is:1,global:1,as:1,"in":1,"if":1,from:1,raise:1,"for":1,except:1,"finally":1,print:1,"import":1,pass:1,"return":1,exec:1,"else":1,"break":1,not:1,"with":1,"class":1,assert:1,yield:1,"try":1,"while":1,"continue":1,del:1,or:1,def:1,lambda:1,nonlocal:10},built_in:{None:1,True:1,False:1,Ellipsis:1,NotImplemented:1}},i:"(|\\?)",c:[hljs.HCM,c,b,a,f,hljs.ASM,hljs.QSM,{cN:"function",b:"\\bdef ",e:":",i:"$",k:{def:1},c:[d,e],r:10},{cN:"class",b:"\\bclass ",e:":",i:"[${]",k:{"class":1},c:[d,e],r:10},hljs.CNM,{cN:"decorator",b:"@",e:"$"}]}}}();hljs.LANGUAGES.perl=function(){var c={getpwent:1,getservent:1,quotemeta:1,msgrcv:1,scalar:1,kill:1,dbmclose:1,undef:1,lc:1,ma:1,syswrite:1,tr:1,send:1,umask:1,sysopen:1,shmwrite:1,vec:1,qx:1,utime:1,local:1,oct:1,semctl:1,localtime:1,readpipe:1,"do":1,"return":1,format:1,read:1,sprintf:1,dbmopen:1,pop:1,getpgrp:1,not:1,getpwnam:1,rewinddir:1,qq:1,fileno:1,qw:1,endprotoent:1,wait:1,sethostent:1,bless:1,s:1,opendir:1,"continue":1,each:1,sleep:1,endgrent:1,shutdown:1,dump:1,chomp:1,connect:1,getsockname:1,die:1,socketpair:1,close:1,flock:1,exists:1,index:1,shmget:1,sub:1,"for":1,endpwent:1,redo:1,lstat:1,msgctl:1,setpgrp:1,abs:1,exit:1,select:1,print:1,ref:1,gethostbyaddr:1,unshift:1,fcntl:1,syscall:1,"goto":1,getnetbyaddr:1,join:1,gmtime:1,symlink:1,semget:1,splice:1,x:1,getpeername:1,recv:1,log:1,setsockopt:1,cos:1,last:1,reverse:1,gethostbyname:1,getgrnam:1,study:1,formline:1,endhostent:1,times:1,chop:1,length:1,gethostent:1,getnetent:1,pack:1,getprotoent:1,getservbyname:1,rand:1,mkdir:1,pos:1,chmod:1,y:1,substr:1,endnetent:1,printf:1,next:1,open:1,msgsnd:1,readdir:1,use:1,unlink:1,getsockopt:1,getpriority:1,rindex:1,wantarray:1,hex:1,system:1,getservbyport:1,endservent:1,"int":1,chr:1,untie:1,rmdir:1,prototype:1,tell:1,listen:1,fork:1,shmread:1,ucfirst:1,setprotoent:1,"else":1,sysseek:1,link:1,getgrgid:1,shmctl:1,waitpid:1,unpack:1,getnetbyname:1,reset:1,chdir:1,grep:1,split:1,require:1,caller:1,lcfirst:1,until:1,warn:1,"while":1,values:1,shift:1,telldir:1,getpwuid:1,my:1,getprotobynumber:1,"delete":1,and:1,sort:1,uc:1,defined:1,srand:1,accept:1,"package":1,seekdir:1,getprotobyname:1,semop:1,our:1,rename:1,seek:1,"if":1,q:1,chroot:1,sysread:1,setpwent:1,no:1,crypt:1,getc:1,chown:1,sqrt:1,write:1,setnetent:1,setpriority:1,foreach:1,tie:1,sin:1,msgget:1,map:1,stat:1,getlogin:1,unless:1,elsif:1,truncate:1,exec:1,keys:1,glob:1,tied:1,closedir:1,ioctl:1,socket:1,readlink:1,"eval":1,xor:1,readline:1,binmode:1,setservent:1,eof:1,ord:1,bind:1,alarm:1,pipe:1,atan2:1,getgrent:1,exp:1,time:1,push:1,setgrent:1,gt:1,lt:1,or:1,ne:1,m:1};var d={cN:"subst",b:"[$@]\\{",e:"}",k:c,r:10};var b={cN:"variable",b:"\\$\\d"};var a={cN:"variable",b:"[\\$\\%\\@\\*](\\^\\w\\b|#\\w+(\\:\\:\\w+)*|[^\\s\\w{]|{\\w+}|\\w+(\\:\\:\\w*)*)"};var g=[hljs.BE,d,b,a];var f={b:"->",c:[{b:hljs.IR},{b:"{",e:"}"}]};var e=[b,a,hljs.HCM,{cN:"comment",b:"^(__END__|__DATA__)",e:"\\n$",r:5},f,{cN:"string",b:"q[qwxr]?\\s*\\(",e:"\\)",c:g,r:5},{cN:"string",b:"q[qwxr]?\\s*\\[",e:"\\]",c:g,r:5},{cN:"string",b:"q[qwxr]?\\s*\\{",e:"\\}",c:g,r:5},{cN:"string",b:"q[qwxr]?\\s*\\|",e:"\\|",c:g,r:5},{cN:"string",b:"q[qwxr]?\\s*\\<",e:"\\>",c:g,r:5},{cN:"string",b:"qw\\s+q",e:"q",c:g,r:5},{cN:"string",b:"'",e:"'",c:[hljs.BE],r:0},{cN:"string",b:'"',e:'"',c:g,r:0},{cN:"string",b:"`",e:"`",c:[hljs.BE]},{cN:"string",b:"{\\w+}",r:0},{cN:"string",b:"-?\\w+\\s*\\=\\>",r:0},{cN:"number",b:"(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b",r:0},{cN:"regexp",b:"(s|tr|y)/(\\\\.|[^/])*/(\\\\.|[^/])*/[a-z]*",r:10},{cN:"regexp",b:"(m|qr)?/",e:"/[a-z]*",c:[hljs.BE],r:0},{cN:"sub",b:"\\bsub\\b",e:"(\\s*\\(.*?\\))?[;{]",k:{sub:1},r:5},{cN:"operator",b:"-\\w\\b",r:0},{cN:"pod",b:"\\=\\w",e:"\\=cut"}];d.c=e;f.c[1].c=e;return{dM:{k:c,c:e}}}();hljs.LANGUAGES.cpp=function(){var b={keyword:{"false":1,"int":1,"float":1,"while":1,"private":1,"char":1,"catch":1,"export":1,virtual:1,operator:2,sizeof:2,dynamic_cast:2,typedef:2,const_cast:2,"const":1,struct:1,"for":1,static_cast:2,union:1,namespace:1,unsigned:1,"long":1,"throw":1,"volatile":2,"static":1,"protected":1,bool:1,template:1,mutable:1,"if":1,"public":1,friend:2,"do":1,"return":1,"goto":1,auto:1,"void":2,"enum":1,"else":1,"break":1,"new":1,extern:1,using:1,"true":1,"class":1,asm:1,"case":1,typeid:1,"short":1,reinterpret_cast:2,"default":1,"double":1,register:1,explicit:1,signed:1,typename:1,"try":1,"this":1,"switch":1,"continue":1,wchar_t:1,inline:1,"delete":1,alignof:1,char16_t:1,char32_t:1,constexpr:1,decltype:1,noexcept:1,nullptr:1,static_assert:1,thread_local:1},built_in:{std:1,string:1,cin:1,cout:1,cerr:1,clog:1,stringstream:1,istringstream:1,ostringstream:1,auto_ptr:1,deque:1,list:1,queue:1,stack:1,vector:1,map:1,set:1,bitset:1,multiset:1,multimap:1,unordered_set:1,unordered_map:1,unordered_multiset:1,unordered_multimap:1,array:1,shared_ptr:1}};var a={cN:"stl_container",b:"\\b(deque|list|queue|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array)\\s*<",e:">",k:b,r:10};a.c=[a];return{dM:{k:b,i:" 0 ) { text = text.replace( new RegExp('\\n?\\t{' + leadingTabs + '}','g'), '\n' ); } else if( leadingWs > 1 ) { text = text.replace( new RegExp('\\n? {' + leadingWs + '}','g'), '\n' ); } section.innerHTML = (new Showdown.converter()).makeHtml(text); if( notes ) { section.appendChild( notes ); } } })(); ================================================ FILE: plugin/markdown/showdown.js ================================================ // // showdown.js -- A javascript port of Markdown. // // Copyright (c) 2007 John Fraser. // // Original Markdown Copyright (c) 2004-2005 John Gruber // // // Redistributable under a BSD-style open source license. // See license.txt for more information. // // The full source distribution is at: // // A A L // T C A // T K B // // // // // Wherever possible, Showdown is a straight, line-by-line port // of the Perl version of Markdown. // // This is not a normal parser design; it's basically just a // series of string substitutions. It's hard to read and // maintain this way, but keeping Showdown close to the original // design makes it easier to port new features. // // More importantly, Showdown behaves like markdown.pl in most // edge cases. So web applications can do client-side preview // in Javascript, and then build identical HTML on the server. // // This port needs the new RegExp functionality of ECMA 262, // 3rd Edition (i.e. Javascript 1.5). Most modern web browsers // should do fine. Even with the new regular expression features, // We do a lot of work to emulate Perl's regex functionality. // The tricky changes in this file mostly have the "attacklab:" // label. Major or self-explanatory changes don't. // // Smart diff tools like Araxis Merge will be able to match up // this file with markdown.pl in a useful way. A little tweaking // helps: in a copy of markdown.pl, replace "#" with "//" and // replace "$text" with "text". Be sure to ignore whitespace // and line endings. // // // Showdown usage: // // var text = "Markdown *rocks*."; // // var converter = new Showdown.converter(); // var html = converter.makeHtml(text); // // alert(html); // // Note: move the sample code to the bottom of this // file before uncommenting it. // // // Showdown namespace // var Showdown={};Showdown.converter=function(){var a,b,c,d=0;this.makeHtml=function(d){return a=new Array,b=new Array,c=new Array,d=d.replace(/~/g,"~T"),d=d.replace(/\$/g,"~D"),d=d.replace(/\r\n/g,"\n"),d=d.replace(/\r/g,"\n"),d="\n\n"+d+"\n\n",d=F(d),d=d.replace(/^[ \t]+$/mg,""),d=f(d),d=e(d),d=h(d),d=D(d),d=d.replace(/~D/g,"$$"),d=d.replace(/~T/g,"~"),d};var e=function(c){var c=c.replace(/^[ ]{0,3}\[(.+)\]:[ \t]*\n?[ \t]*?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|\Z)/gm,function(c,d,e,f,g){return d=d.toLowerCase(),a[d]=z(e),f?f+g:(g&&(b[d]=g.replace(/"/g,""")),"")});return c},f=function(a){a=a.replace(/\n/g,"\n\n");var b="p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del",c="p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math";return a=a.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del)\b[^\r]*?\n<\/\2>[ \t]*(?=\n+))/gm,g),a=a.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math)\b[^\r]*?.*<\/\2>[ \t]*(?=\n+)\n)/gm,g),a=a.replace(/(\n[ ]{0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,g),a=a.replace(/(\n\n[ ]{0,3}[ \t]*(?=\n{2,}))/g,g),a=a.replace(/(?:\n\n)([ ]{0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,g),a=a.replace(/\n\n/g,"\n"),a},g=function(a,b){var d=b;return d=d.replace(/\n\n/g,"\n"),d=d.replace(/^\n/,""),d=d.replace(/\n+$/g,""),d="\n\n~K"+(c.push(d)-1)+"K\n\n",d},h=function(a){a=o(a);var b=t("
");return a=a.replace(/^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$/gm,b),a=a.replace(/^[ ]{0,2}([ ]?\-[ ]?){3,}[ \t]*$/gm,b),a=a.replace(/^[ ]{0,2}([ ]?\_[ ]?){3,}[ \t]*$/gm,b),a=q(a),a=s(a),a=r(a),a=x(a),a=f(a),a=y(a),a},i=function(a){return a=u(a),a=j(a),a=A(a),a=m(a),a=k(a),a=B(a),a=z(a),a=w(a),a=a.replace(/ +\n/g,"
\n"),a},j=function(a){var b=/(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|)/gi;return a=a.replace(b,function(a){var b=a.replace(/(.)<\/?code>(?=.)/g,"$1`");return b=G(b,"\\`*_"),b}),a},k=function(a){return a=a.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,l),a=a.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,l),a=a.replace(/(\[([^\[\]]+)\])()()()()()/g,l),a},l=function(c,d,e,f,g,h,i,j){j==undefined&&(j="");var k=d,l=e,m=f.toLowerCase(),n=g,o=j;if(n==""){m==""&&(m=l.toLowerCase().replace(/ ?\n/g," ")),n="#"+m;if(a[m]!=undefined)n=a[m],b[m]!=undefined&&(o=b[m]);else{if(!(k.search(/\(\s*\)$/m)>-1))return k;n=""}}n=G(n,"*_");var p='",p},m=function(a){return a=a.replace(/(!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,n),a=a.replace(/(!\[(.*?)\]\s?\([ \t]*()?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,n),a},n=function(c,d,e,f,g,h,i,j){var k=d,l=e,m=f.toLowerCase(),n=g,o=j;o||(o="");if(n==""){m==""&&(m=l.toLowerCase().replace(/ ?\n/g," ")),n="#"+m;if(a[m]==undefined)return k;n=a[m],b[m]!=undefined&&(o=b[m])}l=l.replace(/"/g,"""),n=G(n,"*_");var p=''+l+''+i(c)+"")}),a=a.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm,function(a,c){return t('

'+i(c)+"

")}),a=a.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm,function(a,c,d){var e=c.length;return t("'+i(d)+"")}),a},p,q=function(a){a+="~0";var b=/^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;return d?a=a.replace(b,function(a,b,c){var d=b,e=c.search(/[*+-]/g)>-1?"ul":"ol";d=d.replace(/\n{2,}/g,"\n\n\n");var f=p(d);return f=f.replace(/\s+$/,""),f="<"+e+">"+f+"\n",f}):(b=/(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/g,a=a.replace(b,function(a,b,c,d){var e=b,f=c,g=d.search(/[*+-]/g)>-1?"ul":"ol",f=f.replace(/\n{2,}/g,"\n\n\n"),h=p(f);return h=e+"<"+g+">\n"+h+"\n",h})),a=a.replace(/~0/,""),a};p=function(a){return d++,a=a.replace(/\n{2,}$/,"\n"),a+="~0",a=a.replace(/(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+([^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm,function(a,b,c,d,e){var f=e,g=b,j=c;return g||f.search(/\n{2,}/)>-1?f=h(E(f)):(f=q(E(f)),f=f.replace(/\n$/,""),f=i(f)),"
  • "+f+"
  • \n"}),a=a.replace(/~0/g,""),d--,a};var r=function(a){return a+="~0",a=a.replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,function(a,b,c){var d=b,e=c;return d=v(E(d)),d=F(d),d=d.replace(/^\n+/g,""),d=d.replace(/\n+$/g,""),d="
    "+d+"\n
    ",t(d)+e}),a=a.replace(/~0/,""),a},s=function(a){return a+="~0",a=a.replace(/\n```(.*)\n([^`]+)\n```/g,function(a,b,c){var d=b,e=c;return e=v(e),e=F(e),e=e.replace(/^\n+/g,""),e=e.replace(/\n+$/g,""),e="
    "+e+"\n
    ",t(e)}),a=a.replace(/~0/,""),a},t=function(a){return a=a.replace(/(^\n+|\n+$)/g,""),"\n\n~K"+(c.push(a)-1)+"K\n\n"},u=function(a){return a=a.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,function(a,b,c,d,e){var f=d;return f=f.replace(/^([ \t]*)/g,""),f=f.replace(/[ \t]*$/g,""),f=v(f),b+""+f+""}),a},v=function(a){return a=a.replace(/&/g,"&"),a=a.replace(//g,">"),a=G(a,"*_{}[]\\",!1),a},w=function(a){return a=a.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g,"$2"),a=a.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g,"$2"),a},x=function(a){return a=a.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm,function(a,b){var c=b;return c=c.replace(/^[ \t]*>[ \t]?/gm,"~0"),c=c.replace(/~0/g,""),c=c.replace(/^[ \t]+$/gm,""),c=h(c),c=c.replace(/(^|\n)/g,"$1 "),c=c.replace(/(\s*
    [^\r]+?<\/pre>)/gm,function(a,b){var c=b;return c=c.replace(/^  /mg,"~0"),c=c.replace(/~0/g,""),c}),t("
    \n"+c+"\n
    ")}),a},y=function(a){a=a.replace(/^\n+/g,""),a=a.replace(/\n+$/g,"");var b=a.split(/\n{2,}/g),d=new Array,e=b.length;for(var f=0;f=0?d.push(g):g.search(/\S/)>=0&&(g=i(g),g=g.replace(/^([ \t]*)/g,"

    "),g+="

    ",d.push(g))}e=d.length;for(var f=0;f=0){var h=c[RegExp.$1];h=h.replace(/\$/g,"$$$$"),d[f]=d[f].replace(/~K\d+K/,h)}return d.join("\n\n")},z=function(a){return a=a.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g,"&"),a=a.replace(/<(?![a-z\/?\$!])/gi,"<"),a},A=function(a){return a=a.replace(/\\(\\)/g,H),a=a.replace(/\\([`*_{}\[\]()>#+-.!])/g,H),a},B=function(a){return a=a.replace(/<((https?|ftp|dict):[^'">\s]+)>/gi,'
    $1'),a=a.replace(/<(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi,function(a,b){return C(D(b))}),a},C=function(a){function b(a){var b="0123456789ABCDEF",c=a.charCodeAt(0);return b.charAt(c>>4)+b.charAt(c&15)}var c=[function(a){return"&#"+a.charCodeAt(0)+";"},function(a){return"&#x"+b(a)+";"},function(a){return a}];return a="mailto:"+a,a=a.replace(/./g,function(a){if(a=="@")a=c[Math.floor(Math.random()*2)](a);else if(a!=":"){var b=Math.random();a=b>.9?c[2](a):b>.45?c[1](a):c[0](a)}return a}),a=''+a+"",a=a.replace(/">.+:/g,'">'),a},D=function(a){return a=a.replace(/~E(\d+)E/g,function(a,b){var c=parseInt(b);return String.fromCharCode(c)}),a},E=function(a){return a=a.replace(/^(\t|[ ]{1,4})/gm,"~0"),a=a.replace(/~0/g,""),a},F=function(a){return a=a.replace(/\t(?=\t)/g," "),a=a.replace(/\t/g,"~A~B"),a=a.replace(/~B(.+?)~A/g,function(a,b,c){var d=b,e=4-d.length%4;for(var f=0;f reveal.js - Slide Notes
    UPCOMING:
    ================================================ FILE: plugin/notes/notes.js ================================================ /** * Handles opening of and synchronization with the reveal.js * notes window. */ var RevealNotes = (function() { function openNotes() { var notesPopup = window.open( 'plugin/notes/notes.html', 'reveal.js - Notes', 'width=1120,height=850' ); // Fires when slide is changed Reveal.addEventListener( 'slidechanged', function( event ) { post('slidechanged'); } ); // Fires when a fragment is shown Reveal.addEventListener( 'fragmentshown', function( event ) { post('fragmentshown'); } ); // Fires when a fragment is hidden Reveal.addEventListener( 'fragmenthidden', function( event ) { post('fragmenthidden'); } ); /** * Posts the current slide data to the notes window * * @param {String} eventType Expecting 'slidechanged', 'fragmentshown' * or 'fragmenthidden' set in the events above to define the needed * slideDate. */ function post( eventType ) { var slideElement = Reveal.getCurrentSlide(), messageData; if( eventType === 'slidechanged' ) { var notes = slideElement.querySelector( 'aside.notes' ), indexh = Reveal.getIndices().h, indexv = Reveal.getIndices().v, nextindexh, nextindexv; if( slideElement.nextElementSibling && slideElement.parentNode.nodeName == 'SECTION' ) { nextindexh = indexh; nextindexv = indexv + 1; } else { nextindexh = indexh + 1; nextindexv = 0; } messageData = { notes : notes ? notes.innerHTML : '', indexh : indexh, indexv : indexv, nextindexh : nextindexh, nextindexv : nextindexv, markdown : notes ? typeof notes.getAttribute( 'data-markdown' ) === 'string' : false }; } else if( eventType === 'fragmentshown' ) { messageData = { fragment : 'next' }; } else if( eventType === 'fragmenthidden' ) { messageData = { fragment : 'prev' }; } notesPopup.postMessage( JSON.stringify( messageData ), '*' ); } // Navigate to the current slide when the notes are loaded notesPopup.addEventListener( 'load', function( event ) { post('slidechanged'); }, false ); } // If the there's a 'notes' query set, open directly if( window.location.search.match( /(\?|\&)notes/gi ) !== null ) { openNotes(); } // Open the notes when the 's' key is hit document.addEventListener( 'keydown', function( event ) { // Disregard the event if the target is editable or a // modifier is present if ( document.querySelector( ':focus' ) !== null || event.shiftKey || event.altKey || event.ctrlKey || event.metaKey ) return; if( event.keyCode === 83 ) { event.preventDefault(); openNotes(); } }, false ); return { open: openNotes }; })(); ================================================ FILE: plugin/notes-server/client.js ================================================ (function() { // don't emit events from inside the previews themselves if ( window.location.search.match( /receiver/gi ) ) { return; } var socket = io.connect(window.location.origin); var socketId = Math.random().toString().slice(2); console.log('View slide notes at ' + window.location.origin + '/notes/' + socketId); window.open(window.location.origin + '/notes/' + socketId, 'notes-' + socketId); // Fires when a fragment is shown Reveal.addEventListener( 'fragmentshown', function( event ) { var fragmentData = { fragment : 'next', socketId : socketId }; socket.emit('fragmentchanged', fragmentData); } ); // Fires when a fragment is hidden Reveal.addEventListener( 'fragmenthidden', function( event ) { var fragmentData = { fragment : 'previous', socketId : socketId }; socket.emit('fragmentchanged', fragmentData); } ); // Fires when slide is changed Reveal.addEventListener( 'slidechanged', function( event ) { var nextindexh; var nextindexv; var slideElement = event.currentSlide; if (slideElement.nextElementSibling && slideElement.parentNode.nodeName == 'SECTION') { nextindexh = event.indexh; nextindexv = event.indexv + 1; } else { nextindexh = event.indexh + 1; nextindexv = 0; } var notes = slideElement.querySelector('aside.notes'); var slideData = { notes : notes ? notes.innerHTML : '', indexh : event.indexh, indexv : event.indexv, nextindexh : nextindexh, nextindexv : nextindexv, socketId : socketId, markdown : notes ? typeof notes.getAttribute('data-markdown') === 'string' : false }; socket.emit('slidechanged', slideData); } ); }()); ================================================ FILE: plugin/notes-server/index.js ================================================ var express = require('express'); var fs = require('fs'); var io = require('socket.io'); var _ = require('underscore'); var Mustache = require('mustache'); var app = express.createServer(); var staticDir = express.static; io = io.listen(app); var opts = { port : 1947, baseDir : __dirname + '/../../' }; io.sockets.on('connection', function(socket) { socket.on('slidechanged', function(slideData) { socket.broadcast.emit('slidedata', slideData); }); socket.on('fragmentchanged', function(fragmentData) { socket.broadcast.emit('fragmentdata', fragmentData); }); }); app.configure(function() { [ 'css', 'js', 'images', 'plugin', 'lib' ].forEach(function(dir) { app.use('/' + dir, staticDir(opts.baseDir + dir)); }); }); app.get("/", function(req, res) { fs.createReadStream(opts.baseDir + '/index.html').pipe(res); }); app.get("/notes/:socketId", function(req, res) { fs.readFile(opts.baseDir + 'plugin/notes-server/notes.html', function(err, data) { res.send(Mustache.to_html(data.toString(), { socketId : req.params.socketId })); }); // fs.createReadStream(opts.baseDir + 'notes-server/notes.html').pipe(res); }); // Actually listen app.listen(opts.port || null); var brown = '\033[33m', green = '\033[32m', reset = '\033[0m'; var slidesLocation = "http://localhost" + ( opts.port ? ( ':' + opts.port ) : '' ); console.log( brown + "reveal.js - Speaker Notes" + reset ); console.log( "1. Open the slides at " + green + slidesLocation + reset ); console.log( "2. Click on the link your JS console to go to the notes page" ); console.log( "3. Advance through your slides and your notes will advance automatically" ); ================================================ FILE: plugin/notes-server/notes.html ================================================ reveal.js - Slide Notes
    UPCOMING:
    ================================================ FILE: plugin/postmessage/example.html ================================================
    ================================================ FILE: plugin/postmessage/postmessage.js ================================================ /* simple postmessage plugin Useful when a reveal slideshow is inside an iframe. It allows to call reveal methods from outside. Example: var reveal = window.frames[0]; // Reveal.prev(); reveal.postMessage(JSON.stringify({method: 'prev', args: []}), '*'); // Reveal.next(); reveal.postMessage(JSON.stringify({method: 'next', args: []}), '*'); // Reveal.slide(2, 2); reveal.postMessage(JSON.stringify({method: 'slide', args: [2,2]}), '*'); Add to the slideshow: dependencies: [ ... { src: 'plugin/postmessage/postmessage.js', async: true, condition: function() { return !!document.body.classList; } } ] */ (function (){ window.addEventListener( "message", function ( event ) { var data = JSON.parse( event.data ), method = data.method, args = data.args; if( typeof Reveal[method] === 'function' ) { Reveal[method].apply( Reveal, data.args ); } }, false); }()); ================================================ FILE: plugin/print-pdf/print-pdf.js ================================================ /** * phantomjs script for printing presentations to PDF. * * Example: * phantomjs print-pdf.js "http://lab.hakim.se/reveal-js?print-pdf" reveal-demo.pdf * * By Manuel Bieh (https://github.com/manuelbieh) */ // html2pdf.js var page = new WebPage(); var system = require( 'system' ); page.paperSize = { format: 'A4', orientation: 'landscape', margin: { left: '0', right: '0', top: '0', bottom: '0' } }; page.zoomFactor = 1.5; var revealFile = system.args[1] || 'index.html?print-pdf'; var slideFile = system.args[2] || 'slides.pdf'; if( slideFile.match( /\.pdf$/gi ) === null ) { slideFile += '.pdf'; } console.log( 'Printing PDF...' ); page.open( revealFile, function( status ) { console.log( 'Printed succesfully' ); page.render( slideFile ); phantom.exit(); } ); ================================================ FILE: plugin/remotes/remotes.js ================================================ /** * Touch-based remote controller for your presentation courtesy * of the folks at http://remotes.io */ (function(window){ /** * Detects if we are dealing with a touch enabled device (with some false positives) * Borrowed from modernizr: https://github.com/Modernizr/Modernizr/blob/master/feature-detects/touch.js */ var hasTouch = (function(){ return ('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch; })(); if(!hasTouch){ head.ready( 'remotes.ne.min.js', function() { new Remotes("preview") .on("swipe-left", function(e){ Reveal.right(); }) .on("swipe-right", function(e){ Reveal.left(); }) .on("swipe-up", function(e){ Reveal.down(); }) .on("swipe-down", function(e){ Reveal.up(); }) .on("tap", function(e){ Reveal.toggleOverview(); }); } ); head.js('https://raw.github.com/Remotes/Remotes/master/dist/remotes.ne.min.js'); } })(window); ================================================ FILE: plugin/zoom-js/zoom.js ================================================ // Custom reveal.js integration (function(){ document.querySelector( '.reveal' ).addEventListener( 'click', function( event ) { if( event.altKey ) { event.preventDefault(); zoom.to({ element: event.target, pan: false }); } } ); })(); /*! * zoom.js 0.2 (modified version for use with reveal.js) * http://lab.hakim.se/zoom-js * MIT licensed * * Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se */ var zoom = (function(){ // The current zoom level (scale) var level = 1; // The current mouse position, used for panning var mouseX = 0, mouseY = 0; // Timeout before pan is activated var panEngageTimeout = -1, panUpdateInterval = -1; var currentOptions = null; // Check for transform support so that we can fallback otherwise var supportsTransforms = 'WebkitTransform' in document.body.style || 'MozTransform' in document.body.style || 'msTransform' in document.body.style || 'OTransform' in document.body.style || 'transform' in document.body.style; if( supportsTransforms ) { // The easing that will be applied when we zoom in/out document.body.style.transition = 'transform 0.8s ease'; document.body.style.OTransition = '-o-transform 0.8s ease'; document.body.style.msTransition = '-ms-transform 0.8s ease'; document.body.style.MozTransition = '-moz-transform 0.8s ease'; document.body.style.WebkitTransition = '-webkit-transform 0.8s ease'; } // Zoom out if the user hits escape document.addEventListener( 'keyup', function( event ) { if( level !== 1 && event.keyCode === 27 ) { zoom.out(); } }, false ); // Monitor mouse movement for panning document.addEventListener( 'mousemove', function( event ) { if( level !== 1 ) { mouseX = event.clientX; mouseY = event.clientY; } }, false ); /** * Applies the CSS required to zoom in, prioritizes use of CSS3 * transforms but falls back on zoom for IE. * * @param {Number} pageOffsetX * @param {Number} pageOffsetY * @param {Number} elementOffsetX * @param {Number} elementOffsetY * @param {Number} scale */ function magnify( pageOffsetX, pageOffsetY, elementOffsetX, elementOffsetY, scale ) { if( supportsTransforms ) { var origin = pageOffsetX +'px '+ pageOffsetY +'px', transform = 'translate('+ -elementOffsetX +'px,'+ -elementOffsetY +'px) scale('+ scale +')'; document.body.style.transformOrigin = origin; document.body.style.OTransformOrigin = origin; document.body.style.msTransformOrigin = origin; document.body.style.MozTransformOrigin = origin; document.body.style.WebkitTransformOrigin = origin; document.body.style.transform = transform; document.body.style.OTransform = transform; document.body.style.msTransform = transform; document.body.style.MozTransform = transform; document.body.style.WebkitTransform = transform; } else { // Reset all values if( scale === 1 ) { document.body.style.position = ''; document.body.style.left = ''; document.body.style.top = ''; document.body.style.width = ''; document.body.style.height = ''; document.body.style.zoom = ''; } // Apply scale else { document.body.style.position = 'relative'; document.body.style.left = ( - ( pageOffsetX + elementOffsetX ) / scale ) + 'px'; document.body.style.top = ( - ( pageOffsetY + elementOffsetY ) / scale ) + 'px'; document.body.style.width = ( scale * 100 ) + '%'; document.body.style.height = ( scale * 100 ) + '%'; document.body.style.zoom = scale; } } level = scale; if( level !== 1 && document.documentElement.classList ) { document.documentElement.classList.add( 'zoomed' ); } else { document.documentElement.classList.remove( 'zoomed' ); } } /** * Pan the document when the mosue cursor approaches the edges * of the window. */ function pan() { var range = 0.12, rangeX = window.innerWidth * range, rangeY = window.innerHeight * range, scrollOffset = getScrollOffset(); // Up if( mouseY < rangeY ) { window.scroll( scrollOffset.x, scrollOffset.y - ( 1 - ( mouseY / rangeY ) ) * ( 14 / level ) ); } // Down else if( mouseY > window.innerHeight - rangeY ) { window.scroll( scrollOffset.x, scrollOffset.y + ( 1 - ( window.innerHeight - mouseY ) / rangeY ) * ( 14 / level ) ); } // Left if( mouseX < rangeX ) { window.scroll( scrollOffset.x - ( 1 - ( mouseX / rangeX ) ) * ( 14 / level ), scrollOffset.y ); } // Right else if( mouseX > window.innerWidth - rangeX ) { window.scroll( scrollOffset.x + ( 1 - ( window.innerWidth - mouseX ) / rangeX ) * ( 14 / level ), scrollOffset.y ); } } function getScrollOffset() { return { x: window.scrollX !== undefined ? window.scrollX : window.pageXOffset, y: window.scrollY !== undefined ? window.scrollY : window.pageXYffset } } return { /** * Zooms in on either a rectangle or HTML element. * * @param {Object} options * - element: HTML element to zoom in on * OR * - x/y: coordinates in non-transformed space to zoom in on * - width/height: the portion of the screen to zoom in on * - scale: can be used instead of width/height to explicitly set scale */ to: function( options ) { // Due to an implementation limitation we can't zoom in // to another element without zooming out first if( level !== 1 ) { zoom.out(); } else { options.x = options.x || 0; options.y = options.y || 0; // If an element is set, that takes precedence if( !!options.element ) { // Space around the zoomed in element to leave on screen var padding = 20; options.width = options.element.getBoundingClientRect().width + ( padding * 2 ); options.height = options.element.getBoundingClientRect().height + ( padding * 2 ); options.x = options.element.getBoundingClientRect().left - padding; options.y = options.element.getBoundingClientRect().top - padding; } // If width/height values are set, calculate scale from those values if( options.width !== undefined && options.height !== undefined ) { options.scale = Math.max( Math.min( window.innerWidth / options.width, window.innerHeight / options.height ), 1 ); } if( options.scale > 1 ) { options.x *= options.scale; options.y *= options.scale; var scrollOffset = getScrollOffset(); if( options.element ) { scrollOffset.x -= ( window.innerWidth - ( options.width * options.scale ) ) / 2; } magnify( scrollOffset.x, scrollOffset.y, options.x, options.y, options.scale ); if( options.pan !== false ) { // Wait with engaging panning as it may conflict with the // zoom transition panEngageTimeout = setTimeout( function() { panUpdateInterval = setInterval( pan, 1000 / 60 ); }, 800 ); } } currentOptions = options; } }, /** * Resets the document zoom state to its default. */ out: function() { clearTimeout( panEngageTimeout ); clearInterval( panUpdateInterval ); var scrollOffset = getScrollOffset(); if( currentOptions && currentOptions.element ) { scrollOffset.x -= ( window.innerWidth - ( currentOptions.width * currentOptions.scale ) ) / 2; } magnify( scrollOffset.x, scrollOffset.y, 0, 0, 1 ); level = 1; }, // Alias magnify: function( options ) { this.to( options ) }, reset: function() { this.out() }, zoomLevel: function() { return level; } } })(); ================================================ FILE: requirements.txt ================================================ flask ================================================ FILE: run.py ================================================ #coding=utf-8 import os from flask import Flask, render_template, send_from_directory tmpl_dir = os.path.dirname(os.path.abspath(__file__)) app = Flask(__name__, template_folder=tmpl_dir, static_folder=tmpl_dir) @app.route('/') def main(): return render_template('index.html') @app.route('/') def static_url(filename): return send_from_directory(app.static_folder, filename) if __name__ == '__main__': app.run(host='0.0.0.0', port=80)