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]
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]
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']
def test(self): from wordaxe.DCWHyphenator import DCWHyphenator hyphenator = DCWHyphenator('DE', 4) test_words(hyphenator)