Plugins and Filters and Data Science: Displaying R Markdown in Drupal

Co-Presenter(s):
n/a

This session is a case study in using the Drupal 8 Filter API and Plugin API to render R Markdown research publications for the National Center for Charitable Statistics (NCCS).

The Urban Institute has 12 policy centers and several more programs and initiatives. We publish new research almost daily. Historically, most of those publications have been PDF's. Recently, some Urban researchers, with assistance from our Communication and Data Science teams, have successfully implemented an R-based "pipeline" that can generate publications in multiple formats, including PDF (which we still use), HTML, and Markdown.

I'd like to talk about how we handled the challenges we faced when displaying generated Markdown and HTML within a "parent" Drupal site. The most feature-rich example so far is found on The Nonprofit Sector in Brief 2018.

The story behind that publication (with good info about how they used R to create it) can be found on our Data@Urban blog.

Our solution has two main components:

1. Design System and Bootstrap 4: documenting our design system, including utility classes provided by bootstrap provided content contributors with guidance on basic formatting. This is mostly useful for table formatting (and we do a lot of tables). I would touch on this briefly, but the focus of the talk is on . . .

2. Filters and Plugins: We implemented several contrib filters and augmented with our own custom plugins. For this particular project, the Drupal 8 Filter API and Plugin API was incredibly useful. We even found a way to make a filter configurable by node! This is the "meat" of the session, where we'll cover:

  • Filter Overview
  • Our config and contrib selections
  • Generate plugin with drupal console
  • Extend FilterBase class
  • How to use DOMDocument to parse and replace HTML
  • How to make a filter configurable per node.
  • BONUS: Can't you just use JavaScript? (why we chose not to on this one).

The challenges, and our approach is described in more detail in the attached word doc. Not only do I not have a presentation available for you, I don't even have a complete blog post! The attached, in-progress, post is slated to be published on Data@Urban later this year. 

If you are interested in this topic, or session, I will happily assemble the necessary materials for a great talk. If this isn't quite enough for you to accept or to consider accepting, I totally understand. This would be my first Drupal talk after 10+ years building and maintaining Drupal sites. I think this is a great topic and would be interesting for this audience. Of course, I'm also open to your feedback.

I hope you'll consider this session proposal. If not, please consider me for any panels that may need another voice. Thank you for your consideration.

Audience
Experience Level
Beginner