Skip to content
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

Use a custom shortcode parser #2194

Merged
merged 3 commits into from Dec 24, 2015
Merged

Use a custom shortcode parser #2194

merged 3 commits into from Dec 24, 2015

Conversation

@Kwpolska
Copy link
Member

Kwpolska commented Dec 24, 2015

This replaces the cheat involving the HTML parser with a custom character-based parser, written in pure Python.

Advantages:

  • Support for positional arguments with spaces through quotes and backslashes
  • Does not use a hack that works by luck

Disadvantages:

  • the code is a bit ugly
Kwpolska added 3 commits Dec 24, 2015
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
@Kwpolska Kwpolska added this to the v7.7.5 milestone Dec 24, 2015
# Space inside unquoted name: save as positional argument
args.append(cname)
cname = cvalue = qc = ''
elif char == ' ' and flag == 1:

This comment has been minimized.

Copy link
@felixfontein

felixfontein Dec 24, 2015

Contributor

If you use binary notation above, why not here (and in the following cases) as well?

This comment has been minimized.

Copy link
@Kwpolska

Kwpolska Dec 24, 2015

Author Member

I’ll drop the binary notation then; it felt more readable to me in this case.

This comment has been minimized.

Copy link
@felixfontein

felixfontein Dec 26, 2015

Contributor

Why not use binary notation everywhere? That makes it more readable for everyone!

This comment has been minimized.

Copy link
@Kwpolska

Kwpolska Dec 27, 2015

Author Member

A bit too much cruft for me. If you really want that, you can make everything binary.

@ralsina
Copy link
Member

ralsina commented Dec 24, 2015

LGTM

ralsina added a commit that referenced this pull request Dec 24, 2015
Use a custom shortcode parser
@ralsina ralsina merged commit 5bc23e3 into master Dec 24, 2015
4 checks passed
4 checks passed
continuous-integration/appveyor/branch AppVeyor build succeeded
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
if flag & 0b100 and flag & 1:
# Backslash in value: escape next character, no matter what
cvalue += char
flag -= 0b100

This comment has been minimized.

Copy link
@felixfontein

felixfontein Dec 24, 2015

Contributor

Why do you use + and - for bit operations instead of &, | and ~?

This comment has been minimized.

Copy link
@Kwpolska

Kwpolska Dec 24, 2015

Author Member

Because I was too lazy to come up with the bitwise operations needed, and because ± is good enough for this case. Fixed on master.

@ralsina ralsina deleted the shortcode-parser branch Dec 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.