Drupal is a registered trademark of Dries Buytaert

Introduction

The Markdown Importer module is a powerful tool for importing Markdown files into Drupal nodes. It supports integration with both GitHub and GitLab or Private hosted public repositories, making it easy to fetch and transform Markdown files into Drupal content types.

This module utilizes the league/commonmark Markdown parser library for accurate Markdown-to-HTML conversion and provides configuration options for custom content types and fields.

Features

  • Import Markdown files from GitHub and GitLab or Private hosted public repositories.
  • Automatically convert Markdown into HTML using the league/commonmark library.
  • Support for custom content types and target fields.
  • Recursive repository scanning for Markdown files in subdirectories.
  • Validation and error handling for invalid URLs or unsupported platforms.

Requirements

  • Drupal 10/11.
  • Composer (for library dependency management).
  • PHP 8.2 or later.

Installation

  1. Install the module as you would normally install a contributed Drupal module. See Installing Modules for details.
  2. Use Composer to install required dependencies:
    composer require league/commonmark league/commonmark-ext-heading-permalinks league/commonmark-ext-attributes
    

Configuration

Automatic Configuration

  • Upon enabling the module, a default form is provided at /admin/config/services/import-markdown to configure the import process.

Steps to Import Markdown

  1. Navigate to the configuration page for the module.
  2. Enter the Repository URL and select the Platform (GitHub or GitLab or Private hosted git repository).
  3. Choose the Content Type where Markdown content should be imported.
  4. Select the Target Field to store the Markdown content (e.g., body).
  5. Click Import Markdown to start the process.

AJAX-Driven Dynamic Selection

  • The module provides dynamic AJAX-based field selection to ensure compatibility with the selected content type.

Advanced Configuration

  • Customize the Markdown parser settings (e.g., for anchors and attributes) using hook_markdown_importer_config_modify() in a custom module.
  • Utilize the MarkdownProcessor service for programmatic imports.
  • Enable additional features like heading permalinks and custom attributes by modifying the league/commonmark configuration.

Additional Information

  • The module uses html_input: strip and allow_unsafe_links: false for secure Markdown parsing by default. See CommonMark Security Documentation for details.
  • Recursive scanning is enabled to fetch Markdown files from subdirectories of the repository.

Known Limitations

  • This module is currently not compatible with Markdown files containing advanced JavaScript or custom HTML tags unless configured explicitly.
  • Ensure repositories are publicly accessible, as private repositories require additional authentication handling (not included in this version).

Documentation

  • Full documentation is available in the module repository.

Activity

Total releases
3
First release
Dec 2024
Latest release
1 year ago
Release cadence
1 day
Stability
67% stable

Release Timeline

Releases

Version Type Release date
1.0.1 Stable Dec 11, 2024
1.x-dev Dev Dec 10, 2024
1.0.0 Stable Dec 10, 2024