File: util.py

package info (click to toggle)
sqlalchemy 0.9.8%2Bdfsg-0.1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 23,952 kB
  • ctags: 24,534
  • sloc: python: 152,282; ansic: 1,346; makefile: 257; xml: 17
file content (12 lines) | stat: -rw-r--r-- 292 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
import re

def striptags(text):
    return re.compile(r'<[^>]*>').sub('', text)

def go(m):
    # .html with no anchor if present, otherwise "#" for top of page
    return m.group(1) or '#'

def strip_toplevel_anchors(text):
    return re.compile(r'(\.html)?#[-\w]+-toplevel').sub(go, text)