Exemplo n.º 1
0
 def default(self):
     try:
         # build default hyphenate_word using conf's lang (if available)
         return build(self.conf['lang'].replace('_', '-'))
     except HyphenPatternNotFound as e:
         log.warn(e.args[0])
         return lambda x: [x]
Exemplo n.º 2
0
 def default(self):
     try:
         # build default hyphenate_word using conf's lang (if available)
         return build(self.conf['lang'].replace('_', '-'))
     except HyphenPatternNotFound as e:
         log.warn(e.args[0])
         return lambda x: [x]
Exemplo n.º 3
0
    def transform(self, content, entry, *args):
        if entry.lang != self.conf['lang']:
            try:
                hyphenate_word = build(entry.lang.replace('_', '-'))
            except HyphenPatternNotFound as e:
                log.once(warn=e.args[0])
                hyphenate_word = lambda x: [x]
        else:
            hyphenate_word = self.default

        try:
            length = int(args[0])
        except (ValueError, IndexError) as e:
            if e.__class__.__name__ == 'ValueError':
                log.warn('Hyphenate: invalid length argument %r', args[0])
            length = 10

        try:
            return ''.join(Separator(content, hyphenate_word, length=length).result)
        except HTMLParseError as e:
            log.warn('%s: %s in %s' % (e.__class__.__name__, e.msg, entry.filename))
            return content
Exemplo n.º 4
0
    def transform(self, content, entry, *args):
        if entry.lang != self.conf['lang']:
            try:
                hyphenate_word = build(entry.lang.replace('_', '-'))
            except HyphenPatternNotFound as e:
                log.once(warn=e.args[0])
                hyphenate_word = lambda x: [x]
        else:
            hyphenate_word = self.default

        try:
            length = int(args[0])
        except (ValueError, IndexError) as e:
            if e.__class__.__name__ == 'ValueError':
                log.warn('Hyphenate: invalid length argument %r', args[0])
            length = 10

        try:
            return ''.join(
                Separator(content, hyphenate_word, length=length).result)
        except HTMLParseError as e:
            log.warn('%s: %s in %s' %
                     (e.__class__.__name__, e.msg, entry.filename))
            return content