aaronsw / html2text

Convert HTML to Markdown-formatted text.
http://www.aaronsw.com/2002/html2text/
GNU General Public License v3.0
2.61k stars 412 forks source link

Use sortable versioning scheme #29

Open Arfrever opened 12 years ago

Arfrever commented 12 years ago

Please use easily sortable versions (e.g. "3.1.0", "3.1.0.1", "3.1.1", "3.1.2"). Many tools treat "3.101" as newer than "3.11". (The master branch now has version "3.11 dev".)

$ python -c 'from distutils.version import LooseVersion; print(LooseVersion("3.101") > LooseVersion("3.11"))'
True
$ python -c 'from distutils.version import StrictVersion; print(StrictVersion("3.101") > StrictVersion("3.11"))'
True

Examples from a function used by Portage (main package manager for Gentoo Linux):

$ python -c 'from portage import vercmp; print(vercmp("1", "2"))'
-1
$ python -c 'from portage import vercmp; print(vercmp("1", "1"))'
0
$ python -c 'from portage import vercmp; print(vercmp("2", "1"))'
1
$ python -c 'from portage import vercmp; print(vercmp("3.101", "3.11"))'
1
aaronsw commented 12 years ago

Well, decimals are sortable, but they're clearly nonstandard. I think I'll release the next version as 4.0 and do it with multiple-periods from then on; that should be clear to everyone.

stefanor commented 12 years ago

Arfrever: My solution in Debian was to put decimals between every number, e.g. 3.1.0.1. I do it pretty hackily with a pair of regexes, I don't know if Gentoo has any similar mechanism. http://anonscm.debian.org/viewvc/python-modules/packages/python-html2text/trunk/debian/watch?view=markup

Arfrever commented 12 years ago

I can use something similar to:

$ version="3.101"
$ version="${version//./}"
$ parsed_version=
$ for ((i=0; i<${#version}; i++)); do parsed_version+="${parsed_version:+.}${version:${i}:1}"; done
$ echo "${parsed_version}"
3.1.0.1