rooofl Posted October 22 Share Posted October 22 Hello! I have a textarea field already full of Markdown content. My clients need it to have CKEditor on it. That may be a silly question, but I can’t figure out how to use CKEditor with Markdown. Is it possible to either: interpret Markdown in HTML on the fly, in the CKEditor field convert all Markdown in HTML so CKEditor fields show HTML as they are supposed to do (I guess) Thank you for your answers. Link to comment Share on other sites More sharing options...
wbmnfktr Posted October 22 Share Posted October 22 13 hours ago, rooofl said: interpret Markdown in HTML on the fly, in the CKEditor field I'm 99% sure there is no module or editor available that works like that - but a Markdown WYSIWYG would be a great addition. 13 hours ago, rooofl said: convert all Markdown in HTML so CKEditor fields show HTML as they are supposed to do About how many pages are we talking here? In case the number is way lower than 100 pages, a large strong coffee and a nice playlist would be a great start to copy everything over manually. If that's not possible or if there are more pages, you could try to update a real HTML field (TinyMCE nowadays, and not CKEditor anymore). In general this could work like this in a loop: // this duplicates the content in fieldname1 into fieldname2 for all pages with // the template called: templatename $source = "fieldname1"; $destination = "fieldname2"; $template = "templatename"; foreach($pages->find("template=$template") as $p) { // set outputFormatting to 'false' so the plain value is copied $p->of(false); $p->$destination = $p->$source; $p->save($destination); } See: https://processwire.recipes/recipes/duplicate-content-between-fields/ In your case we would need to tweak it a bit more and get the generated HTML first, then drop it into the new $destination field and go from there. BUT... from that moment the client should only be using the CKEditor/TinyMCE field and no markdown anymore. 1 Link to comment Share on other sites More sharing options...
rooofl Posted 3 hours ago Author Share Posted 3 hours ago Thank you @wbmnfktr for your answer. I think it is a bit more complicated than I thought. I understand what you wrote, and it totally make sense, but I think the economy will choose for me : keeping the markdown field as it is. However, I just discovered the module InputfieldEasyMDE, and that might be what I am looking for, as it keeps the markdown field content and just adds formatting options on a icon bar. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now