Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add image alignment parameter #23

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ech0-de
Copy link
Contributor

@ech0-de ech0-de commented Jun 4, 2023

One limitation of this plugin in contrast to dokuwiki's native markup is that images can't be aligned. This pull request adds another image query parameter for image alignment, which is then translated to dokuwiki's image alignment by adding spaces before or after the image url.

For example ![](test.jpg?align=right) is translated into {{ test.jpg?align=right}}. The parameter itself is then ignored by dokuwiki.

Image alignment in commonmark seems to be a controversial topic and my approach is adding a behavior that is not compatible with regular commonmark. I don't see any harm in doing this, since other dokuwiki specific query parameters (such as width and nolink) are also supported. But maybe this change is not desired.

@clockoon
Copy link
Owner

Thanks for good suggestion. This plugin intends to support Commonmark syntax to DW, but not vice versa. As you mentioned, setting image attributes by Commonmark markup is not supported. Using HTML tag is recommended, but not a suitable solution to DW usages.

Appending attributes in URL is one good way to implement such features for internal image link, but I think it has uncertainty in external images, because the URL query strings are unpredictable. Instead, I think following two alternatives would be better, based on your suggestion:

  1. Make the syntax supporting only on internal image, and retain policy for external image with original Commonmark syntax. It’s intuitive but would arise little confusion.
  2. Adding attributes on alt/caption area. For example: ![caption?width=100px&align=center](URL) or ![caption|width=100px&align=center](URL). Attribute strings would be removed when converted to DW, and remain after Commonmark rendering as caption, but image itself should be rendered correctly. This way is more complicated, but easier to bypass the conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants