text2qti icon indicating copy to clipboard operation
text2qti copied to clipboard

Allow image size to be changed

Open gordonwatts opened this issue 3 years ago • 5 comments

There are times that images on disk aren't the proper size (too big?) to be displayed in the exam. The Canvas quiz-question editor allows one to change the image size by hand. Short of using a full <img ... .> tag in your markdown there isn't a way to do that inline in hte markdown.

gordonwatts avatar Mar 15 '21 04:03 gordonwatts

One possible solution is to use the markdown extension called attr_list, which allows you to set attributes for a html element created in markdown. This is part of the markdown processor that text2qti is already using; it is just a matter of turning it on.

This commit to my fork of text2qti does that.

If you are interested in this as a solution to this problem (or any other generic one that attributes might solve), I'm happy to submit a PR.

gordonwatts avatar Mar 15 '21 04:03 gordonwatts

Support for attributes in general is a good suggestion. I think I looked at the attr_list extension once, but didn't turn it on because I'm trying to keep everything as compatible as possible with Pandoc Markdown. I just took a quick look at the attr_list extension source (https://github.com/Python-Markdown/markdown/blob/master/markdown/extensions/attr_list.py). It would probably be easy to create a custom version that is more or less compatible with Pandoc. Basically, swap opening delimiter from {: to { and then limit what can have attributes. I suppose it would also be possible to add an option to enable the existing attr_list as-is.

gpoore avatar Mar 15 '21 16:03 gpoore

Ok - finished finals for this quarter.

If it is possible to change, then I'd suggest not using the { since other things are changing because that is a special character to python (in f-strings).

I'm ok with creating a new flag and turning on and off attr_list. If you are interested in that PR let me know. If you want to modify attr_list' source, that might require a little more work, and perhaps should be done with pandoc in mind (and I've never used pandoc).

gordonwatts avatar Mar 19 '21 07:03 gordonwatts

I've added support in the last commit for Pandoc-style attributes on images. This is similar to attr_list, but uses {<attrs>} instead of {:<attrs>}. Currently, attributes are only supported on images, but that can be easily extended in the future. Since the syntax is compatible with Pandoc, this feature automatically works with solutions export.

gpoore avatar Apr 19 '21 04:04 gpoore

I think this takes care of this - thanks! Feel free to close this!

gordonwatts avatar Apr 22 '21 03:04 gordonwatts