xref: /plugin/mdimport/README.md (revision 7cb424c90c7e1aca7edae5f79baaec2e55306143)
1*7cb424c9SSioc de Narf# mdimport plugin for DokuWiki
2*7cb424c9SSioc de Narf
3*7cb424c9SSioc de Narf**Import Markdown files directly into the DokuWiki editor.**
4*7cb424c9SSioc de Narf
5*7cb424c9SSioc de NarfThis plugin adds a toolbar button to the edit page, allowing you to select a Markdown (`.md`) file from your computer. The file's content is automatically converted to DokuWiki syntax and inserted at the current cursor position.
6*7cb424c9SSioc de Narf
7*7cb424c9SSioc de NarfAll documentation for this plugin is available at:
8*7cb424c9SSioc de Narf**[https://www.dokuwiki.org/plugin:mdimport](https://www.dokuwiki.org/plugin:mdimport)**
9*7cb424c9SSioc de Narf
10*7cb424c9SSioc de Narf---
11*7cb424c9SSioc de Narf
12*7cb424c9SSioc de Narf## Important – Folder Name
13*7cb424c9SSioc de Narf
14*7cb424c9SSioc de NarfIf you install this plugin manually, make sure it is placed in:
15*7cb424c9SSioc de Narf
16*7cb424c9SSioc de Narf    lib/plugins/mdimport/
17*7cb424c9SSioc de Narf
18*7cb424c9SSioc de NarfIf the folder is named differently, the plugin will **not** work!
19*7cb424c9SSioc de Narf
20*7cb424c9SSioc de NarfFor general information on installing extensions in DokuWiki, see:
21*7cb424c9SSioc de Narf[https://www.dokuwiki.org/extensions](https://www.dokuwiki.org/extensions)
22*7cb424c9SSioc de Narf
23*7cb424c9SSioc de Narf---
24*7cb424c9SSioc de Narf
25*7cb424c9SSioc de Narf## Features
26*7cb424c9SSioc de Narf
27*7cb424c9SSioc de Narf- **One‑click import** – Select a Markdown file from your computer, and its content is converted and inserted at the cursor position.
28*7cb424c9SSioc de Narf- **Full conversion** – Supports common Markdown elements:
29*7cb424c9SSioc de Narf  - Headers (`#` → `======`)
30*7cb424c9SSioc de Narf  - Bold (`**text**`), italic (`*text*`), inline code (`` `code` ``)
31*7cb424c9SSioc de Narf  - Links (`[text](url)` → `[[url|text]]`) and images (`![alt](url)` → `{{url|alt}}`)
32*7cb424c9SSioc de Narf  - Unordered and ordered lists (with nesting)
33*7cb424c9SSioc de Narf  - Tables (with column alignment)
34*7cb424c9SSioc de Narf  - Code blocks (with language hint)
35*7cb424c9SSioc de Narf  - Blockquotes and horizontal rules
36*7cb424c9SSioc de Narf  - YAML front matter (automatically stripped)
37*7cb424c9SSioc de Narf- **Live preview** – Conversion happens in the background via AJAX; the resulting DokuWiki syntax is inserted immediately.
38*7cb424c9SSioc de Narf- **Lightweight** – No external dependencies; pure PHP and JavaScript.
39*7cb424c9SSioc de Narf
40*7cb424c9SSioc de Narf---
41*7cb424c9SSioc de Narf
42*7cb424c9SSioc de Narf## Requirements
43*7cb424c9SSioc de Narf
44*7cb424c9SSioc de Narf- **DokuWiki** – any recent version (tested with **2025‑05‑14 “Librarian”** and later)
45*7cb424c9SSioc de Narf- **PHP** – 7.4 or higher (uses typed properties and `str_starts_with`)
46*7cb424c9SSioc de Narf
47*7cb424c9SSioc de Narf---
48*7cb424c9SSioc de Narf
49*7cb424c9SSioc de Narf## Installation
50*7cb424c9SSioc de Narf
51*7cb424c9SSioc de Narf1. **Download** the plugin from [GitHub](https://github.com/yourusername/dokuwiki-plugin-mdimport) or the [DokuWiki plugin repository](https://www.dokuwiki.org/plugin:mdimport).
52*7cb424c9SSioc de Narf2. **Extract** the contents into `lib/plugins/mdimport/` of your DokuWiki installation.
53*7cb424c9SSioc de Narf3. **Enable** the plugin via the DokuWiki extension manager (Admin → Extension Manager) or by setting `plugin»mdimport»enabled = 1` in the configuration.
54*7cb424c9SSioc de Narf
55*7cb424c9SSioc de NarfThe plugin should appear immediately on the edit page toolbar.
56*7cb424c9SSioc de Narf
57*7cb424c9SSioc de Narf---
58*7cb424c9SSioc de Narf
59*7cb424c9SSioc de Narf## Usage
60*7cb424c9SSioc de Narf
61*7cb424c9SSioc de Narf1. Open any page in edit mode.
62*7cb424c9SSioc de Narf2. Click the **“Import Markdown file”** button (�� icon) in the toolbar.
63*7cb424c9SSioc de Narf3. A file picker dialog opens – select a `.md` or `.txt` file.
64*7cb424c9SSioc de Narf4. The content is converted and inserted at the current cursor position.
65*7cb424c9SSioc de Narf
66*7cb424c9SSioc de NarfThe conversion uses an internal PHP class (`MarkdownToDokuWikiConverter`) and returns pure DokuWiki syntax, so you can further edit the imported text as usual.
67*7cb424c9SSioc de Narf
68*7cb424c9SSioc de Narf---
69*7cb424c9SSioc de Narf
70*7cb424c9SSioc de Narf## Supported Markdown Syntax
71*7cb424c9SSioc de Narf
72*7cb424c9SSioc de Narf| Markdown | DokuWiki | Notes |
73*7cb424c9SSioc de Narf|----------|----------|-------|
74*7cb424c9SSioc de Narf| `# Heading 1` | `====== Heading 1 ======` | Level 1–6 supported |
75*7cb424c9SSioc de Narf| `**bold**` or `__bold__` | `**bold**` | Same in both |
76*7cb424c9SSioc de Narf| `*italic*` or `_italic_` | `//italic//` | |
77*7cb424c9SSioc de Narf| `` `code` `` | `''code''` | |
78*7cb424c9SSioc de Narf| `[link](url)` | `[[url|link]]` | |
79*7cb424c9SSioc de Narf| `![alt](image.jpg)` | `{{image.jpg|alt}}` | |
80*7cb424c9SSioc de Narf| `- item` or `* item` | `* item` (unordered) | Nested lists use two‑space indentation |
81*7cb424c9SSioc de Narf| `1. item` | `- item` (ordered) | Ordered lists become DokuWiki unordered lists with a dash; numbering is not preserved |
82*7cb424c9SSioc de Narf| `> quote` | `>> quote` | |
83*7cb424c9SSioc de Narf| `---` | `----` | Horizontal rule |
84*7cb424c9SSioc de Narf| `` ``` `` | `<code>` and `</code>` | Language hint preserved (e.g., ` ```php `) |
85*7cb424c9SSioc de Narf| `\| Header \|` | `^ Header ^` | Table rows; alignment is detected from the separator line |
86*7cb424c9SSioc de Narf
87*7cb424c9SSioc de Narf> **Note:** DokuWiki’s syntax differs from Markdown in several places; the plugin aims for a sensible conversion, but always check the result before saving.
88*7cb424c9SSioc de Narf
89*7cb424c9SSioc de Narf---
90*7cb424c9SSioc de Narf
91*7cb424c9SSioc de Narf## Conversion Details
92*7cb424c9SSioc de Narf
93*7cb424c9SSioc de Narf- **YAML front matter** – If the file starts with a block delimited by `---` … `---` (or `...`), it is removed entirely.
94*7cb424c9SSioc de Narf- **Code blocks** – Opening and closing triple backticks are replaced with `<code>` and `</code>` tags. An optional language hint becomes a class (`<code php>`).
95*7cb424c9SSioc de Narf- **Tables** – The plugin detects the separator line (e.g., `|:---:|---:|`) and uses it to align columns (`^ left ^`, `^ center :^`, `^ right :^`).
96*7cb424c9SSioc de Narf- **Inline formatting** – Bold, italic, inline code, links, and images are converted as shown above.
97*7cb424c9SSioc de Narf- **Paragraphs** – Multiple lines of text are joined with a single space and separated by blank lines.
98*7cb424c9SSioc de Narf
99*7cb424c9SSioc de Narf---
100*7cb424c9SSioc de Narf
101*7cb424c9SSioc de Narf## License
102*7cb424c9SSioc de Narf
103*7cb424c9SSioc de Narf**Copyright (C) 2026 sioc-de-narf <sioc.de.narf@gmail.com>**
104*7cb424c9SSioc de Narf
105*7cb424c9SSioc de NarfThis program is free software: you can redistribute it and/or modify it under the terms of the **GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.**
106*7cb424c9SSioc de Narf
107*7cb424c9SSioc de NarfThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the [GNU General Public License](https://www.gnu.org/licenses/gpl-3.0.html) for more details.
108*7cb424c9SSioc de Narf
109*7cb424c9SSioc de NarfYou should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
110*7cb424c9SSioc de Narf
111*7cb424c9SSioc de NarfThe full license text is available in the `LICENSE` file included with this plugin.
112*7cb424c9SSioc de Narf
113*7cb424c9SSioc de Narf---
114*7cb424c9SSioc de Narf
115*7cb424c9SSioc de Narf## Author
116*7cb424c9SSioc de Narf
117*7cb424c9SSioc de Narf- **Name:** sioc-de-narf
118*7cb424c9SSioc de Narf- **Email:** sioc.de.narf@proton.me
119*7cb424c9SSioc de Narf- **Website:** [DokuWiki plugin page](https://www.dokuwiki.org/plugin:mdimport)
120*7cb424c9SSioc de Narf
121*7cb424c9SSioc de Narf---
122*7cb424c9SSioc de Narf
123*7cb424c9SSioc de Narf## Contributing
124*7cb424c9SSioc de Narf
125*7cb424c9SSioc de NarfFound a bug or want to improve the conversion? Feel free to open an issue or submit a pull request on [GitHub](https://github.com/yourusername/dokuwiki-plugin-mdimport). Contributions are welcome!