7

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).

2
  • 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, 2013 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! Aug 23, 2013 at 0:28

2 Answers 2

1

Finished dictionary

I found a Wiki parser that cleaned much the Codex exported XML, then did some extra clean up using TextMate regex search/replace and managed to build a decent dictionary:


Minor issues will be found as the Codex is a collective effort, and formatting may vary from article to article.

I put the source files and finished .dictionary file on Dropbox:


Initial steps

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:

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

5
  • 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, 2014 at 16:00
  • It looks like WordPress uses it's own proprietary markup language. I can't seem to find any info on what it's based off of. If it were based off of Markdown or something, I'd imagine it wouldn't be too hard to convert this to html. Oct 21, 2014 at 2:19
  • Found a parser that seems to work, I still have the project, am testing and report back :)
    – brasofilo
    Oct 21, 2014 at 2:51
  • I'm super giddy waiting to see this in action. I'm super stoked you managed to take it this far. Congratulations, and if you manage to piece this in to a one stop app or even a shell script, it would be HUGE for the WP dev community. Offline Codex reference built straight into the default Dictionary app! Oct 21, 2014 at 2:54
  • One big thing that I noticed is that it appears that under the "parameters" header, parameters aren't marked as optional or required. Any ideas about this? Oct 21, 2014 at 15:01
8

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.

8
  • 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? Aug 23, 2013 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, 2013 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, 2013 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. Aug 23, 2013 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, 2013 at 0:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .