picocms / Pico

Pico is a stupidly simple, blazing fast, flat file CMS.
http://picocms.org/
MIT License
3.81k stars 616 forks source link

Self-closing img tag #650

Closed hack3r3d closed 1 year ago

hack3r3d commented 1 year ago

I don't know that this is the correct forum for this sort of question, but how to change pico so it doesn't self-close img tags?

PhrozenByte commented 1 year ago

What is a "self-closing img tag" (<img />?) and why do you want to change its behaviour?

hack3r3d commented 1 year ago

I don't want it to <img /> I want it to be <img></img> Why is because it's better html.

PhrozenByte commented 1 year ago

Why is because it's better html.

Even though <img></img> is valid XHTML, it actually is invalid HTML5:

Void elements only have a start tag; end tags must not be specified for void elements.

– Source: https://html.spec.whatwg.org/multipage/syntax.html#elements-2

Start tags must have the following format: …

  1. Then, if the element is one of the void elements, or if the element is a foreign element, then there may be a single U+002F SOLIDUS character (/). This character has no effect on void elements, but on foreign elements it marks the start tag as self-closing.

– Source: https://html.spec.whatwg.org/multipage/syntax.html#start-tags

Simply put: <img></img> is invalid HTML5, it must either be <img> (i.e. without a closing tag, but this is invalid XHTML), or <img /> (both valid XHTML and HTML5). So I'd recommend not to do stuff like that. <img /> is perfectly fine.

Anyway, you could extend Parsedown to transform your Markdown to whatever you like - or simply add the plain (X)HTML in your Markdown files.

hack3r3d commented 1 year ago

I don't want to get into a debate about html, but the answer it to extend Parsedown? The result I'm going for is just <img>Thanks.

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in two days if no further activity occurs. Thank you for your contributions! :+1: