Beispiel #1
0
 def _get_hyphenator(self, lang):
     if not lang in HtmlHyphenator.hyphenator_f:
         if has_wordaxe and lang in wordaxe_languages:
             h = DCWHyphenator(lang, minWordLength=3)
             HtmlHyphenator.hyphenator[lang] = h
             HtmlHyphenator.hyphenator_f[lang] = lambda w: wordaxe_hyphenation_wrapper(h, w)
         elif has_pyphen and lang in pyphen.LANGUAGES:
             h = pyphen.Pyphen(lang=lang)
             HtmlHyphenator.hyphenator[lang] = h
             HtmlHyphenator.hyphenator_f[lang] = lambda w: h.inserted(w, hyphen=HtmlHyphenator.html_hypenation_mark)
         else:
             HtmlHyphenator.hyphenator_f[lang] = lambda x: x
     return HtmlHyphenator.hyphenator_f[lang]
Beispiel #2
0
 def _get_hyphenator(cls, lang):
     if not lang in HtmlHyphenator.hyphenator_f:
         if has_wordaxe and lang in wordaxe_languages:
             h = DCWHyphenator(lang, minWordLength=3)
             HtmlHyphenator.hyphenator[lang] = h
             HtmlHyphenator.hyphenator_f[lang] = \
                 lambda w: wordaxe_hyphenation_wrapper(h, w)
         elif has_pyphen and lang in pyphen.LANGUAGES:
             h = pyphen.Pyphen(lang=lang)
             HtmlHyphenator.hyphenator[lang] = h
             HtmlHyphenator.hyphenator_f[lang] = \
                 lambda w: h.inserted(w,
                     hyphen=HtmlHyphenator.html_hypenation_mark)
         else:
             HtmlHyphenator.hyphenator_f[lang] = lambda x: x
     return HtmlHyphenator.hyphenator_f[lang]
Beispiel #3
0
    Frame, Paragraph, PageTemplate, SimpleDocTemplate
from reportlab.platypus import Paragraph as NonHyphParagraph

__author__ = "Henning von Bargen"
"""
Test cases where the content of the paragraph is "empty".
"""

USE_HYPHENATION = True

if USE_HYPHENATION:
    try:
        import wordaxe.rl.styles
        from wordaxe.rl.paragraph import Paragraph
        from wordaxe.DCWHyphenator import DCWHyphenator
        wordaxe.hyphRegistry['DE'] = DCWHyphenator('DE', 5)
    except SyntaxError:
        print(
            "could not import hyphenation - try to continue WITHOUT hyphenation!"
        )

PAGESIZE = pagesizes.landscape(pagesizes.A4)


class EmptyContentTestCase(unittest.TestCase):
    "Test paragraphs with empty context."

    def testEmpty(self):
        "Generate a document with the given text"
        stylesheet = getSampleStyleSheet()
        normal = stylesheet['BodyText']
Beispiel #4
0
 def test(self):
     from wordaxe.DCWHyphenator import DCWHyphenator
     hyphenator = DCWHyphenator('DE', 4)
     test_words(hyphenator)