It might be straightforward to write a bit of Clojure code that takes the first 
structure and transforms it into the second.  Discarding information you don't 
want is usually easier than adding information that isn't there.

Strings could be manipulated to remove characters that are illegal in keywords, 
and change spaces to dashes, and then call keyword on it, e.g.

user=> (keyword (str "primitives" "->" "numbers"))
:primitives->numbers

Andy

On Mar 26, 2012, at 11:47 AM, Devin Walters wrote:

> This is slightly off-topic, but I wanted to discuss the structure of the 
> cheatsheet.
> 
> I would like to turn the cheatsheet into a more queryable document than it 
> currently is and allow for it to be a dependency via clojars. 
> cheatsheet-structure has a lot of the display logic for various output 
> formats which doesn't seem relevant to simply getting information out of a 
> specific section or subsection. It seems like the raw data should be separate 
> from the display logic: for instance, instead of…
> 
> [:column
>   [:box "green"
>    :section "Primitives"
>    :subsection "Numbers"
>    :table [["Arithmetic" :cmds '[+ - …]]]
>   ]
> ]
> 
> It should be possible to have a simple map somewhere:
> 
> (def primitives
>   {:primitives {:children [:numbers, :strings, …], :column? true},
>    :primitives->numbers {:title "Numbers", :children [:arithmetic, …], 
> :box-color "blue"},
>    :numbers->arithmetic {:title "Arithmetic", :commands '[+ - …]}})
> 
> With a function that does something like:
> 
> (into-output-structure primitives) => [:column [:box "blue" :section 
> "Primitives" :subsection "Numbers" :table [["Arithmetic" :cmds '[+ - …]]]
> 
> Long story short, I've been staring at this for a bit, and I'm wondering if 
> there are any strong feelings about how to make the cheatsheet more of a 
> modular, queryable structure than it currently is.
> 
> Cheers,
> '(Devin Walters)
> 
> On Monday, March 26, 2012 at 4:35 AM, mnicky wrote:
> 
>> Seems that the text of cl-format overflows the right edge of the tooltip: 
>> http://i.imgur.com/B0ljt.png (tested in FF, Opera, Chrome)
>> 
>> On Monday, March 26, 2012 11:12:50 AM UTC+2, Andy Fingerhut wrote:
>>> 
>>> I've replaced this test page [1] with another one.  The one I posted on 
>>> March 24 has been overwritten.  The version at [2] that does not use 
>>> JavaScript, but only the title attribute on anchors, is still there as it 
>>> was yesterday.
>>> [1] 
>>> http://homepage.mac.com/​jafingerhut/files/cheatsheet-​clj-1.3.0-v1.4-tooltips/​cheatsheet-full.html
>>> 
>>> [2] 
>>> http://homepage.mac.com/​jafingerhut/files/cheatsheet-​clj-1.3.0-v1.4-tooltips/​cheatsheet-title-attribute.​html
>>> 
>>> The new version of [1] uses different JavaScript for the tooltips, 
>>> simplified so that the tips always appear above or below the link being 
>>> tipped.  This made it easier to ensure the tip always appears within the 
>>> bounds of the window.  The only exceptions I am aware of where the tip can 
>>> go out of the window boundaries is if your window is so narrow (< 600 
>>> pixels or so) that the tip doesn't fit in the width of the window at all, 
>>> or too short vertically.
>>> 
>>> It should also eliminate the "bouncing" problem that the old one had, and I 
>>> have made the tips completely opaque, not partially transparent.
>>> 
>>> It still probably won't work well with Android browsers with touchscreens.  
>>> I don't know what could be done about that.  I did try it on Safari on my 
>>> iPhone, and found that on a single tap on a link, it showed the tooltip, 
>>> and it required a second tap on the same link for the browser to follow the 
>>> link.  I like that behavior.
>>> 
>>> Take it for another spin if you had issues with it before.
>>> 
>>> All necessary files to generate these pages, including my modified jQuery 
>>> TipTip plugin, are here:
>>> 
>>> https://github.com/​jafingerhut/clojure-​cheatsheets
>>> 
>>> Andy
>>> 
>>> 
>>> On Mar 24, 2012, at 3:15 AM, Andy Fingerhut wrote:
>>> 
>>> > There are still some problems with this, but it is ready for experimental 
>>> > use, at least.  Alex, please don't put this on clojure.org -- it ain't 
>>> > ready yet.
>>> > 
>>> > http://homepage.mac.com/​jafingerhut/files/cheatsheet-​clj-1.3.0-v1.4-tooltips/​cheatsheet-full.html
>>> > 
>>> > I found and used TipTip for tooltips [1], because it advertises the 
>>> > ability to keep the tooltips within the browser window no matter where 
>>> > the cursor is relative to the window border.  I've tweaked a few settings 
>>> > that may cause it to fail to do this properly sometimes, and there are 
>>> > many cases where the tooltip appears so close to the cursor that it 
>>> > "flashes" on and off quickly.  As a workaround, try moving the cursor 
>>> > away from the tooltip, but still hovering over the link if you can.  If 
>>> > anyone knows how to correct those problems by tweaking the JavaScript 
>>> > code or CSS settings, please let me know.
>>> > 
>>> > The tooltips consist of the normal doc strings, with the first line of 
>>> > dashes removed, and truncated to the first 15 lines if it is longer than 
>>> > that (very few are).  Most links go to clojuredocs.org, as usual.
>>> > 
>>> > Give it a test drive and see what you think.
>>> > 
>>> > Andy
>>> > 
>>> > 
>>> > [1] http://code.drewwilson.com/​entry/tiptip-jquery-plugin
>>> >
>>> 
>> 
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with your 
>> first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
> 
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to