-
Notifications
You must be signed in to change notification settings - Fork 103
Description
This issue is for discussing the syntax for including images in odoc. Since the parser has been remerged into this repo, I open it here!
External and internal images
I would like to support "external" and "internal" images, just as for links. The "src attribute" for external images would be given as a link, and as a reference (to an asset) for internal images.
Alternative text
I think that we should encourage the use of an alternative text, for accessibility. The recommanded rules for alternative text are:
- A replacement for the image when the image is "informative"
- An empty alt text when the image is "decorative"
- No alt text when providing an alt text is not really possible (for instance, a user-uploaded image.)
In the case of odoc, I guess we can always provide an alt text (case 1 and 2), so the syntax should hopefully incentivize people to add one.
Compatibility with metadata extension
At some point, during the dev meetings and private discussions, the need to add metadata to the odoc language was mentioned (it first came when discussing how to specify alignments in table columns, in "heavy syntax").
Some things were mentioned:
{tag[key1=value1 key2=value2] content}. For instance{table[align="LCR"]...}.{{tag key1=value1 key2=value2} content}. For instance{{table align="LCR"}...}. This looks a bit similar to{{!ref}content}and{{:link}content}.
While this was only informal discussions, I think the new syntax for image should be designed not to prevent the addition of metadata!
The syntax
With these three requirements in mind, here is one proposition (option A) {{img!ref}alt text}:
Using a reference:
Home town: {{img!carouge.png}Carouge}.
Using a link:
Home town: {{img:http://carouge.com/carouge.png}Carouge}.
With an empty alternative text:
I lived in {{img!carouge.png}} Carouge.
I lived in {{img:http://carouge.com/carouge.png}} Carouge.
I think it is nice for the following reason:
- The syntax for external and internal images is quite consistent with links and references
- It incentivize people to write alternative text, as
{{img!ref}}feels wrong ({img!ref}could arguably be added). - It is compatible with at least one option for adding metadata:
{{img!carouge.png title="A photo of Carouge"}Carouge}
Other possibilities
- Option B:
{img{!ref}alt text}
Using a reference:
Home town: {img{!carouge.png}Carouge}.
Using a link:
Home town: {img{:http://carouge.com/carouge.png}Carouge}.
With an empty alternative text:
I lived in {img{!carouge.png}} Carouge.
I lived in {img{:http://carouge.com/carouge.png}} Carouge.
But that’s not great to add metadata
- Option C:
{img[!ref]alt text}
Using a reference:
Home town: {img[!carouge.png]Carouge}.
Using a link:
Home town: {img[:http://carouge.com/carouge.png]Carouge}.
With an empty alternative text:
I lived in {img[!carouge.png]} Carouge.
I lived in {img[:http://carouge.com/carouge.png]} Carouge.
With metadata
Home town: {img[!carouge.png title="A photo of Carouge"]Carouge}
Satisfy all criteria as well, but feels slightly more different from the rest of the syntax, since it introduces the brackets in tags. But, a serious candidate in my opinion :)
Conclusion
What do you think?