para-level-ids-image

Why I wrote my WordPress plugin

Strike one item off the bucket list: I’ve written a WordPress plugin.

Paragraph Level IDs is available now from the WordPress plugin directory, and I’ve created a static page on this site to explain the detail. But in essence, the plugin adds lots of little anchors into the HTML of your blog posts, before each paragraph.

This means that the author and users can link to specific paragraphs in a piece of online text.

This functionality is extremely useful when dealing with long screeds of text. Someone may quote a bon mot, but if you follow the link to where the writer says the quote came from, you often have to trawl through many paragraphs to find the quote and check the context. If a site has anchors, or id attributes embedded in the HTML, the person creating the link can send the reader to the exact paragraph in the text.

This is a very old technique, one that has been present in HTML since its earliest incarnations. But few people use it routinely on their webpages. This plugin offers an easy way to alleviate that inefficiency!

Why write the plugin?

There were two prompt for me to try and tweak WordPress blogging system with a plugin. The first is the George Mallory answer: “Because its there“, because I can. I have been part of the WordPress community Before It Was Cool and love the elegance of the software: You can add any modifications you want to a dedicated ‘plugins’ folder (or if you want to change the way the site looks, a ‘themes’ folder). The site then behaves differently, but the underlying core code is not changed. Its great to be a part of the international community creating and extending a communications platform.  We’re helping more people communicate more efficiently with one another.

Efficiency was the impetus for creating this particular piece of code. In the past few years, I have had to wade through a lot of long legal and government policy documents: court judgements in libel cases, Ministry of Justice consultations, white papers, draft legislation, the Leveson Report, and Defamation Act documents. All these are usually presented as cumbersome PDFs, which, despite being electronic documents, nevertheless read like books.1 It takes time for the user to scroll to find the relevant passage. It is extremely difficult to link to a specific paragraph or clause in a PDF document. When you are scrutinising legislation on a line-by-line basis, this adds a lot of time to the research process. My modest plugin only works for WordPress sites (i.e. not Government documents) but it nevertheless sets a good example.

Thankfully, the Houses of Parliament Hansard (the official transcript of what has been said in the House Commons, the House of Lords, and all their Committees) is also a beacon of best practice. Most of its reports include precisely the anchors that should be in all such official documents. It is therefore easy to link to and read any given speech or procedural element (I’ve already moaned about the few gaps in its provision). Most other Government sites do not do this, and persist with their obstructive PDFs.

Nowhere is the problem more apparent than with the Leveson Report. The printed and PDF versions of the text impose an inappropriate linear experience upon the reader. The text is so long and extensively cross-referenced. The issues and topics it deals with are incredibly diverse. It cries out for a better, non-linear means of navigation.

I have an idea that I might create an HTML version, The Leveson Report (As It Should Be), with copious anchor links throughout the text. If I were to use the free WordPress software for this purpose, then I’ll need my Paragraph Level IDs plugin on hand to make the thing as useful as possible.


1. Yes, I know that my Defamation Act 2013: Complete & Unabridged compendium converted online text into book form… but I was making a different philosophical point with that project. [back]

6 thoughts on “Why I wrote my WordPress plugin

    1. To be clear, it doesn’t work on the <html> tag, it works on <p> tags within the HTML document.

      Yes, Wikipedia includes anchors – not on the paragraph level I don’t think, but on the section level which is good enough for the kind of precise linking that I am advocating.

  1. Great idea – will give it a go. Congratulations.

    I feel your pain re. the cumbersome PDFs – the same ones in fact. I’d also commend TheyWorkForYou for their formatting of debates etc. – I wish all policy docs were as accessible.

    Am currently working through one of the Leveson chapters, and this facility would be great so YES PLEASE to the HTML version of “The Leveson Report (As It Should Be)”
    Don’t know if anyone else has thought of this / working on this too? How wonderful if you could click on a topic or person’s name and see all relevant references …

    1. Thanks, Judith.

      I have actually now made a start on this precise project. I found some online tools that convert a PDF into HTML. However, the markup it creates is cumbersome with screeds of unnecessary data: not unlike the output produced when you save a Microsoft word document as a web page. Crucially it does not identify the structure of the page: headers, quotes, list items, etc. and there are no links.

      However, it is the perfect project to teach myself the basics of regular expressions, in the coding sense: REGEX. I have had more fun than is probably appropriate crafting search-and-replace queries to add the links and cross references.

      I will be sure to let you know when the final thing is published and online.

      And yes, TheyWorkForYou, for the win! But it should really not be the job of a third party charity to produce clean and linkable Parliamentary records. That should be the job of Parliament and Hansard. Incidentally, the legislation.gov.uk website is perfect – You can link to any part of any law, on a clause or sub-clause basis.

  2. please do – sounds fantastic, and a very worthwhile project.

    re. official accessible data. mySociety has done sterling work in making official data useable and also shifting attitudes and approaches to opening up public data, but I agree the onus should be on Parliament too, and in the case of law, on the MoJ / HCTMS and the judiciary. John Sheridan et al’s work on legislation.gov.uk and Good Law sets a very good example, but so much more could be done to make legal information digestible / useable and enhance the public’s right to receive information. Many simple things could be done that wouldn’t cost the earth…

Leave a Reply