Camen Design Forum

What convetion should be used for code and quote bbcode?

append delete Kroc

The reason I haven't implemented pre / code and quote bbcode yet is that I’m undecided on what convention I should use. I would not like to use a convention that requires typing a symbol every line, as this goes wonky and becomes difficult to manage if you delete / add text before submitting. Therefore, some sort of enclosing wrapper would be best.

Quotes:

It is important to note that quotes will have to contain nested quotes, so the syntax has to be such that this can be safely detected and rendered.

The most common type of quote convention is "[q]…[/q]". These are okay, but nothing too special. In ReMarkable, block quotes use pipes and tabs—off the cards here—but inline quotes use « … » or << … >>. These look nicer but are less commonly known.

PRE / Code:

There is a need to quote source code and other monospace text. In bbcode this is usually [code]. In ReMarkable it is `…` (samp) or ``…`` (code), and the pre "fence" for large blocks.

~~~>
…
<~~~

Pre fences have the benefit of being nestable, however this is not common in bbcode; most bbcode does not allow you to write unescaped bbcode, other than turning the whole feature off.

I am interested mainly in elegance, simplicity to type (most bbcode is clumsy) and a natural flow in text.

What are your thoughts?

Reply RSS

Replies

append delete #26. JJ

I think I should include the quote speech marks (styled differently) so that when you copy / paste someone else's quote, it retains the nesting.

And I just need to test it for good measure.

append delete #27. Jose Pedro Arvela

I know this is getting abusing, but I just want to test one more quote.

Hmmm, I'm still leaning toward simplicity for my vote. Maybe just don't worry about nested quotes/pres. It will even make the regexes faster and simpler. I can't imagine anyone complaining harshly about not being able to nest quotes.

However, if we really wanted to be intuitive about this, it could be possible to have the start of a blockquote be a line feed and a double quote, and the end be a double quote and a line feed:

Start parent quote

Nested quote here

End of parent quote

That should allow for nested blockquotes, and be fairly intuitive as well. It also for the most part wouldn't interfere with "inline quotes like this one".

Posted by JJ in forum.camendesign.com/…

append delete #28. Kroc

Abuse away! I’m sure it can be broken, but the regex-recursion pairing should make it pretty watertight for 99.9% of uses.

append delete #29. Kroc

JJ

Ahh, now I miss real regexes. Damn javascript.

Interesting note, you can include the poster’s name in your selection and the date / post-number don’t get copied :)

append delete #30. Jose Pedro Arvela

When discussing this with some people I know (I simply had to show them the incredibly simple and awesome implementation of quotes in here), they raised an issue, which is the impossibility of having a link to the original poster. While this is irrelevant in small conversations, it might be problematic in threads with 50+ posts from different people.

I was slightly worried with it until you included the name in the rest of the quote. Couldn't it be possible to implement some sort of hidden character after the username (or simply use the #29, etc) that would be converted to a link to the original comment in PHP? This way quoting is still intuitive and any long discussion is still manageable.

Example:
when copying "#29. Kroc ...", in the actual quote system, the #29. could have a link to the original comment by the person.

I think such system would allow to solve such problem while keeping this forum focused on the discussion itself and much intuitive.

append delete #31. Kroc

@Jose Pedro Arvela Great idea. Please file a bug accordingly and it will get done :)

append delete #32. Jose Pedro Arvela

#31. Kroc

@Jose Pedro Arvela Great idea. Please file a bug accordingly and it will get done :)

Done: github.com/… :D

append delete #33. Jose Pedro Arvela

Also, one more stress text I remembered:

Leaving the first line of the quote empty might be problematic.

On the other side, leaving the last line of the quote empty (with the exception of the quote element) might not be good either.

How about nesting quotes with only 1 line break instead of 2? (and how will the close quote handle?)
"Nested quote?"

What if someone joins 2 closing quotes in nested block quotes?

Like this?

append delete #34. Jose Pedro Arvela

Wow, the regexp handled that much better than I expected.

append delete #35. Kroc

That may not have come out quite how you intended, but at least it didn’t break the HTML, which is the idea.

append delete #36. JJ

Jose just got owned by Kroc's regex skills.

#37. Jose Pedro Arvela

This post was deleted by its owner

append delete #38. Jose Pedro Arvela

With the exception of the one in which I only place 1 line break before the nested quote (in which the quote was still completely comprehensible even if not showing exactly as a quote), everything used the proper formatting, in a flawless manner. Congrats! :D

Also:

#32. Jose Pedro Arvela

#31. Kroc

@Jose Pedro Arvela Great idea. Please file a bug accordingly and it will get done :)

