def CookedBody(self, stx_level=None, setLevel=0): """ """ if (self.text_format.endswith('html') or self.text_format.endswith('plain') or (stx_level is None) or (stx_level == self._stx_level)): return self.cooked_text else: if HTML: html_renderer = HTML() cooked = html_renderer(self.text, stx_level) else: cooked = format_stx(self.text, stx_level) if setLevel: self._stx_level = stx_level self.cooked_text = cooked return cooked
def _edit(self, text, text_format=''): level = self._stx_level if not text_format: text_format = self.text_format if self.text_format: self.text_format = text_format if text_format == 'html' or text_format == 'text/html': self.text = self.cooked_text = text elif text_format == 'plain' or text_format == 'text/plain': self.text = text self.cooked_text = html_quote(text).replace('\n', '<br />') else: if HTML: html_renderer = HTML() self.cooked_text = html_renderer(text=text, level=level) else: self.cooked_text = format_stx(text=text, level=level) self.text = text
def CookedBody(self, stx_level=None, setlevel=0): """\ The prepared basic rendering of an object. For Documents, this means pre-rendered structured text, or what was between the <BODY> tags of HTML. If the format is html, and 'stx_level' is not passed in or is the same as the object's current settings, return the cached cooked text. Otherwise, recook. If we recook and 'setlevel' is true, then set the recooked text and stx_level on the object. """ if (self.text_format == 'html' or self.text_format == 'plain' or (stx_level is None) or (stx_level == self._stx_level)): return self.cooked_text else: cooked = format_stx(self.text, stx_level) if setlevel: self._stx_level = stx_level self.cooked_text = cooked return cooked
def _edit(self, text, text_format='', safety_belt=''): """ Edit the Document and cook the body. """ level = self._stx_level if not text_format: text_format = self.text_format if not self._safety_belt_update(safety_belt=safety_belt): msg = ("Intervening changes from elsewhere detected." " Please refetch the document and reapply your changes." " (You may be able to recover your version using the" " browser 'back' button, but will have to apply them" " to a freshly fetched copy.)") raise 'EditingConflict', msg if text_format == 'html': self.text = self.cooked_text = text elif text_format == 'plain': self.text = text self.cooked_text = html_quote(text).replace('\n', '<br />') else: self.cooked_text = format_stx(text=text, level=level) self.text = text
def _edit(self, text, text_format='', safety_belt=''): """ Edit the Document and cook the body. """ level = self._stx_level if not text_format: text_format = self.text_format if not self._safety_belt_update(safety_belt=safety_belt): msg = ("Intervening changes from elsewhere detected." " Please refetch the document and reapply your changes." " (You may be able to recover your version using the" " browser 'back' button, but will have to apply them" " to a freshly fetched copy.)") raise 'EditingConflict', msg if text_format == 'html': self.text = self.cooked_text = text elif text_format == 'plain': self.text = text self.cooked_text = html_quote(text).replace('\n','<br />') else: self.cooked_text = format_stx(text=text, level=level) self.text = text