Giter Site home page Giter Site logo

Comments (5)

rixx avatar rixx commented on September 26, 2024 1

I would be sure to have an English explanation of how to limit is computed. Not just code samples.

The code sample was intended for people implementing this improved documentation, not for the users.

from pretalx.

rixx avatar rixx commented on September 26, 2024

First off,

But Jimmy's is barred because he took the time to learn HTML and now he pays the price.

That's a pretty antagonistic way to start off a feature request, and I don't really have the patience to respond in a kind and educational manner today, so I'm going to leave it at that.

OR, state explicitly before the user starts entering text, that you will be counting formatting too in your counts, so if the users uses HTML then he should be prepared to pay the price.

That's a fairly technical piece of information, and while pretalx is used for many tech events, it's also used for many non-tech events where users are barely aware of how to write Markdown / HTML in the first place. However, organisers can add a hint like this when they configure their event, and for technical events with strict word limits (not a typical use case!), that may be the best approach to take here.

(Markdown too?)

As the text isn't converted in any way before counting words, yes, Markdown is counted too – though by the nature of Markdown, I'd expect it to be much closer to what you'd expect in terms of word count – in your example, the HTML is counted as 140 words and the Markdown as 126 words.


We already link to our documentation to explain how Markdown works. We could have an equivalent page that explains how length restrictions work, including a small JavaScript tester / calculator for word counts. I'd merge a contribution like that – the relevant code is as follows:

const wordCount = (str) => {const re = /\b\w+\b/g; return ((str||'').match(re) || []).length }

from pretalx.

jidanni avatar jidanni commented on September 26, 2024

Well all I know is I had to submit the form any times until I could get it down to the limits.

There wasn't even a way to test it per field. The whole form had to be submitted to find the results.

I would be sure to have an English explanation of how to limit is computed. Not just code samples.

from pretalx.

jidanni avatar jidanni commented on September 26, 2024

Seems \w isn't always the best choice,

$ echo "Bill's dog."|perl -nwle '$k++ for /\w+/g; END{print $k}'
3
$ echo "Bill's dog."|wc -w
2

https://github.com/pretalx/pretalx/blob/main/src/pretalx/common/forms/utils.py is where the counting takes place.
https://www.google.com/search?q=counting+words+in+django maybe has better ideas.

$ perl -nwle '$k++ for /\w+/g; END{print $k}' file.txt
845
$ perl -nwle '$k++ for /\S+/g; END{print $k}' file.txt
823
$ wc --words file.txt
823 file.txt

from pretalx.

rixx avatar rixx commented on September 26, 2024

Linking to Google results is neither productive nor appropriate. Locking this conversation.

from pretalx.

Related Issues (20)

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.