I'm surprised I never implemented the "PASS" keyword after the pipe, which would
allow you to do a one-liner that doesn't force you to add  .
This is valid syntax, but less than ideal:
#ajax1
PASS
#ajax2
PASS
You can probably patch this regex in your local version of shpaml:
@syntax('(.*?) \| (.*)') def TEXT_ENCLOSING_TAG(m): tag, text = m.groups()
return enclose_tag(tag, text)
I think you want to insert "(?:PASS$)" into the syntax,
@syntax('(.*?) \| (?:PASS$)?(.*)')
>>> re.match('(.*?) \| (?:PASS$)?(.*)', "div | PASS").groups() ('div', '') >>>
>>>re.match('(.*?) \| (?:PASS$)?(.*)', "div | desired content").groups() ('div',
>>>'desired content')
span | PASS
...is that you would no longer be able to produce this html with a one-liner
<span>PASS</pass>
It's probably rare that you'd need that, so the patch is probably worthwhile for
you, but it would be potentially problematic for other users.
The other syntax that you tried, which was to assume that div shortcuts apply
after "> ", might not be as problematic.
This is the method that manipulates lines with text to the right of the angle
bracket:
@syntax('> (.*)') def SELF_CLOSING_TAG(m): tag = m.group(1).strip()
return '<%s />' % apply_jquery(tag)[0]
You probably add these two lines before the "return" statement:
if DIV_SHORTCUT.match(tag): tag = 'div' + tag
I haven't tested it, though. I also haven't thought through all the
implications, but it seems innocuous enough.
Intuitively the following should work:
> #outer > #inner
should translate to
<div id="outer"><div id="inner" /></div>
And
#outer > #inner |
should translate to
<div id="outer"><div id="inner"></div></div>
IIRC, both aren't handled as expected (some or all of it is treated as a
literal rather than as SHPAML).
Adding this behaviour would therefore create no problems with backwards
compatibility without adding new symbols.
Cheers,
Ashmoi
#one > #two > #three |
The trailing bar, even if followed by whitespace, won't be handled as
expected.
Any reason this shouldn't be handled the same as a bar followed by
actual content?