gjbarnard / moodle-filter_synhi

Syntax highlighter
GNU General Public License v3.0
3 stars 2 forks source link

The EnlighterJS engine turns inline elements to block elements #2

Closed twhitehead closed 3 years ago

twhitehead commented 3 years ago

Noticed all my inline elements are being turned into block elements by the EnlightnerJS engine as shown in this screenshot from our moodle (clearly I didn't want ssh broken out into its own line each time!)

moodle-issue

From the manual, the first argument passed to the EnlightnerJS.init is a selector for block elements, and the second for inline elements. This plugin calls EnlightnerJS.init with the same pre (block) and code (inline) selector specification for both

EnlighterJS.init('synhi pre, synhi code', 'synhi pre, synhi code', {theme: '".$config->enlighterjsstyle."', indent : 4});

I expect this is can be resolved by simply only specifying the block elements (pre) for the first and only the inline elements (code) for the second

EnlighterJS.init('synhi pre', 'synhi code', {theme: '".$config->enlighterjsstyle."', indent : 4});
gjb2048 commented 3 years ago

@twhitehead Thanks for the patch, please could you supply some testing instructions and data.

twhitehead commented 3 years ago

No problem, and thanks for the very quick reply. If you create a moodle page in html mode (e.g., a lesson) with the following context

You can run the command <code>ls -l</code> to list all your files in long format.

and enable your plugin with the EnlighterJS engine, you should see that it renders the inline command as a block item (i.e., on its own line) like so

You can run the command
ls -l
to list all your files in long format.

instead of an inline (i.e., inside the line) like it should

You can run the command ls -l to list all your files in long format.

Reloading the page (possibly a shift+F5 will be required to avoid the browser caching the old version) after applying the patch should fix this.

gjb2048 commented 3 years ago

@twhitehead Sorry for the delay, just tested and accepted. Thanks for the test information. I'll just need to update the PHPUnit test. Also, I tested on M3.11, so the filter should be ok there too.

twhitehead commented 3 years ago

No worries. That was plenty quick. :grin:

Thanks so much for doing the testing for me.

gjb2048 commented 3 years ago

@twhitehead No problem, I've just credited you in the readme and I'm going to do a proper release on Moodle.org soon.

gjb2048 commented 3 years ago

@twhitehead FYI: https://moodle.org/plugins/filter_synhi/3.7.1.2/24260.

twhitehead commented 3 years ago

Excellent. I'll see if our admin will update us now! Thanks again. :smile: