Giter VIP home page Giter VIP logo

django-precise-bbcode's People

Contributors

dependabot[bot] avatar ellmetha avatar ilar avatar robvdl avatar slasyz avatar thorrak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-precise-bbcode's Issues

Too many <br> tags.

django have template tags linebreaks and linebreaksbr.

I use TextField for store my post. in template {{ post.content|safe|bbcode }}, if I input many enter for linebreak, bbcode template tag convert it to too many
tag.

so, I wish bbcode template tag can parse it like linebreaks, not linebreaksbr

thanks

Rendered output is in quotes

Whenever I render a text field(via the template filter) or if I use a BBCodeTextField and use .render both output with surrounding double quotes. Thus not applying the tags
Example:
If the field holds: [b]Hello[/b]
The output would be: "<strong>Hello</strong>"

Django 1.9 warning

In Django 1.9 django.db.models.get_model is removed in favour of the AppConfig (app.get_model(...)). On Django 1.8 the following warning is now spit out:

/path/to/venv/lib/python2.7/site-packages/precise_bbcode/bbcode/__init__.py:115:     RemovedInDjango19Warning: django.db.models.get_model is deprecated.
  SmileyTag = get_model('precise_bbcode', 'SmileyTag')

Custom tag doesn`t render

issue
Custom tag renders when it's content contains one line, but when it's content contains more, than one line it doesn't render. If I turn 'End tag closing' off, it renders, but it contains one line in html.
P.S. Sorry for my English.

Django precise_bbcode not properly parsing contents of [code] tags?

If I provide the input:
[code] for i in var: print(var[i]) [/code]

precise-bbcode does not actually format that line as code (and it remains as plain text).
This has been the case for over a year.

So after digging through the source I have found a few lines that after changing got things working correctly.

I have provided a fix for this issue here.

But I am unsure if this is the proper way to solve the issue.

Error on Django 3

Running from master:

  File "/.direnv/python-3.8.1/lib/python3.8/site-packages/precise_bbcode/fields.py", line 6, in <module>
    from django.utils.encoding import python_2_unicode_compatible
ImportError: cannot import name 'python_2_unicode_compatible' from 'django.utils.encoding' (/.direnv/python-3.8.1/lib/python3.8/site-packages/django/utils/encoding.py)

Django version 3.0.2

Error: reduce() arg 2 must support iteration

I just added this package to a new Django 4.2.4 install and am getting reduce() arg 2 must support iteration using the example provided in the docs:

{% load bbcode_tags %}
{{ "[b]Write some bbcodes![/b]"|bbcode }}

Seems to be in precise_bbcode/core/utils.py, line 10

Smiley Link not working.

I have added a smiley via the django admin area. THe issue is when I add it to my site using the code i created it does not show up. It cant even find it. I can find it on the local machine uploaded to the directory but it won't render on screen.

issuewithsmilies

being rendered

As you can see it was uploaded to the project folder. But it wont load..
inprojectfolder

add bb code options support

Hi, thanks for application!
But, can you add options support for precise-bbcode?
Example:
[codepen author=test]text[/codepen]
Thanks!

SyntaxWarning on Python 3.12

I'm checking if I can upgrade a project to Python 3.12 yet, and while doing so, this library shows some syntax warnings:

2.508 /usr/local/lib/python3.12/site-packages/precise_bbcode/bbcode/placeholder.py:37: SyntaxWarning: invalid escape sequence '\w'                                                            
2.508   if not re.match('^[\w]+$', new_placeholder.name):                                                                                                                                     
2.510 /usr/local/lib/python3.12/site-packages/precise_bbcode/bbcode/tag.py:46: SyntaxWarning: invalid escape sequence '\s'                                                                    
2.510   if not re.match('^[^\s=]+$', new_tag.name):   

I believe these should be updated to raw strings, so adding a r -prefix should be sufficient.

BBCode editor somewhere/in the works?

Hi,

I was wondering if you know of any BBCode editor that supports selecting text in the input/textarea and then clicking a BBCode tag button to apply it to the selection, similar to how phpBB3 does it for example.

If it doesn't exist, I will probably write it for my own project and will contribute back to upstream then. If it does exist or is in the planning, that'd be good to know to avoid doing duplicate work!

Tags with a dash inside doesn't work [b]-[/b] or [b]--[/b]

This is a bit of a weird edge case, but after changing one of my sites to this library after the current one was no longer viable, I noticed that only a tag with a dash or multiple dashes inside won't get processed.

What works:

[b]a[/b]
[b]a-[/b]
[b]-a[/b]

What doesn't work:

[b]-[/b]
[b]--[/b]

It's a bit of an edge case though, not very common thing to do but a user did this :)

Can't add a new object - RuntimeError: 'path' must be None or a list, not <class '_frozen_importlib_external._NamespacePath'>

I get this:

  File "/app/apps/posts/forms.py", line 19, in save
    instance.save()
  File "/usr/local/lib/python3.5/site-packages/django/db/models/base.py", line 806, in save
    force_update=force_update, update_fields=update_fields)
  File "/usr/local/lib/python3.5/site-packages/django/db/models/base.py", line 831, in save_base
    update_fields=update_fields,
  File "/usr/local/lib/python3.5/site-packages/django/dispatch/dispatcher.py", line 193, in send
    for receiver in self._live_receivers(sender)
  File "/usr/local/lib/python3.5/site-packages/django/dispatch/dispatcher.py", line 193, in <listcomp>
    for receiver in self._live_receivers(sender)
  File "/usr/local/lib/python3.5/site-packages/precise_bbcode/fields.py", line 136, in process_bbcodes
    parser = get_parser()
  File "/usr/local/lib/python3.5/site-packages/precise_bbcode/bbcode/__init__.py", line 23, in get_parser
    loader.load_parser()
  File "/usr/local/lib/python3.5/site-packages/precise_bbcode/bbcode/__init__.py", line 42, in load_parser
    self.init_bbcode_placeholders()
  File "/usr/local/lib/python3.5/site-packages/precise_bbcode/bbcode/__init__.py", line 75, in init_bbcode_placeholders
    placeholders = placeholder_pool.get_placeholders()
  File "/usr/local/lib/python3.5/site-packages/precise_bbcode/placeholder_pool.py", line 73, in get_placeholders
    self.discover_placeholders()
  File "/usr/local/lib/python3.5/site-packages/precise_bbcode/placeholder_pool.py", line 33, in discover_placeholders
    load('bbcode_placeholders')
  File "/usr/local/lib/python3.5/site-packages/precise_bbcode/core/loading.py", line 37, in load
    get_module(app, modname)
  File "/usr/local/lib/python3.5/site-packages/precise_bbcode/core/loading.py", line 23, in get_module
    imp.find_module(modname, app_path)
  File "/usr/local/lib/python3.5/imp.py", line 270, in find_module
    "not {}".format(type(path)))
RuntimeError: 'path' must be None or a list, not <class '_frozen_importlib_external._NamespacePath'>

I use Python 3.5 and Django 1.11. I followed the docs (nothing complicated):

content = BBCodeTextField(verbose_name='content')

But in my tests when I send a POST:

post_data = {
    'title': 'Test title with ล‚',
    'categories': [category.pk for category in categories],
    'tags': tags,
    'content': 'Hello world!',
}

response = self.client.post(self.url, post_data)

I get above error. The only custom thing is in my form:

def save(self, commit=True):
    instance = super().save(commit=False)
    instance.slug = slugify(instance.title, only_ascii=True)
    instance.status = Post.STATUS_CHOICES[0][0]

    if commit:
        instance.save()
        self.save_m2m()
    return instance

Any idea what that can be?

escape bbcode option for tags?

First of all, I'm using this project in a custom forum board software, and it works wonders. I've never had any problem using it and the documentation is great, so thank you very much!

One question I have is if there is a way that I can 'escape' bbcode within certain tags, for instance I have a thread on the forum that shows all of the supported bbcodes and how to use them. I'd like to be able to do something like:

[b]Example[/b]
[code][b]Example[/b][/code]

Where the code tag shows [b]Example[/b] rather than a bolded "Example"

Is there any way that I can accomplish this?

A BBCode tag with this name appears to already exist

Hey guys,

i have the same error how here with the current version (1.0.8) and Django 1.8. I can create a Custom BBcode. After delete of this, i can not create a new BBcode with the same Tag. A restart of Django solve this error.

Is this a Issue or a failure on my site?

Thx

Parsing BBCode to List

I didn't see it in documentation, so I thought maybe this feature does not exist.

Is there a way to parse bbcode to a list from a string? Considering a custom tag as a:

text = "Lorem ipsum dolor sit amet, [a]consectetur[/a] adipiscing elit, sed do eiusmod [a]tempor[/a] incididunt ut labore [a]et[/a] dolore magna aliqua."

parser("a", "text")
["consectetur","tempor","et"]

Why do I need it? (Or why would someone else need it?)

In a basic blog, where titles are (for an unknown reason) implemented as a different model (not a field) called as Title.

I want to get value of a tag and filter a QuerySet based on that value. Considering the former example:

Title.objects.filter(label="consectetur")

Is it possible yet?

Thanks in advance.

BBCode not rendered in base model

When base model (not abstract) contains BBCodeTextField and the child model is saved, the _rendered field is not saved in the database. In general, even the pre_save signal is not raised for base model, when child is saved. Nevertheless when base model pre_save and post_save signals are raised by child model pre_save and post_save receivers, the situation is not changed. The SQL prompt shows that raw and rendered are different, while print(), placed at the end of process_bbcodes(), shows the rendered content normally at pre_save - but doesn`t save.

