Problem/Motivation
If you edit for example https://www.drupal.org/docs/develop/coding-standards/api-documentation-a... and click save without otherwise changing the page then the page will be completely broken. The edit history of the page shows you that at least 3 people have failed the same way already https://www.drupal.org/node/1354/revisions
Is this related to the Full HTML format?
Proposed resolution
Disable the WYSIWYG editor for pages in full HTML format.
Workaround in the meantime: disable javascript in your browser when editing a doc page. That way the WYSIWYG editor is not loaded and you can actually edit the page and only make the change you want to make.
Comments
Comment #2
wim leersInteresting enough, Gábor Hojtsy was complaining to me in chat about the very same thing while working on the Drupal 8.2 release notes.
Chat log:
Comment #3
gábor hojtsyYeah I turned off JS for drupal.org entirely to be able to edit/prepare the 8.2.0 release announcenent.
Comment #4
tvn commentedComment #5
tvn commentedThere was also a problem with this page which is not Full HTML: https://www.drupal.org/node/2116263/discuss
Comment #6
jonathan1055 commentedYes, I had this on https://www.drupal.org/docs/8/phpunit/running-phpunit-tests which really got messed up, for example two separate comand-line commands getting concatenated into one (non-sensical) command. I think I have fixed the page, but each time I did a preview my changes were reset, so it was tricky. I did not see this post until after, so did not try turning off javascript.
Comment #7
drummInline styles are an anti-pattern I don’t mind discouraging. I updated https://www.drupal.org/blog/drupal-8-2-0 with the WYSIWYG and almost all the styles remain. The differences are:
right&aside-halfclasses for this.Comment #8
drummI gave the same treatment to https://www.drupal.org/blog/drupal-8-1-0. Something confusing there is that preview and the first view after edit don’t show the video, presumably due to browser JS restrictions on POST, or something. The video does show on a normal page load.
Comment #9
drummThe remaining problems are #6 and the issue summary, clarifying the issue title.
For #6: the code filter treats
<code>tags as sometimes block-level, sometimes inline. The usual check is for a newline within the tag. CKEditor merges inline tags so you don't junk like<strong>a</strong><strong>b</strong>. So this should hit that edge case:<code>a<code>aFor the issue summary, yes editing code is broken. An extra newline is added above the code, and newlines within code are stripped. If I remove
$text = str_replace(' ', "\n", $text);fromcodefilter_prism_process_code(), the problem seems to go away. I’ll do a bit more checking to see if there are any side effects. See also #2704949: When using prism, the pre wrappers get infinitely wrapped on ckeditor.Comment #10
drummI deployed a new version of #2704949: When using prism, the pre wrappers get infinitely wrapped on ckeditor on Drupal.org and have edited https://www.drupal.org/docs/develop/coding-standards/api-documentation-a... with both the WYSIWYG and plain text, without disabling JS.
The page as it was did still confuse the thing pretty well, so I did end up reformatting it myself. I think reverting to a really clean version before documentation migration would have avoided this, but I didn't want to figure out the substantive changes. Hopefully the formatting is all good now.
Comment #11
drummI moved #7 into #2741227: Enable CKEditor for more content types since it is a bit of an edge case. Let’s consolidate future work in that issue.
Comment #12
tvn commentedWe should add one indeed, the new release announcement template is an example where we need it, I am sure there are/will be more cases. I'll add a note to #2741227 (don't want to start a whole new issue for this small thing).