# RTE: cleanup imported document code

**URL:** https://meta.discourse.org/t/rte-cleanup-imported-document-code/386713
**Category:** Feature
**Tags:** composer
**Created:** [October 25, 2025, 7:20am UTC](https://meta.discourse.org/t/rte-cleanup-imported-document-code/386713 "2025-10-25T07:20:20Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Thomas\_Rother](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thomas_rother/32/423597_2.png) [@Thomas\_Rother](https://meta.discourse.org/u/Thomas_Rother)
#### Post date: [October 25, 2025, 7:20am UTC](https://meta.discourse.org/t/rte-cleanup-imported-document-code/386713/1 "2025-10-25T07:20:20Z")

</div>

I am currently moving some content from Dokuwiki ([https://www.dokuwiki.org/dokuwiki](https://www.dokuwiki.org/dokuwiki)) to Discourse. The Dokuwiki syntax is not clean markdown, therefore it needs manual editing. I normally use the old editor as I can see all characters there. But with the old editor I see strange “jumping effects”: when you mark a text block and try to format it, the cursor jumps up and down. Re-formatting of longer text is nearly impossible that way, as you always have to re-position your editing window again. It is hard to describe this, I could only show it with screencasts … The effect was describe earlier in [Cursor jumping around in composer / editor text box](https://meta.discourse.org/t/cursor-jumping-around-in-composer-editor-text-box/263017)

The RTE editor editor does not show this effect. But I am missing an option to clean up junky code imported from other systems …

---

<div class="post-metadata">

### Author: ![renato](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/renato/32/383632_2.png) [@renato](https://meta.discourse.org/u/renato)
#### Post date: [October 25, 2025, 10:40am UTC](https://meta.discourse.org/t/rte-cleanup-imported-document-code/386713/2 "2025-10-25T10:40:24Z")

</div>

Can you share what this junk code looks like?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [October 25, 2025, 4:14pm UTC](https://meta.discourse.org/t/rte-cleanup-imported-document-code/386713/3 "2025-10-25T16:14:34Z")

</div>

> [@Thomas\_Rother](#):
>
> I am currently moving some content from Dokuwiki ([dokuwiki [DokuWiki]](https://www.dokuwiki.org/dokuwiki)) to Discourse.

How much? Tens, hundreds, thousands of posts?

If it’s more than a few, it probably makes sense to get an import script to do it. If it’s not **that** many, then it likely still would make sense to get some code to fix the markdown rather than trying to edit it by hand. (An even more wacky solution would be to have a plugin handle the docuwiki edditites).

---

<div class="post-metadata">

### Author: ![Thomas\_Rother](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thomas_rother/32/423597_2.png) [@Thomas\_Rother](https://meta.discourse.org/u/Thomas_Rother)
#### Post date: [October 26, 2025, 7:14am UTC](https://meta.discourse.org/t/rte-cleanup-imported-document-code/386713/4 "2025-10-26T07:14:01Z")

</div>

Its not **that** many, but maybe enough, to think about a script-based/programatic solution. The tricky thing is that the code is dokuwiki syntax ( [https://www.dokuwiki.org/wiki:syntax](https://www.dokuwiki.org/wiki:syntax) ) plus enhanced UI code from a bootstrap3 template ([https://getbootstrap.com](https://getbootstrap.com)). It looks nice but I did not have content migration in mind when I’ve setted it up this way. The main issue is not the dokuwiki syntax, but the bootstrap

 … stuff. Code example:

`<div class="level1">&nbsp;</div> <h2 class="page-header pb-3 mb-4 mt-5">Plattenplatz ermitteln</h2> <div class="level2"> <p>Filtern auf ext4, was ist verf&uuml;gbar?</p> <pre class="code"> root@tokoeka ~ # df -h -t ext4 --total Filesystem Size Used Avail Use% Mounted on /dev/mapper/pve-root 196G 39G 148G 21% / /dev/md0 486M 400M 57M 88% /boot /dev/mapper/pve-data 3.0T 560G 2.3T 20% /mnt/data /dev/mapper/pve-backup 414G 40K 393G 1% /mnt/backup total 3.6T 598G 2.8T 18% - </pre> <p>&nbsp;</p> <p>Filtern auf ext4, was wird genutzt?</p> <pre class="code"> root@tokoeka ~ # df -h -t ext4 --output=used Used 39G 400M 560G 40K 598G </pre> <p>&nbsp;</p> </div>`

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [October 26, 2025, 11:38am UTC](https://meta.discourse.org/t/rte-cleanup-imported-document-code/386713/5 "2025-10-26T11:38:09Z")

</div>

Yeah. That’s a mess. You can probably spend a little time with nokogiri and get it into markdown.

---

<div class="post-metadata">

### Author: ![renato](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/renato/32/383632_2.png) [@renato](https://meta.discourse.org/u/renato)
#### Post date: [October 26, 2025, 2:03pm UTC](https://meta.discourse.org/t/rte-cleanup-imported-document-code/386713/6 "2025-10-26T14:03:27Z")

</div>

If you paste a clipboard with this exact `text/html` content in rich editor mode you get a content resulting in this markdown:

````markdown
## Plattenplatz ermitteln

Filtern auf ext4, was ist verfügbar?

```
 root@tokoeka ~ # df -h -t ext4 --total Filesystem Size Used Avail Use% Mounted on /dev/mapper/pve-root 196G 39G 148G 21% / /dev/md0 486M 400M 57M 88% /boot /dev/mapper/pve-data 3.0T 560G 2.3T 20% /mnt/data /dev/mapper/pve-backup 414G 40K 393G 1% /mnt/backup total 3.6T 598G 2.8T 18% - 
```

 

Filtern auf ext4, was wird genutzt?

```
 root@tokoeka ~ # df -h -t ext4 --output=used Used 39G 400M 560G 40K 598G 
```

````

It’s lossy regarding stuff we don’t care about (`div`s, `class`es, etc), but will understand `hN`, `pre`, or anything defined in our ProseMirror schema, respecting our [various editor extensions](https://github.com/search?q=repo%3Adiscourse%2Fdiscourse%20parseDOM&type=code) registering [`parseDOM`](https://prosemirror.net/docs/ref/#model.NodeSpec.parseDOM) definitions used by ProseMirror’s parser, including those from theme components or plugins.

As for the original request:

> [@Thomas\_Rother](#):
>
> But I am missing an option to clean up junky code imported from other systems …

I think when the rich editor is loading the document, it’s not this same HTML anymore, is it?

Because a post `raw` containing HTML blocks should be rendered as a “pass-through” code editor node:

 ![image](https://global.discourse-cdn.com/meta/original/4X/f/4/1/f41e0855510748f6b5c080ad0dd291b42809a0d7.png)

This can then be edited the same way it could in Markdown mode.
