Merge lp://qastaging/~mbp/launchpad/391780-markdown into lp://qastaging/launchpad
Proposed by
Martin Pool
Status: | Merged |
---|---|
Approved by: | Martin Pool |
Approved revision: | no longer in the source branch. |
Merged at revision: | 14384 |
Proposed branch: | lp://qastaging/~mbp/launchpad/391780-markdown |
Merge into: | lp://qastaging/launchpad |
Diff against target: |
225 lines (+90/-4) 7 files modified
lib/lp/app/browser/stringformatter.py (+26/-1) lib/lp/app/browser/tests/test_stringformatter.py (+50/-0) lib/lp/registry/browser/person.py (+3/-1) lib/lp/registry/templates/product-index.pt (+3/-2) lib/lp/services/features/flags.py (+6/-0) setup.py (+1/-0) versions.cfg (+1/-0) |
To merge this branch: | bzr merge lp://qastaging/~mbp/launchpad/391780-markdown |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Raphaël Badin (community) | Approve | ||
Review via email: mp+82832@code.qastaging.launchpad.net |
Commit message
[r=rvb][bug=391780][incr] Markdown markup in project and user home pages
Description of the change
Support Markdown markup in project and user home pages, per bug 391780.
To post a comment you must log in.
Looks good.
A few remarks:
[0]
50 +def format_ markdown( text):
51 + """Return html form of marked-up text."""
52 + # This returns whole paragraphs (in p tags), similarly to text_to_html.
53 + md = markdown.Markdown(
54 + safe_mode='escape',
55 + extensions=[
56 + 'tables',
57 + ])
58 + return md.convert(text) # How easy was that?
Looks like there is a big overhead in creating the Mardown class each time we have a string to convert:
python -m timeit -s 'import markdown; md = markdown. Markdown( safe_mode= "escape" ,extensions= [ "tables",])' 'for x in range(1000): md.convert("a *b* a");'
10 loops, best of 3: 246 msec per loop
python -m timeit -s 'import markdown;' 'for x in range(1000): markdown. Markdown( safe_mode= "escape" ,extensions= [ "tables" ,]).convert( "a *b* a");'
10 loops, best of 3: 471 msec per loop
You might want to create and reuse instances stored in threading.local.
[1]
125 + def test_plain_ text(self) : '<p>hello world</p>'))
126 + self.assertThat(
127 + 'hello world',
128 + MarksDownAs(
Don't you want to include 'real' markdown markup here, just as an illustration for the reader?
[2]
160 - <div class="summary" tal:content= "context/ summary" > "structure context/ summary/ fmt:markdown" >
161 + <div class="summary"
162 + tal:content=
163 $Product.summary goes here. This should be quite short,
Small indentation inconsistency here ;)