A BBCode tag with this name appears to already exist

When editing a custom tag in the admin I get the error "A BBCode tag with this name appears to already exist" after saving. Renaming the tag to something else fixes the issue, but deleting the tag and recreating it still gives the same error. This makes any tag names savable only once.

I am running latest master branch bf889d8 on python 2.7 and django 1.7.

string index out of range

  File "venv/lib/python3.10/site-packages/precise_bbcode/bbcode/defaults/tag.py", line 114, in render
    if href[0] == href[-1] and href[0] in ('"', '\'') and len(href) > 2:

Exception Type: IndexError at /
Exception Value: string index out of range

Happens with short hrefs.
I'll fix it in a moment.

Django reports model changes (missing migration)

Applied initial migration 0001 no problem, but it seems there are model changes not reflected in migrations yet, so a migration 0002 is needed.

Here is the output of a makemigrations --dry-run:

Migrations for 'precise_bbcode':
  precise_bbcode/migrations/0002_alter_smileytag_image.py
    - Alter field image on smileytag

Relative urls don't work

This works fine:

[url=https://localhost/www]text[/url]
[img]https://localhost/www/img[/img]
[url=https://localhost/www][img]https://localhost/www/img[/img][/url]

This does not:

[url=/www]text[/url]
[img]/www/img[/img]
[url=/www][img]/www/img[/img][/url]

Please fix or hint so I can fix it for us all faster

TEXT placeholder doesn't match unicode characters

[center]๐ŸŽˆ[/center] will not be rendered as HTML, since the ๐ŸŽˆ character is not valid text. However, the documentation says that TEXT "matches anything", so I would suspect unicode characters as well.

Why don't use use .+, as it matches anything, like the docs say?

BBCode replacing URLs in contents

Hello I am current having this issues and it's quite annoying as BBCode parser is currently wrapping all url in <a> tags. I have disabled the Replace links options in all my custom BBCode tags so I don't know how this is happening.

Example use:

from precise_bbcode.bbcode import get_parser

body = '<html><head><title>Document</title></head><body><a href="https://html.spec.whatwg.org/">WHATWG HTML</a>.</body></html>';
parser = get_parser()
rendered = parser.render(body)

print(rendered)

Outputs

<a href="&lt;a href=" https:="" title="WHATWG HTML"><a href="https://html.spec.whatwg.org/">https://html.spec.whatwg.org/</a></a>

I think there should be a global setting that could be used to disable replace links for BBCodes tags, thank you.

Image with link is not working

I have just updated from 1.2.6 to 1.2.9 and found that [img] under [url] is not rendering. Downgraded to 1.2.8 and it works just fine.

Smiley Codes Can Pre-Empt Each Other.

Expected Behavior

If two custom smilies are set that where one has a code that contains a subset of the other code, each code should produce the associated smiley.

Actual Behavior

The code for the longer smiley will be pre-empted by the code for the smaller smiley, leaving the smaller smiley followed by the rest of the code.

Steps to Reproduce the Problem

  1. Create a smiley for the standard code ':p'
  2. Create a smiley for the standard forum smiley ':ph34r:'
  3. Render text that contains ':ph34r:'

The rendered text will display "๐Ÿ˜›h34r:" instead of the expected ninja smiley.

Specifications

  • Version: master
  • Platform: Ubuntu 16
  • Subsystem: Django 2.0.4

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.