plover.formatting
– Formatting Actions#
This module handles parsing Plover’s dictionary entry mini-language and converting it into actions that the translation engine can execute.
- plover.formatting.ATOM_RE: re.re#
A regular expression for detecting individual formatting items in a dictionary entry. Each atom is either raw text, possibly containing some escaped braces (
\{
and\}
), or a “meta” formatting or translation command enclosed in braces (e.g.{*<}
).
- plover.formatting.WORD_RX: re.re#
A regular expression for detecting words in translation output. Each word consists of either an uninterrupted series of letters or numbers, or a punctuation character that may be surrounded by whitespace characters on either side.
- class plover.formatting.RetroFormatter(previous_translations)#
A helper class for iterating over the results of previous translations. It supports iterating over previous actions or translated text.
- previous_translations#
- FRAGMENT_RX#
A regular expression for detecting fragments in a string of text. Each fragment is a series of non-whitespace characters followed by zero or more trailing whitespace characters.
- iter_last_actions()#
- iter_last_fragments()#
- last_fragments([count=1])#
- iter_last_words([strip=False, rx=WORD_RX])#
- last_words([count=1, strip=False, rx=WORD_RX])#
- last_text(size)#
- class plover.formatting._Context(previous_translations, last_action)#
- previous_translations#
- last_action#
- translated_actions#
- new_action()#
- copy_last_action()#
- translated(action)#
- iter_last_actions()#
- class plover.formatting.Formatter#
-
- spaces_after#
- last_output_spaces_after#
- start_capitalized#
- start_attached#
- add_listener(callback)#
- remove_listener(callback)#
- set_output(output)#
- set_space_placement(s)#
- format(undo, do, prev)#
- class plover.formatting.TextFormatter(spaces_after)#
- spaces_after#
- replaced_text#
- appended_text#
- trailing_space#
- render(action_list, last_action)#
- reset(trailing_space)#
- class plover.formatting.OutputHelper(output, before_spaces_after, after_spaces_after)#
- output#
- before#
- after#
- flush()#
- render(last_action, undo, do)#
- class plover.formatting._Action([prev_attach=False, prev_replace='', glue=False, word=None, orthography=True, space_char=' ', upper_carry=False, case=None, text=None, trailing_space='', combo=None, command=None, next_attach=False, next_case=None])#
- DEFAULT#
- prev_attach#
- glue#
- word#
- upper_carry#
- orthography#
- next_attach#
- next_case#
- space_char#
- case#
- trailing_space#
- prev_replace#
- text#
- combo#
- command#
- copy_state()#
- new_state()#
- class plover.formatting.Case#
- CAP_FIRST_WORD#
- LOWER#
- LOWER_FIRST_CHAR#
- TITLE#
- UPPER#
- UPPER_FIRST_WORD#
- plover.formatting.apply_case(text, case)#
- plover.formatting.apply_mode(text, case, space_char, begin, last_action)#
- plover.formatting.apply_mode_case(text, case, appended)#
- plover.formatting.apply_mode_space_char(text, space_char)#
- plover.formatting.capitalize_first_word(s)#
- plover.formatting.capitalize_all_words(s)#
- plover.formatting.lower_first_character(s)#
- plover.formatting.upper_all_words(s)#
- plover.formatting.upper_first_word(s)#
- plover.formatting.rightmost_word(s)#
- plover.formatting.has_word_boundary(s)#