Part of lp.app.browser.stringformatter View In Hierarchy
Method | __init__ | Undocumented |
Method | nl_to_br | Quote HTML characters, then replace newlines with <br /> tags. |
Method | escape | Undocumented |
Method | break_long_words | Add manual word breaks to long words. |
Method | text_to_html | Quote text according to DisplayingParagraphsOfText. |
Method | text_to_html_with_target | See `text_to_html`(). |
Method | nice_pre | <pre>, except the browser knows it is allowed to break long lines |
Method | email_to_html | text_to_html and hide signatures and full-quoted emails. |
Method | obfuscate_email | Obfuscate an email address if there's no authenticated user. |
Method | strip_email | Strip out things that may be email. |
Method | linkify_email | Linkify any email address recognised in Launchpad. |
Method | lower | Return the string in lowercase |
Method | shorten | Use like tal:content="context/foo/fmt:shorten/60". |
Method | ellipsize | Use like tal:content="context/foo/fmt:ellipsize/60". |
Method | format_diff | Format the string as a diff in a table with line numbers. |
Method | format_ssdiff | Format the string as a side-by-side diff. |
Method | css_id | Return a CSS compliant id. |
Method | zope_css_id | Return a CSS compliant id compatible with zope's form fields. |
Method | oops_id | Format an OOPS ID for display. |
Method | markdown | Undocumented |
Method | traverse | Undocumented |
Static Method | _substitute_matchgroup_for_spaces | Return a string made up of ' ' for each character in the |
Static Method | _linkify_bug_number | Undocumented |
Static Method | _handle_parens_in_trailers | Move closing parens from the trailer back into the url if needed. |
Static Method | _split_url_and_trailers | Given a URL return a tuple of the URL and punctuation trailers. |
Static Method | _linkify_url_should_be_ignored | Don't linkify URIs consisting of just the protocol. |
Static Method | _linkify_substitution | Undocumented |
Static Method | _linkify_substitution_with_target | See `_linkify_substitution`(). |
Method | _ssdiff_emit_line | Undocumented |
Method | _ssdiff_emit_queued_lines | Undocumented |
Method | _css_id | Return a CSS compliant id. |
Used when replacing leading spaces with nbsps.
There must be only one match group.
If there are opening parens in the url that are matched by closing parens at the start of the trailer, those closing parens should be part of the url.
Returns | an unescaped url, an unescaped trailer. |
See `_linkify_substitution`(). The target attribute of the links will be updated to point to "_new", so that links will open in a new window.
See `text_to_html`(). URLs will be linkified with a target="_new" attribute.
Note that CSS will eventually have a property to specify this behaviour, but we want this now. To do this we need to use the mozilla specific -moz-pre-wrap value of the white-space property. We try to fall back for IE by using the IE specific word-wrap property.
TODO: Test IE compatibility. StuartBishop 20041118
This method wraps inclusions like signatures and PGP blocks in <span class="foldable"></span> tags. Quoted passages are wrapped <span class="foldable-quoted"></span> tags. The tags identify the extra content in the message to the presentation layer. CSS and JavaScript may use this markup to control the content's display behaviour.
The email address is obfuscated as <email address hidden>.
This formatter is intended to hide possible email addresses from unauthenticated users who view this text on the Web. Run this before the text is converted to html because text-to-html and email-to-html will insert markup into the address. eg. foo/fmt:obfuscate-email/fmt:email-to-html
The pattern used to identify an email address is not 2822. It strives to match any possible email address embedded in the text. For example, mailto:person@domain.dom and http://person:password@domain.dom both match, though the http match is in fact not an email address.
This is a variation on obfuscate_email for when we are generating a snipped for page metadata: we don't want to waste space spelling out "<email address hidden>", and we do want to strip addresses even for logged-in users in case they use the summary in a sharing tool.
If an email address is recognised as one registered in Launchpad, it is linkified to point to the profile page for that person.
Note that someone could theoretically register any old email address in Launchpad and then have it linkified. This may or not may be a concern but is noted here for posterity anyway.
The strip pattern allows ids which contain periods which is required for compatibility with zope form fields.
The id may contain letters, numbers, hyphens and underscores. The first character must be a letter. Unsupported characters are converted to hyphens. Multiple characters are replaced by a single hyphen. The letter 'j' will start the id if the string's first character is not a letter.
Parameters | prefix | an optional string to prefix to the id. It can be used to ensure that the start of the id is predictable. |