add nobr tag hyphenation
authorrobin <robin@reportlab.com>
Mon, 25 Jun 2018 17:02:08 +0100
branchhyphenation
changeset 4413 dec33c7e7922
parent 4412 9875ed9ca9e4
child 4414 694b1d5c1c3d
add nobr tag
src/reportlab/lib/rl_accel.py
src/reportlab/platypus/paraparser.py
src/rl_addons/rl_accel/_rl_accel.c
tests/test_rl_accel.py
--- a/src/reportlab/lib/rl_accel.py	Sun Jun 24 18:11:37 2018 +0100
+++ b/src/reportlab/lib/rl_accel.py	Mon Jun 25 17:02:08 2018 +0100
@@ -320,7 +320,7 @@
         'returns 1 if two ParaFrags map out the same'
         if (hasattr(f,'cbDefn') or hasattr(g,'cbDefn')
                 or hasattr(f,'lineBreak') or hasattr(g,'lineBreak')): return 0
-        for a in ('fontName', 'fontSize', 'textColor', 'rise', 'us_lines', 'link', "backColor"):
+        for a in ('fontName', 'fontSize', 'textColor', 'rise', 'us_lines', 'link', "backColor", "nobr"):
             if getattr(f,a,None)!=getattr(g,a,None): return 0
         return 1
     _py_funcs['sameFrag'] = sameFrag
--- a/src/reportlab/platypus/paraparser.py	Sun Jun 24 18:11:37 2018 +0100
+++ b/src/reportlab/platypus/paraparser.py	Mon Jun 25 17:02:08 2018 +0100
@@ -699,6 +699,7 @@
 #               width="w%" --> fontSize*w/100   idea from Roberto Alsina
 #               height="h%" --> linewidth*h/100 <ralsina@netmanagers.com.ar>
 #       <greek> - </greek>
+#       <nobr> ... </nobr> turn off word breaking and hyphenation
 #
 #       The whole may be surrounded by <para> </para> tags
 #
@@ -887,6 +888,13 @@
     def end_sub( self ):
         self._pop('sub')
 
+    def start_nobr(self, attrs):
+        self.getAttributes(attrs,{})
+        self._push('nobr',nobr=True)
+
+    def end_nobr(self ):
+        self._pop('nobr')
+
     #### greek script
     #### add symbol encoding
     def handle_charref(self, name):
--- a/src/rl_addons/rl_accel/_rl_accel.c	Sun Jun 24 18:11:37 2018 +0100
+++ b/src/rl_addons/rl_accel/_rl_accel.c	Mon Jun 25 17:02:08 2018 +0100
@@ -29,7 +29,7 @@
 #ifndef min
 #	define min(a,b) ((a)<(b)?(a):(b))
 #endif
-#define VERSION "0.73"
+#define VERSION "0.74"
 #define MODULE "_rl_accel"
 
 struct module_state	{
@@ -444,7 +444,7 @@
 static PyObject *sameFrag(PyObject *module, PyObject* args)
 {
 	PyObject *f, *g;
-	static char *names[] = {"fontName", "fontSize", "textColor", "rise", "us_lines", "link", "backColor", NULL};
+	static char *names[] = {"fontName", "fontSize", "textColor", "rise", "us_lines", "link", "backColor", "nobr", NULL};
 	int	r=0, t;
 	char **p;
 	if (!PyArg_ParseTuple(args, "OO:sameFrag", &f, &g)) return NULL;
--- a/tests/test_rl_accel.py	Sun Jun 24 18:11:37 2018 +0100
+++ b/tests/test_rl_accel.py	Mon Jun 25 17:02:08 2018 +0100
@@ -157,9 +157,9 @@
 
         for func,kind in getFuncs('sameFrag'):
             if not func: continue
-            a=ABag(fontName='Helvetica',fontSize=12, textColor="red", rise=0, us_lines=0, link="aaaa")
-            b=ABag(fontName='Helvetica',fontSize=12, textColor="red", rise=0, us_lines=0, link="aaaa")
-            for name in ("fontName", "fontSize", "textColor", "rise", "us_lines", "link"):
+            a=ABag(fontName='Helvetica',fontSize=12, textColor="red", rise=0, us_lines=0, link="aaaa", nobr=1)
+            b=ABag(fontName='Helvetica',fontSize=12, textColor="red", rise=0, us_lines=0, link="aaaa", nobr=1)
+            for name in ("fontName", "fontSize", "textColor", "rise", "us_lines", "link", "nobr"):
                 old = getattr(a,name)
                 assert func(a,b)==1, "%s sameFrag(%s,%s)!=1" % (kind,a,b)
                 assert func(b,a)==1, "%s sameFrag(%s,%s)!=1" % (kind,b,a)