An open API service indexing awesome lists of open source software.

https://github.com/matt-dray/wordup

:page_with_curl::speaking_head: R package: Word to Govspeak [WIP]
https://github.com/matt-dray/wordup

govspeak uk-gov-data-science word xml

Last synced: 5 months ago
JSON representation

:page_with_curl::speaking_head: R package: Word to Govspeak [WIP]

Awesome Lists containing this project

README

          

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#",
fig.path = "man/figures/README-",
out.width = "100%"
)
```

# {wordup}

[![Project Status: Concept – Minimal or no implementation has been done yet, or the repository is only intended to be a limited example, demo, or proof-of-concept.](https://www.repostatus.org/badges/latest/concept.svg)](https://www.repostatus.org/#concept)
[![R-CMD-check](https://github.com/matt-dray/wordup/workflows/R-CMD-check/badge.svg)](https://github.com/matt-dray/wordup/actions)
[![Blog post](https://img.shields.io/badge/rostrum.blog-post-008900?labelColor=000000&logo=data%3Aimage%2Fgif%3Bbase64%2CR0lGODlhEAAQAPEAAAAAABWCBAAAAAAAACH5BAlkAAIAIf8LTkVUU0NBUEUyLjADAQAAACwAAAAAEAAQAAAC55QkISIiEoQQQgghRBBCiCAIgiAIgiAIQiAIgSAIgiAIQiAIgRAEQiAQBAQCgUAQEAQEgYAgIAgIBAKBQBAQCAKBQEAgCAgEAoFAIAgEBAKBIBAQCAQCgUAgEAgCgUBAICAgICAgIBAgEBAgEBAgEBAgECAgICAgECAQIBAQIBAgECAgICAgICAgECAQECAQICAgICAgICAgEBAgEBAgEBAgICAgICAgECAQIBAQIBAgECAgICAgIBAgECAQECAQIBAgICAgIBAgIBAgEBAgECAgECAgICAgICAgECAgECAgQIAAAQIKAAAh%2BQQJZAACACwAAAAAEAAQAAAC55QkIiESIoQQQgghhAhCBCEIgiAIgiAIQiAIgSAIgiAIQiAIgRAEQiAQBAQCgUAQEAQEgYAgIAgIBAKBQBAQCAKBQEAgCAgEAoFAIAgEBAKBIBAQCAQCgUAgEAgCgUBAICAgICAgIBAgEBAgEBAgEBAgECAgICAgECAQIBAQIBAgECAgICAgICAgECAQECAQICAgICAgICAgEBAgEBAgEBAgICAgICAgECAQIBAQIBAgECAgICAgIBAgECAQECAQIBAgICAgIBAgIBAgEBAgECAgECAgICAgICAgECAgECAgQIAAAQIKAAA7)](https://www.rostrum.blog/2023/06/21/wordup-tables/)

## Purpose

Convert a Microsoft Word document (docx) to [Govspeak Markdown](https://www.gov.uk/guidance/how-to-publish-on-gov-uk/markdown), which is the format required to publish on [GOV.UK](https://www.gov.uk/).

This package is a personal project for learning purposes. It may never be finished and has no guarantees.

## Motivation and scope

Producers of [statistical publications](https://www.gov.uk/search/research-and-statistics?content_store_document_type=statistics_published&order=updated-newest) might draft their reports in docx format. Publishers need to convert these to Govspeak Markdown so they can be uploaded to the Government's publishing platform. This can be time consuming to do manually and there is potential for error. There's a [Govspeak converter tool](https://govspeak-preview.publishing.service.gov.uk/), but there's some missing functionality, such as handling images and tables.

## Installation

The package is available from GitHub. It isn't stable.

```{r eval=FALSE}
install.packages("remotes") # if not yet installed
remotes::install_github("matt-dray/wordup")
```

Here's the list structure of an example `word/document.xml` from an unzipped docx file.

```{r}
library(wordup)
path <- system.file("examples/simple.docx", package = "wordup")
body_list <- wu_read(path)
str(body_list, give.attr = FALSE, max.level = 3)
```
We can delve into this structure to retrieve text, etc.

```{r}
body_list$document$body[[5]]
```
Hopefully {wordup} will get functions to grab text and styles, apply Govspeak styling and then output a Markdown file. It could also convert images to SVG and insert anchor links for them.

## Related

There are existing packages that can convert [R Markdown](https://rmarkdown.rstudio.com/) to Govspeak:

* [{govspeaker}](https://github.com/best-practice-and-impact/govspeakr) (archived)
* [{mojgovspeak}](https://github.com/moj-analytical-services/mojspeakr)
* [{rgovspeak}](https://github.com/Defra-Data-Science-Centre-of-Excellence/rgovspeak)

For handling Word documents in R:

* [{officer}](https://davidgohel.github.io/officer/) can read a Word document to a tidy table
* [{docxtractr}](https://github.com/hrbrmstr/docxtractr) can extract tables, comments and other things