GithubHelp home page GithubHelp logo

dmulholl / shortcodes Goto Github PK

View Code? Open in Web Editor NEW
18.0 3.0 9.0 463 KB

A customizable shortcode parser in Python.

Home Page: http://www.dmulholl.com/dev/shortcodes.html

License: The Unlicense

Python 100.00%

shortcodes's Introduction

Shortcodes

A Python library for parsing customizable WordPress-style shortcodes.

shortcodes's People

Contributors

dmulholl avatar gvwilson avatar sybrenstuvel avatar

Stargazers

 avatar Zach Johnson avatar Damjan Malis avatar Son Tu avatar Nick Moreton avatar Dejan Noveski avatar Bob Blanchett avatar  avatar Samidhya Sarker avatar Wassim Boussetta avatar Trevor avatar Arseny Gabdullin avatar Gary Wu avatar Chris Amico avatar Shantanu Oak avatar  avatar Jake Hickenlooper avatar Dewang Mistry avatar

Watchers

Shantanu Oak avatar  avatar  avatar

shortcodes's Issues

Python 2.7 support

Would it be possible to support Python 2.7? I know it's almost deprecated, but there is some stuff running on it, and I can't imagine it being too hard to do using the six module...

Feature Request: Processing the outermost shortcode first?

Hi,

First, thank you for making such a great library! It is the backbone of the Unprompted templating language for Stable Diffusion.

It has proven itself both flexible and reliable, however there is one limitation I've had to carefully work around: the inability to process an outermost shortcode first.

My project has evolved into a pseudo-programming language with conditional shortcodes like [if] and [switch] that, by design, must defer or outright skip processing of inner content.

Assuming this isn't already possible, I was hoping you could point me in the right direction for implementing such a change. I understand if it's not something you would implement yourself--my use case of the library is definitely unusual--but I'd appreciate your thoughts. Is it something that could be added without inverting the entire flow of parse()?

Thanks!

Non-ASCII text is broken

The decode_escapes() function breaks non-ASCII text. For example, decode_escapes('ü') returns 'ü'.

Tested on Python 3.6.3 on Ubuntu Linux.

don’t intercept exceptions in AtomicShortcode and BlockShortcode

hi,

first and foremost: thank you for working on this library.

while looking at the code (and integrating it into one of my django apps) i noticed that you except any kind of exception in AtomicShortcode and BlockShortcode with no possibility to opt-out from this behaviour.

imho you should’t catch exceptions at all at this point. in fact the way you handle them now even hides SyntaxError exceptions. in my case i wanted to raise a specific exception that is handled by one of the django middlewares. this is impossible because the exception in my shortcode is already handled by the render function in AtomicShortcode. all i have now is a RenderingError that doesn’t help much :).

i see a few options for resolving this:

  • don’t catch exceptions in AtomicShortcode and BlockShortcode
  • allow users to configure the behaviour when registering the shortcode
  • expose a custom exception class that users can subclass and that is ignored by your exception handler function

if you tell me which option you prefer i may be able to submit a pull request :).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.