[library-web] [mallard] consider all title node content to get document title



commit 56a31fb13fc960e70e7c336d27753d4f693f4f57
Author: Frédéric Péters <fpeters 0d be>
Date:   Wed Apr 6 18:43:02 2011 +0530

    [mallard] consider all title node content to get document title
    
    This is because Orca title is not just text.
    
      <title>
        <media type="image" mime="image/png" src="figures/orca-logo.png">
          <app>Orca</app>'s logo
        </media>
        <app>Orca</app> Screen Reader
      </title>

 src/modtypes/mallard.py |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/src/modtypes/mallard.py b/src/modtypes/mallard.py
index 18104eb..bcc15fa 100644
--- a/src/modtypes/mallard.py
+++ b/src/modtypes/mallard.py
@@ -270,7 +270,20 @@ class MallardModule(DocModule):
                                             xml_file, lang))
                     continue
                 if doc_page == 'index.page':
-                    doc.title[lang] = page.link_title.text
+                    def get_plain(x):
+                        if x.text:
+                            t = x.text
+                        for element in x.getchildren():
+                            if element.tag == '{%s}media' % MAL_NS:
+                                continue
+                            if not element.text:
+                                continue
+                            t += ' '
+                            t += element.text
+                            if element.tail:
+                                t += element.tail
+                        return t.strip()
+                    doc.title[lang] = get_plain(page.link_title)
             if not lang in doc.languages:
                 continue
             temporary = tempfile.NamedTemporaryFile()



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]