-
Notifications
You must be signed in to change notification settings - Fork 560
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
[feature] Add =image to perl pod #18169
Comments
I appreciate the design proposed, and |
General comments:
I have a lot of questions that come up:
My biggest concern here is that it will promote a single, specific multimedia element as first-class in the POD specification. There are both additional types of multimedia elements, as well as elements that can replace this one. So why this one? What about them? My second biggest concern is that we might be growing here into an attempt to recreate arbitrarily complicated HTML using POD and I'm not sure we'll be able to do it. (It might not be exactly "arbitrarily complicated," but it sure can be. The example in the ticket includes |
@Grinnz I agree that breaking back compatibility is a thing better to avoid, but I also don't see a problem introducing it as it happened already with =head3 and =head4 back then. If old formatters emit a warning f.ex. "tag =image unknown" but will continue working that is even better I think, that way they send a signal to the user that update is needed |
@xsawyerx I see a need for local images, f ex when converting to latex or pdf, or using an offline documentation. I agree that local and remote subtags are somewhat inelegant, however I seriously doubt that one can (and for that matter, should) enforce a html-like schema where both local and remote images can be defined as a single unambiguous URI. F ex metacpan or github, when rendering a pod file as html, won't extract referenced images that are found correspondingly either in archive or in a repository, that might have different paths compared to where an image is to be installed locally. What I meant by INC is to define a local storage for a module, which is in my eyes falls quite naturally in $SITEPERL/lib/$MODULE . Many modules already install pod files there - would you consider that a malpractice too? I don't mind though extending =image with location rules other than INC, as long as this is standartized; I wish though this could be done easily because when one runs "perldoc foo", foo.pod is searched exactly in INC.
However I very much agree that =image and potential friends like =video could indeed begin to grow into an unmanageable set of features. That's why I'd rather keep =image spartan, confining it to the 4 options I outlined in the ticket: local, remote, text fallback, and no text fallback. Ah yes, a figcaption too; figcaption is nice. |
Previous discussion: metacpan/metacpan-web#1965 |
Are you suggesting that we decouple the concept of an image from HTML's If our If we're not coupling the suggested It's worthwhile researching how this is handled in other formats. We could try to steal from TeX, but here lie dragons. TeX is far more capable than Pod and we might be stea^Winspired by TeX but still be unable to properly import the full capability it has (coughPerl6cough). In Markdown, there is a syntax for images but I fear it suffers from the same problems of elevating certain HTML elements to first-class. Perhaps we could just follow Markdown in minimal support for images and the desire for more compatibility with Markdown to introduce it. |
I guess it was implicit, but yes, I do suggest to not copycat html's img tag and its properties. Moreover, I don't suggest to dive into devising a rich-enough specification, as this is going to open for 1) endless discussions and 2) will be too much tied up to html. For example, text support in html: it has all these great possibilities to set fonts, use text sub/superpositions, letter spacing, kerning and what not, and yet POD is just fine without these text features. So yes, I think that Markdown's minimal support for images is the way to go, Markdown did it right. I'm not really proficient in TeX/LaTeX, but I know how to deal with images in PDFs. That format has a rather unique set of image capabilities not necessarily available in html - it can apply arbitrary matrices, stencil masks, alpha masks, porter-duff operators (special alpha blendings), create filling patterns from images, and more. I think supporting these would be a serious overkill, and that is the same point of view I take when arguing against supporting all of html image functionality. |
Resolving relative references to images is something the parser will likely need to do (possibly as an option indicating a base URL for pod2html). I think a simple relative URL rather then distinguishing local and remote URLs would work. I expect most formatters would disable remote URLs by default to avoid remote images becoming an attack vector by default if some image library ends up with an attackable security issue. I'd be inclined to not support remote URLs at all, since some (most?) processors will need to fetch the URL to render the image, or even to just get the size for HTML. While I'd love images in POD, I'm not sure they belong in the format. |
@tonycoz As my concern with remotes is only for metacpan/github/etc online renderers, I do agree that remotes, as a general concept, should be out of the picture. But let's look at github f ex: if I want to include an image from the same repository, I need this URL:
whilte a pod itself, when rendered, is served from
On one hand I'd love to say just |
update:
So I guess remote and local could be indeed merged! This is great. Which means that we could also borrow from the markdown syntax and make images part of a text paragraph, not a paragraph on its own - with syntax like |
I think so. I also want pod syntax which can express image. |
Another point, the P<> syntax doesn't need to contain special text fallback. Because, contrary to the multitude of the graphical formatters, text can be addressed simply as
if so desired. I'm thinking about working on a patch however I don't want to find myself in a situation where it would be rejected or premature because the very topic is undecided yet. @xsawyerx what kind of consensus should be reached there for the green light, if any? |
Proposed changes to pod syntax should be run through the pod-people list before merging. |
The alt text could be expressed in the same way L<> does link text:
|
Hello again, After running the proposal through pod people, the idea I'm thankful for as it highlighted the flaws I wasn't aware of, and so here's the next version of the proposal. The consensus became a yaml embedded into 'image' formatter, like this:
or, for 90% of cases, simply
Apparently the yaml is also TMTWODI about multiline entries ( see https://yaml-multiline.info/ ), and what's more interesting, cpan's YAML doesn't understand neither of these, but that's not really relevant because YAML.pm is not in the core. The proposal is agnostic about multiline style. Pod people raised a concern about how to parse these YAML sections in core perl modules. It seems the most sensible solution would be to include a minimal Pod::Simple::YAML parser, just enough to parse 1-level deep structures found in the image section. The "src:" tag is to be used for both local and remote path, referring to the installation and/or distribution root. It will be the module author's job to make sure that, the image referred is installed in the same relative path as it is found in the distribution. The "text:" fallback will be produced by formatter that understands =image, but where graphic output is unavailable. The drawback is that old and non-conforming formatters will not display the fallback text The "resolution:" tag is to be used when the image size is important to match the text size. Formatters may use the value, in DPI, to scale the output image accordingly. The "title:" tag is to be displayed as a generic description of the image. For example XHTML may use The format is open for more tags, however I think these should be conservative - potential addition of "width: 90%" and "rotation: 45" and what not will complicate the things greatly; the rationale is to keep syntax rather terse, in the same vein as markdown's image syntax. In the output, an image will not be part of text, ie a floating image with f ex inline formula. An image will always end the current paragraph and will start a new one. Two =image blocks will be rendered as two separated paragraphs. It is proposed to adjust the core Pod::Simple so that it knows about the =image block, and will parse it so that the formatters don't need doing so. Pod::Simple creates an element tree and passes it to the formatters; these, in turn, should be adjusted to produce the corresponding output. Now, I hope I didn't forget anything. Kindly come with comments! |
@khwilliamson Karl, would that be okay to send a pull request for this feature in Pod::Simple? |
Adding YAML to Pod seems like over-complicating things. I had previously proposed a way to specify alternates where the Pod renderer would pick the first supported of several possible items it could render. The specific syntax I thought of probably isn't perfect. But that seems like it might be a better approach than creating a new way to embed text blobs in Pod. |
@haarg indeed, but that's apparently too limiting. There's no way to specify a title/footnote/figcaption which is really nice to have. Also, as pointed y pod-people, =for text is too limiting as well, it won't work for *roff f.ex. |
I do suggest sending a PR to Pod::Simple, and if people have comments on the specifics, they can do it there |
@khwilliamson Thank you, I (optimistically) understood your original answer as positive enough :) Here's the work in progress that I believe already resolved all potential problems, only tests, docs, and polishing left: https://github.com/dk/pod-simple/commits/master/lib/Pod/Simple . The individual commits are rather untidy, as it's more for myself, and when everything is ready I'm planning to kill this repository, fork it anew, and submit a pull request as one huge commit -- unless you would prefer the commits as they are now. New things introduced:
I also tested this on perl's Pod::Man that is not in the Pod::Simple distro, but it seems to be working. You're very welcome to take a preliminary look. |
Hello everybody, as promised, there's a pull request sitting at perl-pod/pod-simple#128 . The fork is at https://github.com/dk/pod-simple, you're welcome to review and play with it. The patch also opens the possibility to create html with images, but not by default. If you want to try pod2html you'll need this first:
|
Hello everyone, the patch seems to be stalled for unclear reasons, and my invitation for discussion why doesn't seem to be working. I'm sorry I'm not really good with soft skills so I don't understand why is that. Would someone kindly look at the status and see whether it is possible to promote the patch, or restart the discussion, or something else? |
FWIW, that's how feature requests in this project usually end up. We don't have a real feature proposal process, so in practice only committers get to propose and implement features. |
Regardless of what I said above, while people generally seem to like the idea of |
And that is why I have yet to merge this. I haven't had time to educate myself as to the issues involved. |
I think that is a fair assessment. |
Thanks everyone. It is though rather disheartening that the said opposition never uttered a word while the syntax was discussed and agreed on, and only did that after I put lots of efforts in the implementation and polishing and testing. I don't think I have energy for another round of discussion about what syntax would please the crown. Sorry. |
I propose an extension that, in spirit of "easy things easy", makes embedding of images in pod, well, easy.
Currently it is possible with a lots of ugly hacks, but the worst is especially knowing the formatted beforehand - f.ex. to show such a pod in github or metacpan requires magic like
=for html <p><img src="...png">
where you need to know that it is html, for example.
(see https://metacpan.org/pod/distribution/Prima/pod/Prima/Drawable.pod#Font-ABC-metrics as an example. It works but it is ugly).
In my experience an image tag should be able to do the following:
An =image tag, in full form, would be thus used like this, for example:
and also a short syntax for 90% of cases just as
This will break backward compatibility, but I'm decidedly not proposing a weaker but compatible option, such as f.ex.
because I think that images should no longer be hacks but rather 1st class citizens.
Let's discuss this
The text was updated successfully, but these errors were encountered: