src/reportlab/platypus/paraparser.py
branchpy33
changeset 3931 ceee76b69e7c
parent 3900 056aff5b1a58
child 3937 f685e0de4282
equal deleted inserted replaced
3930:950841932d03 3931:ceee76b69e7c
   662                 self._syntax_error('<a name="..."/> anchor variant only allows name attribute')
   662                 self._syntax_error('<a name="..."/> anchor variant only allows name attribute')
   663                 A = dict(name=A['name'])
   663                 A = dict(name=A['name'])
   664             A['_selfClosingTag'] = 'anchor'
   664             A['_selfClosingTag'] = 'anchor'
   665         else:
   665         else:
   666             href = A.get('href','').strip()
   666             href = A.get('href','').strip()
   667             if not href:
       
   668                 self._syntax_error('<a> tag must have non-blank name or href attribute')
       
   669             A['link'] = href    #convert to our link form
   667             A['link'] = href    #convert to our link form
   670             A.pop('href')
   668             A.pop('href',None)
   671         self._push(**A)
   669         self._push(**A)
   672 
   670 
   673     def end_a(self):
   671     def end_a(self):
   674         frag = self._stack[-1]
   672         frag = self._stack[-1]
   675         sct = getattr(frag,'_selfClosingTag','')
   673         sct = getattr(frag,'_selfClosingTag','')
  1003                 k = k.lower()
  1001                 k = k.lower()
  1004             if k in list(attrMap.keys()):
  1002             if k in list(attrMap.keys()):
  1005                 j = attrMap[k]
  1003                 j = attrMap[k]
  1006                 func = j[1]
  1004                 func = j[1]
  1007                 try:
  1005                 try:
  1008                     A[j[0]] = (func is None) and v or func(v)
  1006                     A[j[0]] = v if func is None else func(v)
  1009                 except:
  1007                 except:
  1010                     self._syntax_error('%s: invalid value %s'%(k,v))
  1008                     self._syntax_error('%s: invalid value %s'%(k,v))
  1011             else:
  1009             else:
  1012                 self._syntax_error('invalid attribute name %s'%k)
  1010                 self._syntax_error('invalid attribute name %s'%k)
  1013         return A
  1011         return A