1 #!/usr/bin/env python 2 3 """ 4 Common parsing data. 5 6 Copyright (C) 2012, 2013 Paul Boddie <paul@boddie.org.uk> 7 8 This software is free software; you can redistribute it and/or 9 modify it under the terms of the GNU General Public License as 10 published by the Free Software Foundation; either version 2 of 11 the License, or (at your option) any later version. 12 13 This software is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public 19 License along with this library; see the file LICENCE.txt 20 If not, write to the Free Software Foundation, Inc., 21 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 22 """ 23 24 MAX_TITLE_LENGTH = 120 25 26 URL_SCHEMES = ("http", "https", "ftp", "mailto") 27 28 # Translation helpers. 29 30 blocktypes = { 31 "h1" : "= %s =", 32 "h2" : "== %s ==", 33 "h3" : "=== %s ===", 34 "h4" : "==== %s ====", 35 "h5" : "===== %s =====", 36 "h6" : "====== %s ======", 37 "bq" : "{{{%s}}}", 38 } 39 40 headings = blocktypes.keys(); headings.remove("bq") 41 42 def get_page_title(title): 43 return title[:MAX_TITLE_LENGTH].strip() 44 45 def quote_macro_argument(arg): 46 if arg.find('"') != -1: 47 return '"%s"' % arg.replace('"', '""') 48 else: 49 return arg 50 51 # vim: tabstop=4 expandtab shiftwidth=4