Skip to main content
Last updated: 25 Oct 2023

Find usage of Govspeak in content

Govspeak is an extension for Markdown used in GOV.UK’s publishing applications.

After making a change to the Govspeak gem, you may need to republish content that uses that markdown.

In nearly all cases, Govspeak is converted to HTML within the publishing application before being sent to Publishing API. This means there are two options for finding affected content: searching for raw Govspeak within the publishing application or converted HTML in Publishing API.

Searching for raw Govspeak in Whitehall

There is a rake task to find published content that matches a regular expression:

rake 'reporting:matching_docs[regex]'

Replace regex with an escaped version of the regular expression. This should be run on a whitehall-admin pod using the instructions in Run a rake task on EKS.

For example, to find all uses of inline attachments contained within steps, you would use the following regex:


This is escaped and used in the rake task as follows:

rake 'reporting:matching_docs[s\[0-9\]+\\..*?\\\[AttachmentLink:.*?\\\].*$]'

Searching for converted HTML in Publishing API

Follow the instructions to open a Rails console for Publishing API.

Example commands

Here’s some example commands you can run, feel free to modify the regex for your specific usecase (and add more here if you fancy :))

This will take a few minutes to execute since it’s iterating over a lot of editions!

Find ‘call to action’

Edition.where.not(content_store: nil).find_each { |e| puts "{e.base_path}" if e.details.to_s =~ /class=\\"call-to-action/ }
Edition.where.not(content_store: nil).find_each { |e| puts "{e.base_path}" if e.details.to_s =~ /href=\\"https:\/\/\/watch?v=/ }

Find hardcoded buttons

Edition.where.not(content_store: nil).find_each { |e| puts "{e.base_path}" if e.details.to_s =~ /class=\\"button/ }