markdown_importer
No security coverage
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/commonmarklibrary. - 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
- Install the module as you would normally install a contributed Drupal module. See Installing Modules for details.
- 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-markdownto configure the import process.
Steps to Import Markdown
- Navigate to the configuration page for the module.
- Enter the Repository URL and select the Platform (GitHub or GitLab or Private hosted git repository).
- Choose the Content Type where Markdown content should be imported.
- Select the Target Field to store the Markdown content (e.g., body).
- 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
MarkdownProcessorservice for programmatic imports. - Enable additional features like heading permalinks and custom attributes by modifying the
league/commonmarkconfiguration.
Additional Information
- The module uses
html_input: stripandallow_unsafe_links: falsefor 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.