Skip to content

pandoc_filters_508compliance

Kelli Johnson edited this page Dec 15, 2020 · 5 revisions

Table of contents

508 compliance

Individuals that have difficulties reading documents can have electronic documents read out loud to them. This will only work with a pdf document if the document is tagged, i.e., has appropriate metadata associated with the content. This metatdata helps screen readers navigate the content present on the page.

My own path towards creating 508 compliant documents was not linear. I found it important to my learning to document both the failed and successful endeavors that I embarked on because it was easy to forget what I had done given that I was interacting with various new software frameworks. Thus, these notes include unproductive content as well as productive information that should be used going forward.

accpdf

While searching for solutions to generating 508 compliant documents in the pandoc issue list, I found a rather lengthy issue on compliance. The discussion focused on how to use lua filters and Karl Pettersson's attempt to make a compliant document. And, it was here where I first learned about filters from accpdf and the use of lua scripts to introduce filtering.

The example included Julia code, which I quickly stripped from the markdown script and compiled the .md file on my machine. Then, I checked for compliance using PAC3 a free checker available for download. After figuring out the the document needed to be compiled multiple times, just like any LaTeX file to get the links right, I then sent the resulting pdf to Stacey Miller. It was seen as nearly compliant by her IT help at the West Coast Regional Office. Unfortunately, they wanted to check tables and more complicated headers.

I then continued down this road of filters and integrated the .latex file available within the aacpdf repository into the sadraft.tex file that serves as the latex template file for all stock assessments built using the sa4ss package. Next, I added the tagged-filter.lua and the makefile to the skeleton folder so that they would be copied into the stock assessment directory. Some tweaking of the latex code was needed to work with bookdown and existing code. I then added the lua filter to the call to pandoc by bookdown. This allowed for the removal of the makefile. Though, I think I still need to add the sed call somewhere. At this point, tables were still not compliant.

jq

I found a stock overflow question regarding lua filter and tables. The user wanted to box in each cell of a table using pipes and hlines but didn't want to have to do this manually. Instead, they were looking for how to convert pandoc ASTs into json and then use jq to manipulate the resulting json. I did not need this much functionality, but it was good to learn what was going on. I was able to use their use of the $format structure within the AST RawBlock and then a call to sed, which was new to me. Pandoc uses longtable to convert markdown tables to longtable LaTex but if the table is already a longtable, then it leaves the AST format as latex and nothing is done, i.e., it doesn't get the table tag. So, I figured out how to use sed to find begin{longtable} and end{longtable} to insert the appropriate tags before and after the table. I am sure this will break at some point, well it already did when there was a mix of longtables and markdown tables. Nevertheless, it is a good start.

Unsolved mysteries

  • I cannot get linked text to work with the filter, only with bookdown.
  • Can I use a system call inside of R with the makefile to build compliant documents?
  • Add the sed call within the aacpdf makefile to some filter or something else
Clone this wiki locally