New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Completely rewrote shortcode parser. #2200
Conversation
|
||
|
||
def _format_position(data, pos): | ||
"""Return position formatted as line/column.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could use a note that this is for pretty error messages.
args.append(cname) | ||
|
||
return name, (args, kwargs) | ||
empty_string = data[:0] # same string type as data; to make Python 2 happy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think ''
will be enough in our case. By the way, this file didn’t have a from __future__ import unicode_literals
import — I just fixed that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes some test fail, since it always returns a unicode string. My final fix makes it return the same string type as the input was. But we could of course also fix the tests :)
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
|
You can also replace About large inputs: since it uses |
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
Would you mind adding tests (real tests, not doctests!) for all the things this parser fixes? |
I found some more bugs, improved some error messages, and added proper tests. |
LGTM, anybody else? |
LGTM too. Merging. |
Completely rewrote shortcode parser.
@felixfontein how could we expand on this to make it handle both hugo shortcode cases?
/me is totally dumb about parsers and stuff. No computer-thingies college courses, see ;-) |
Let’s not do |
We could use a different marker. On Mon, Jan 4, 2016 at 12:46 PM Chris Warrick notifications@github.com
|
Is % really not enough? On 4 January 2016 at 20:23, Roberto Alsina notifications@github.com wrote:
Chris Warrick https://chriswarrick.com/ |
We might already have some problems, if you write something along It would be better to first replace the shortcodes with some unique IDs, then use markdown, and finally replace the markers by their transformed content. This would also make it trivial to implement support for |
The reason for "shortcodes with markup inside them" is pretty good. Imagine you want to make a paragraph be a bootstrap warning panel, or whatever. You could do this:
Requiring the content of the shortcode not be processed by the compiler makes this usecase suck. |
This PR fixes some shortcomings in the current shortcode parsers:
{{% a "%}}" %}}
is parsed as expected;==> {{% <==
;{{% a "b"c"d" %}}
aren't allowed anymore.