Done: github.com/… :D

Also, new issue, links aren't quoted in their totality, and are cropped when quoted. (in the above quote, github.com/… would have become github.com/... )

append delete #39. Kroc

With the exception of the one in which I only place 1 line break before the nested quote

No, that’s normal.

Because you can insert single line-breaks.
"And then do this as part of normal text."

And it won’t break. Quotes must be separate.

append delete #40. Kroc

Also, new issue, links aren't quoted in their totality, and are cropped when quoted.

Big problem.

append delete #41. Jonhoo

Just to make sure I understand the quoting syntax correctly:
"This will not be displayed as a quote (single newline after other text)"

This will (preceeded by double newline)"
"Though I'm not sure about this? (single newline after quote)

Empty first lines do not pose problems?

Nor do empty last lines?

How are
multiline
quotes
handled?

Multiline

with empty line

Nested quotes with a single newline
"Second quote here"

Nested quotes with double newline

Second quote here

Nested quote with outer closing quote on separate line
"Second quote"

"And finally, what happens if I do not close my quote?

append delete #42. Jonhoo

Okay, so to sum up:
- nested quotes need a double newline before them - is this a necessary requirement?
- writing two quotes on lines that are next to each other (separate by a single newline) cause them to be merged with the ending quote of the first and the opening quote of the second visible

Otherwise, a very sturdy quoting mechanism methinks.

append delete #43. Kroc

Quotes require one blank line before them, and one blank line after them. That is all.

Quotes do not trigger on single lines on purpose.
You are allowed to use single line breaks in your normal prose.
Like this.
It adds dramatic effect.
I didn’t want the unexpected munging of people’s paragraphs
"when they don’t expect it."
Especially if they copy/pasted the text from somewhere else.

append delete #44. Kroc

I think I should include the quote speech marks (styled differently) so that when you copy / paste someone else's quote, it retains the nesting.

This has now been done. You can copy existing quotes and they will appear as before. The code ignores leading / trailing whitespace so if your webbrowser adds extra spaces before the quote marks, this isn’t a problem.

After a tense battle with the regex, I fixed an edge case, but I can’t tell if that opened any other issues. If quotes don’t do what you were expecting please let me know, thanks.

append delete #45. Kroc

“This has now been done. You can copy existing quotes and they will appear as before. The code ignores leading / trailing whitespace so if your webbrowser adds extra spaces before the quote marks, this isn’t a problem.”

Idiot, helps if I upload the code :P New generated quotes only.

append delete #46. Jose Pedro Arvela

I'm bumping this because I'd like to know if some syntax for code blogs has been defined already.

If nothing has been suggested, I'd like to remember you that it is important that we are capable of quoting someone and that code is kept in code blocks. So, I think something, even if reaching obvious redundancy, as <[CODE[ ... ]> might be simple enough to remember and might be possible to include in the post itself without looking awkward, perhaps in a stylistically good way too. It only worries me that this might be confused with other code (it could easily be confused with actual HTML...).

What we need to do is find something that looks like code (so people can actually relate it to code blocks), is intuitive, but isn't actually code, at least in the most common programming languages.

Jose Pedro Arvela added on

“It only worries me that this might be confused with other code (it could easily be confused with actual HTML...). ”

With this I meant that the parser might confuse the code inside the block with the actual opening/closing tags.

Furthermore, I doubt nesting code blocks is necessary, actually, I think it should be avoided, so we can perhaps use that to our advantage.

append delete #47. Kroc

Code blocks are one of the last major "must-haves" for NNF before I can consider it "done". We do need inline code and code blocks as people are inserting HTML and JS code into their posts and the hyperlink processing is breaking them.

Like quotes, it would be necessary for the code blocks to also display their delimiters when processed (as JPA mentioned), otherwise the code string could break the parser when being quoted, especially if there’s more than one code block in a quote.

Personally I prefer "~~~", but apparently this isn’t on all international keyboards. Since this delimiter has to be in the output, it needs to be minimal and thin, and not overpowering like ### or $$$.

other suggestions:

code
…
/end

% PHP
…
%

(where by you can write anything after the first % so that you can label what language it is as a guide)

append delete #48. Kroc

Any more comments on this before I implement this?

append delete #49. Jonhoo

Which style are you implementing?

append delete #50. Kroc

The last one I mentioned, using %. This is minimal and copy+pastes cleanly.

Reply

(Leave this as-is, it’s a trap!)

There is no need to “register”, just enter the same name + password of your choice every time.

Pro tip: Use markup to add links, quotes and more.

Your friendly neighbourhood moderators: Kroc, Impressed, Martijn