Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > cz.comp.lang.python > #3176
| From | Matěj Cepl <mcepl@cepl.eu> |
|---|---|
| Newsgroups | cz.comp.lang.python |
| Subject | Re: [python] alternativa textwrap.fill(), která by zarovnávala po česku? |
| Date | 2017-05-11 01:12 +0200 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <slrnoh77j5.db.mcepl@mitmanek.ceplovi.cz> (permalink) |
| References | (1 earlier) <CADoCwr0n57Uhm9RKy8N=GpRqC_xp=vGF9gyj7m1j4e0OqLB5=Q@mail.gmail.com> <mailman.1.1494450194.22440.python@py.cz> <slrnoh72qm.kmr.mcepl@mitmanek.ceplovi.cz> <17124f05-2e0e-bddf-6b84-81efa2df2616@sandbox.cz> <mailman.2.1494455290.22440.python@py.cz> |
On 2017-05-10, 22:28 GMT, Vláďa Macek wrote:
> print textwrap.fill(instr, width=65).replace(u'~',
> unichr(160))
No, udělal jsem v podstatě to:
diff --git a/reflow.py b/reflow.py
index 22b08cf..757077c 100644
--- a/reflow.py
+++ b/reflow.py
@@ -133,12 +133,18 @@ class ReflowPluginWindowActivatable(GObject.Object, Gedit.WindowActivatable):
if isinstance(text, str):
text = unicode(text, 'utf8')
+ # we don't want to break on the non-breaking space
+ # FIXME not sure whether there isn’t better replacement character
+ text = text.replace(unichr(0xA0), '~')
+
text = textwrap.fill(text,
width=self.get_gedit_margin(),
initial_indent=first_prefix,
subsequent_indent=prefix,
break_on_hyphens=False,
drop_whitespace=True)
+ text = text.replace('~', unichr(0xA0))
+
return text
def _get_line(self, index):
Ale nejsem na to hrdej. Navíc přemýšlím, jestli někdy nebudu
chtít mít ~ znak v textu. Ale snad ne.
Hezký den,
Matěj
--
https://matej.ceplovi.cz/blog/, Jabber: mcepl@ceplovi.cz
GPG Finger: 3C76 A027 CA45 AD70 98B5 BC1D 7920 5802 880B C9D8
Of course I'm respectable. I'm old. Politicians, ugly buildings,
and whores all get respectable if they last long enough.
--John Huston in "Chinatown."
Back to cz.comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar
alternativa textwrap.fill(), která by zarovnávala po česku? Matěj Cepl <mcepl@cepl.eu> - 2017-05-10 21:35 +0200
Re: [python] alternativa textwrap.fill(), která by zarovnávala po česku? Honza Král <honza.kral@gmail.com> - 2017-05-10 23:02 +0200
Re: [python] alternativa textwrap.fill(), která by zarovnávala po česku? Matěj Cepl <mcepl@cepl.eu> - 2017-05-10 23:51 +0200
Re: [python] alternativa textwrap.fill(), která by zarovnávala po česku? Vláďa Macek <macek@sandbox.cz> - 2017-05-11 00:28 +0200
Re: [python] alternativa textwrap.fill(), která by zarovnávala po česku? Matěj Cepl <mcepl@cepl.eu> - 2017-05-11 01:12 +0200
Re: [python] alternativa textwrap.fill(), která by zarovnávala po česku? Petr Přikryl <prikryl@atlas.cz> - 2017-05-11 09:31 +0200
Re: [python] alternativa textwrap.fill(), která by zarovnávala po česku? Matěj Cepl <mcepl@cepl.eu> - 2017-05-11 10:50 +0200
Re: [python] alternativa textwrap.fill(), která by zarovnávala po česku? Petr Viktorin <encukou@gmail.com> - 2017-05-11 11:22 +0200
Re: [python] alternativa textwrap.fill(), která by zarovnávala po česku? Matěj Cepl <mcepl@cepl.eu> - 2017-05-11 16:31 +0200
csiph-web