-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
69 lines (49 loc) · 3.76 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# {wordup}
<!-- badges: start -->
[![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/)
<!-- badges: end -->
## 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