Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
This paste will be private.
#!/usr/bin/env ruby # # Lookup current word as a CSS property on w3c.org # # The mapping below was generated using: # echo '$props = {'; curl -s http://www.w3.org/TR/CSS2/propidx.html|egrep "(^|<tr><td>)<a href=\".*\" class=\"noxref\"><span class=\".*\">'.*'</span></a>"|perl -pe "s|(?:<tr><td>)?<a href=\"(.*)\" class=\"noxref\"><span class=\".*\">'(.*)'</span></a>|\t\"\$2\"\t=> \"\$1\",|"; echo '}' $props = { "azimuth" => "aural.html#propdef-azimuth", "background" => "colors.html#propdef-background", "background-attachment" => "colors.html#propdef-background-attachment", "background-color" => "colors.html#propdef-background-color", "background-image" => "colors.html#propdef-background-image", "background-position" => "colors.html#propdef-background-position", "background-repeat" => "colors.html#propdef-background-repeat", "border" => "box.html#propdef-border", "border-collapse" => "tables.html#propdef-border-collapse", "border-color" => "box.html#propdef-border-color", "border-spacing" => "tables.html#propdef-border-spacing", "border-style" => "box.html#propdef-border-style", "border-top" => "box.html#propdef-border-top", "border-right" => "box.html#propdef-border-right", "border-bottom" => "box.html#propdef-border-bottom", "border-left" => "box.html#propdef-border-left", "border-top-color" => "box.html#propdef-border-top-color", "border-right-color" => "box.html#propdef-border-right-color", "border-bottom-color" => "box.html#propdef-border-bottom-color", "border-left-color" => "box.html#propdef-border-left-color", "border-top-style" => "box.html#propdef-border-top-style", "border-right-style" => "box.html#propdef-border-right-style", "border-bottom-style" => "box.html#propdef-border-bottom-style", "border-left-style" => "box.html#propdef-border-left-style", "border-top-width" => "box.html#propdef-border-top-width", "border-right-width" => "box.html#propdef-border-right-width", "border-bottom-width" => "box.html#propdef-border-bottom-width", "border-left-width" => "box.html#propdef-border-left-width", "border-width" => "box.html#propdef-border-width", "bottom" => "visuren.html#propdef-bottom", "caption-side" => "tables.html#propdef-caption-side", "clear" => "visuren.html#propdef-clear", "clip" => "visufx.html#propdef-clip", "color" => "colors.html#propdef-color", "content" => "generate.html#propdef-content", "counter-increment" => "generate.html#propdef-counter-increment", "counter-reset" => "generate.html#propdef-counter-reset", "cue" => "aural.html#propdef-cue", "cue-after" => "aural.html#propdef-cue-after", "cue-before" => "aural.html#propdef-cue-before", "cursor" => "ui.html#propdef-cursor", "direction" => "visuren.html#propdef-direction", "display" => "visuren.html#propdef-display", "elevation" => "aural.html#propdef-elevation", "empty-cells" => "tables.html#propdef-empty-cells", "float" => "visuren.html#propdef-float", "font" => "fonts.html#propdef-font", "font-family" => "fonts.html#propdef-font-family", "font-size" => "fonts.html#propdef-font-size", "font-size-adjust" => "fonts.html#propdef-font-size-adjust", "font-stretch" => "fonts.html#propdef-font-stretch", "font-style" => "fonts.html#propdef-font-style", "font-variant" => "fonts.html#propdef-font-variant", "font-weight" => "fonts.html#propdef-font-weight", "height" => "visudet.html#propdef-height", "left" => "visuren.html#propdef-left", "letter-spacing" => "text.html#propdef-letter-spacing", "line-height" => "visudet.html#propdef-line-height", "list-style" => "generate.html#propdef-list-style", "list-style-image" => "generate.html#propdef-list-style-image", "list-style-position" => "generate.html#propdef-list-style-position", "list-style-type" => "generate.html#propdef-list-style-type", "margin" => "box.html#propdef-margin", "margin-top" => "box.html#propdef-margin-top", "margin-right" => "box.html#propdef-margin-right", "margin-bottom" => "box.html#propdef-margin-bottom", "margin-left" => "box.html#propdef-margin-left", "marker-offset" => "generate.html#propdef-marker-offset", "marks" => "page.html#propdef-marks", "max-height" => "visudet.html#propdef-max-height", "max-width" => "visudet.html#propdef-max-width", "min-height" => "visudet.html#propdef-min-height", "min-width" => "visudet.html#propdef-min-width", "orphans" => "page.html#propdef-orphans", "outline" => "ui.html#propdef-outline", "outline-color" => "ui.html#propdef-outline-color", "outline-style" => "ui.html#propdef-outline-style", "outline-width" => "ui.html#propdef-outline-width", "overflow" => "visufx.html#propdef-overflow", "padding" => "box.html#propdef-padding", "padding-top" => "box.html#propdef-padding-top", "padding-right" => "box.html#propdef-padding-right", "padding-bottom" => "box.html#propdef-padding-bottom", "padding-left" => "box.html#propdef-padding-left", "page" => "page.html#propdef-page", "page-break-after" => "page.html#propdef-page-break-after", "page-break-before" => "page.html#propdef-page-break-before", "page-break-inside" => "page.html#propdef-page-break-inside", "pause" => "aural.html#propdef-pause", "pause-after" => "aural.html#propdef-pause-after", "pause-before" => "aural.html#propdef-pause-before", "pitch" => "aural.html#propdef-pitch", "pitch-range" => "aural.html#propdef-pitch-range", "play-during" => "aural.html#propdef-play-during", "position" => "visuren.html#propdef-position", "quotes" => "generate.html#propdef-quotes", "richness" => "aural.html#propdef-richness", "right" => "visuren.html#propdef-right", "size" => "page.html#propdef-size", "speak" => "aural.html#propdef-speak", "speak-header" => "tables.html#propdef-speak-header", "speak-numeral" => "aural.html#propdef-speak-numeral", "speak-punctuation" => "aural.html#propdef-speak-punctuation", "speech-rate" => "aural.html#propdef-speech-rate", "stress" => "aural.html#propdef-stress", "table-layout" => "tables.html#propdef-table-layout", "text-align" => "text.html#propdef-text-align", "text-decoration" => "text.html#propdef-text-decoration", "text-indent" => "text.html#propdef-text-indent", "text-shadow" => "text.html#propdef-text-shadow", "text-transform" => "text.html#propdef-text-transform", "top" => "visuren.html#propdef-top", "unicode-bidi" => "visuren.html#propdef-unicode-bidi", "vertical-align" => "visudet.html#propdef-vertical-align", "visibility" => "visufx.html#propdef-visibility", "voice-family" => "aural.html#propdef-voice-family", "volume" => "aural.html#propdef-volume", "white-space" => "text.html#propdef-white-space", "widows" => "page.html#propdef-widows", "width" => "visudet.html#propdef-width", "word-spacing" => "text.html#propdef-word-spacing", "z-index" => "visuren.html#propdef-z-index", } cur_line = ENV['TM_CURRENT_LINE'] cur_word = ENV['TM_CURRENT_WORD'] # since dash (‘-’) is not a word character, extend current word to neighboring word and dash characters $prop_name = /[-\w]*#{cur_word}[-\w]*/.match(cur_line)[0] def request_prop_name s = `\"#{ENV['TM_SUPPORT_PATH']}/bin/CocoaDialog.app/Contents/MacOS/CocoaDialog\" inputbox --title 'Documentation for Property' --informative-text 'What property would you like to lookup?' --text '#{$prop_name}' --button1 'Lookup' --button2 'Cancel' --button3 'Show All Properties'` case (a = s.split("\n"))[0].to_i when 1 then $props[a[1].to_s] || "propidx.html" when 2 then abort "<script>window.close()</script>" when 3 then "propidx.html" end end prop_url = $props[$prop_name] || request_prop_name url = "http://www.w3.org/TR/CSS2/" + prop_url puts "<meta http-equiv='Refresh' content='0;URL=#{url}'>"
From the Design Piracy series on my blog: