Nested parens in inline markup

Shaun McCance <shaunm at gnome.org>
Thu Feb 5 12:37:40 EST 2015

https://github.com/projectmallard/mallard-ducktype/issues/1

= Inline Test
Let’s put nested non-syntax brackets in an inline: $code(AddContact(ss)
→ (u)).

The first ) is parsed as closing the $code(. The correct way to write
this right now is $code(AddContact(ss$) → (u$)), escaping the right
parens. I could see this being a common gotcha, because parentheses are
rather common. Options:

1) Leave it as-is. Markup is markup, and sometimes you have to escape
stuff.

2) Change the bracket characters to {}, which are less common in normal
prose (though more common in code): $code{AddContact(ss) → (u)}.

3) Let you choose between {} and () for the bracket characters. I think
this is unambiguous, though I'd have to write the parsing code to be
sure.

4) Let you optionally double up parens to avoid escaping:
$code((AddContact(ss) → (u$))). Oops, still doesn't help when the
non-markup right paren is at the end. Also, if your content begins with
a left paren, you'll have to escape that to avoid the parser thinking
you've done double parens.

5) Keep track of non-markup parens so that $code(AddContact(ss) → (u))
actually works. I don't know if any other format does this. Seems simple
on the surface, but it could get hairy. Imagine a situation where you're
putting markup around unbalanced expressions:
WRONG:   $em(()parenthesized text where the parens are italic$em())
WITH #1: $em(()parenthesized text where the parens are italic$em($))
WITH #5: $em($()parenthesized text where the parens are italic$em($))

Thoughts?

--
Shaun