@@ -3,6 +3,7 @@ package org.wordpress.aztec.plugins.shortcodes
33import org.wordpress.aztec.plugins.shortcodes.extensions.ATTRIBUTE_VIDEOPRESS_HIDDEN_ID
44import org.wordpress.aztec.plugins.shortcodes.extensions.ATTRIBUTE_VIDEOPRESS_HIDDEN_SRC
55import org.wordpress.aztec.plugins.html2visual.IHtmlPreprocessor
6+ import org.wordpress.aztec.plugins.shortcodes.utils.GutenbergUtils
67import org.wordpress.aztec.plugins.visual2html.IHtmlPostprocessor
78
89class VideoShortcodePlugin : IHtmlPreprocessor , IHtmlPostprocessor {
@@ -11,12 +12,20 @@ class VideoShortcodePlugin : IHtmlPreprocessor, IHtmlPostprocessor {
1112 private val TAG_VIDEOPRESS_SHORTCODE = " wpvideo"
1213
1314 override fun beforeHtmlProcessed (source : String ): String {
15+ if (GutenbergUtils .contentContainsGutenbergBlocks(source)) return source
1416 var newSource = source.replace(Regex (" (?<!\\ [)\\ [$TAG ([^\\ ]]*)\\ ](?!\\ ])" ), " <$TAG $1 />" )
1517 newSource = newSource.replace(Regex (" (?<!\\ [)\\ [$TAG_VIDEOPRESS_SHORTCODE ([^\\ ]]*)\\ ](?!\\ ])" ), { it -> fromVideoPressShortCodeToHTML(it) })
1618 return newSource
1719 }
1820
1921 override fun onHtmlProcessed (source : String ): String {
22+ if (GutenbergUtils .contentContainsGutenbergBlocks(source)) {
23+ // From https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video
24+ // > Tag omission None, both the starting and ending tag are mandatory.
25+ return StringBuilder (source)
26+ .replace(Regex (" (<$TAG [^>]*?)(\\ s*/>)" ), " \$ 1></$TAG >" )
27+ }
28+
2029 return StringBuilder (source)
2130 .replace(Regex (" <$TAG ([^>]*(?<! )) */>" ), { it -> fromHTMLToShortcode(it) })
2231 .replace(Regex (" <$TAG ([^>]*(?<! )) */>" ), { it -> fromHTMLToShortcode(it) })
0 commit comments