Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I'm an avid WordPress developer, and I'm constantly referring to the Wordpress Codex to look up various functions. I recently got a new 2013 MBP, and I just found the glorious "three finger tap to look up" function. Now, I've read that it's possible to change the dictionary that's used by adding or removing dictionaries from Dictionary.app, but I'm interested in doing something different.

Has anybody found a way to import WordPress Codex into the Dictionary app? Essentially, I want to be able to highlight a WordPress function, three finger tap, and be presented with the Codex article (or at least an abridged version with usage and params).

share|improve this question
1  
This has nothing to do with three-finger tapping, so I'll post it as a comment instead of an answer: if you use the excellent Dash to browse the Codex offline, it integrates with several popular editors, such as Sublime Text, to provide features very similar to what you've described (e.g. look up the selected function). I highly recommend it! –  Dan J Aug 23 '13 at 0:22
    
I just checked it out, and it definitely seems useful, however it's not quite the functionality I'm looking for. I would be all over this app if only it integrated with the three finger tap functionality. It even says it offers a "look up highlighted text in Dash feature", but still doesn't integrate to the level I'd like. Still, thanks for the suggestion! –  Thought Space Designs Aug 23 '13 at 0:28

2 Answers 2

Apple shows you how to create and add Custom Dictionaries to it's Dictionary Applications in the Dictionary Services Programming Guide

It includes examples and a guide on the dictionary XHTML markup.

share|improve this answer
    
Thanks for the reference. I need to figure out a way to scrape content from the Wordpress codex "function reference" section, and then use this content to build a dictionary. Looking at this reference, it would seem I could script this solution, but I haven't a clue where to start. Do you have any good references on how I might be able to build a dictionary based off of arbitrary web content? –  Thought Space Designs Aug 23 '13 at 1:09
    
Can you add a link to the Wordpress reference you are talking about. This would help anyone who may want to look at a solution. –  markhunte Aug 23 '13 at 9:46
    
I added a link to the Codex to the question. I'm very interested in following this to see if someone comes up with something. :) –  Dan J Aug 23 '13 at 18:13
    
Thanks for adding the link. I missed this comment. I would love if somebody had a suggestion for doing this that doesn't involve screen scraping the codex. –  Thought Space Designs Aug 23 '13 at 21:21
    
You can use Special:Export to put it into XML. It'd be quite a job converting that into the Dictionary format, but it's doable. –  tubedogg Aug 24 '13 at 0:51

I was able to create a very rough Codex dictionary using this resources:

  • Following the steps to install and make a dictionary described in How can I create a dictionary for Mac OS X?

  • A sample XML file from the tool SQL to Apple Dictionary

    <?xml version="1.0" encoding="UTF-8"?>
    <!--
            This is a sample dictionary source file.
            It can be built using Dictionary Development Kit.
    -->
    <d:dictionary xmlns="http://www.w3.org/1999/xhtml" xmlns:d="http://www.apple.com/DTDs/DictionaryService-1.0.rng">
    <d:entry id="ldap" d:title="LDAP">
            <d:index d:value="LDAP"/>
            <h1>LDAP</h1>
            <p>Lightweight Directory Access Protocol</p>
    </d:entry>
    <d:entry id="midi" d:title="MIDI">
            <d:index d:value="MIDI"/>
            <h1>MIDI</h1>
            <p>Musical Instrument Digital Interface</p>
    </d:entry>
    <d:entry id="xml" d:title="XML">
            <d:index d:value="XML"/>
            <h1>XML</h1>
            <p>Extensible Markup Language</p>
    </d:entry>
    </d:dictionary>
    
  • A PHP script to convert the exported Codex XML file to conform with the sample file. Here's a Google Drive file with the resulting XML (70 thousand lines) and a Gist with the conversion script.

This is the result:

Codex dictionary

As can be seen, the biggest issue is to convert WordPress markup language into HTML.

share|improve this answer
    
The <title> field should be using underscores, in my test I haven't, so the search is for is user instead of is_user –  brasofilo Aug 25 at 16:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.