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

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

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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@ralsina ralsina merged commit 5bc23e3 into master Dec 24, 2015
if flag & 0b100 and flag & 1:
# Backslash in value: escape next character, no matter what
cvalue += char
flag -= 0b100
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 December 24, 2015 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants