Closed edent closed 11 years ago
Might I suggest that instead of converting to <br>
, it's converted to <br/>
. I know that HTML5 doesn't require the XHTML-style self-closing tag, but having the self-closing tag means you won't piss off developers who are still bound to doctypes that require it.
Semantically speaking, it's probably better to \n
to <br/>
and \n\n
to <p>(content of line)</p>
.
Also agree about the self-closing tag. HTML5 supports an XML-parseable polyglot syntax, and the self-closing style is allowed under the doctype.
Also suggest that even single line posts are wrapped in a <p>
element.
That said, I'm not sure I'm totally keen on having a HTML version of the post content sent with the original content (I'm fairly certain this has already been discussed in issues #8 and #20) as then you're responsible for multiple versions of the same content.
Additionally, who's responsible for setting this? The client (which has to generate and send multiple versions of the same content)? The API (which has to generate multiple versions server-side)? Is it open to abuse? How about we have a markdown version of each post?
I'm going off the topic of this issue here.
I agree with <br/>. I can see the rationale for <p> as well, but are there restrictions in nesting <p> in other tags?
@abitgone I would expect clients to send plain text. The generated HTML is a best effort designed to reduce developer overhead & increase consistency.
@edent Marvellous. That's exactly what I would expect.
@edent Ideally, a post - especially a multiline post - should be contained in a block-level element, and if somebody's doing anything different to it, they probably won't be interested in the HTML anyway. <p>
will happily nest inside any block.
@edent Exactly what @cgiffard said – a <p>
element will happily nest inside any block-level element. Generally speaking, as long as the API and the output is clearly defined, designers will know what to do and what to expect.
We now translate \n ->
. This helps clients quickly present posts as html that looks very similar to the underlying post text. If clients want a more complex text -> html processing, they can customize that.
\n -> <br>
:) since I didn't remember you can type html here
If a user writes a post with newline characters (usually \n) that character is passed along in the 'text' field of the API response.
In the HTML response, it is also passed as "\n". I would expect that newlines be converted to <br> in the HTML representation.
Otherwise, clients have to implement nl2br (or their language's equivalent).
See https://alpha.app.net/edent/post/103821 for an example.