Giter Site home page Giter Site logo

wordup's Introduction

{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. R-CMD-check Blog post

Purpose

Convert a Microsoft Word document (docx) to Govspeak Markdown, which is the format required to publish on GOV.UK.

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

You may also be interested in a demo Shinylive app for converting tables to Govspeak format.

Motivation and scope

Producers of statistical publications 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, but there’s some missing functionality, such as handling images and tables.

Installation

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

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.

library(wordup)
path <- system.file("examples/simple.docx", package = "wordup")
body_list <- wu_read(path)
str(body_list, give.attr = FALSE, max.level = 3)
# List of 1
#  $ document:List of 1
#   ..$ body:List of 15
#   .. ..$ p     :List of 2
#   .. ..$ p     :List of 3
#   .. ..$ p     :List of 5
#   .. ..$ p     :List of 3
#   .. ..$ p     :List of 1
#   .. ..$ p     :List of 2
#   .. ..$ p     :List of 2
#   .. ..$ p     :List of 3
#   .. ..$ p     :List of 1
#   .. ..$ tbl   :List of 5
#   .. ..$ p     :List of 3
#   .. ..$ p     :List of 4
#   .. ..$ p     :List of 1
#   .. ..$ p     :List of 1
#   .. ..$ sectPr:List of 4

We can delve into this structure to retrieve text, etc.

body_list$document$body[[5]]
# $r
# $r$t
# $r$t[[1]]
# [1] "This is some more text. This time with bullets:"
# 
# 
# 
# attr(,"paraId")
# [1] "2460A889"
# attr(,"textId")
# [1] "3361B78B"
# attr(,"rsidR")
# [1] "007D458C"
# attr(,"rsidRDefault")
# [1] "007D458C"

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 to Govspeak:

For handling Word documents in R:

  • {officer} can read a Word document to a tidy table
  • {docxtractr} can extract tables, comments and other things

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.