for fld in flds: if len(fld.parent.select(" > *"))==1: fld.parent.replace_with(fld.div) ptabs=re.compile("(.*?)([^\.\?\s][^\.\?]+ 'tab' [^\.]+\.)(.*)", re.UNICODE|re.MULTILINE|re.DOTALL) for p in soup.findAll(text=re.compile(" 'tab' ")): txt=ptabs.sub("\\1\\3",p).strip() padre=p.parent if len(txt)>0: if p.previous_sibling: txt=" "+txt if p.next_sibling: txt=txt+" " p.replace_with(txt) else: if util.eqtxt(p.parent,p): p.parent.extract() else: p.extract() ins=find_fld(soup.body.div, re.compile(u".*Instalación: qué usar para este curso.*", re.UNICODE|re.MULTILINE|re.DOTALL)) if len(ins)>0: i=ins[0] a=i.div.a a.attrs["href"]="labs/Preparing%20Your%20Computer%20for%20LFS101x.pdf" i.findAll("p")[-1].extract() c=a.parent.contents[-1] if isinstance(c, bs4.NavigableString) or isinstance(c, unicode): c.replace_with(c.string.replace(u" (si es que se ha registrado para el MOOC) o haciendo clic en el botón Documento a continuación","")) p=soup.new_tag("p") p.string=u"Otros recursos últiles: "
else: s.unwrap() for u in soup.findAll("u"): u.unwrap() for s in soup.findAll("b"): s.name = "strong" for s in soup.findAll("strong"): if util.is_vacio(s) or s.find_parent("strong") or s.find_parent( "span") or s.find_parent("table"): s.unwrap() for s in soup.findAll("span"): s2 = s.find_parent("span") if s2: if s2.attrs["class"] == s.attrs["class"]: s.unwrap() elif util.eqtxt(s, s2): s2.unwrap() for s in soup.findAll(["span", "strong"], text=comandos): if len(s.select(" > *")) == 0: s.name = "span" s.attrs['class'] = "comando" tags = util.vacio(soup, ['strong', 'em', 'i', 'span', 'u']) for t in tags: t.unwrap() for lb in soup.findAll("label"): lb.unwrap() lis = soup.findAll("li")