1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
|
ProcessHTML.py creates the PDF handbooks for MuseScore.
ProcessHTML is written and maintained by David Bolton.
http://davidbolton.info
**********************************
SET UP INSTRUCTIONS
Code is written for Python 2.6. The actual PDF creation
has several dependencies that must be installed first.
See http://www.htmltopdf.org/ for details.
A connection to the Internet is required since
ProcessHTML.py fetches HTML and images files from the
MuseScore website.
FURTHER SETUP AND PATCHES
If you get "AttributeError: 'NoneType' object has no
attribute 'bands'" then see
http://code.google.com/p/xhtml2pdf/issues/detail?id=65
To create the Japanese and Chinese handbooks see
http://code.google.com/p/xhtml2pdf/issues/detail?id=63
If you encounter
File "C:\Python26\lib\site-packages\reportlab\platypus\doctemplate.py", line 783, in handle_flowable
raise LayoutError(ident)
reportlab.platypus.doctemplate.LayoutError
Comment line 783 in "C:\Python26\lib\site-packages\reportlab\platypus\doctemplate.py"
USE INSTRUCTIONS
To create PDF handbooks run ProcessHTML.py from the
command line.
By default the script will create the English handbook.
To create other language handbooks use the standard
two-letter language code as follows:
> Python ProcessHTML.py -l fr
To create all the language handbooks at once use "all"
as the command line argument.
> Python ProcessHTML.py all
*********************************
INSTRUCTIONS FOR ADDING NEW LANGUAGE
1. In chapterHeading() add the translation for
"Chapter". For example:
elif language_code == 'nb':
chapter = 'Kapittel'
2. In createHandbook() add the URL for the print
version of the handbook and the top-level URL for
the handbook on the website. Make sure the internal
URL using Unicode characters rather than escaped
charaters ('http://musescore.org/nb/hndbok' instead
of 'http://musescore.org/nb/h%C3%A5ndbok'). For
example
elif language_code == 'nb':
url = 'http://musescore.org/nb/print/book/export/html/2122'
internal = 'http://musescore.org/nb/hndbok'
3. In main() the two-letter code the language_choices
list. For example
language_choices = ['all','en','nl','de','es','fi','fr','gl','it','ja','nb','ru','pl','pt-BR']
*********************************
CHANGE LOG
Version 1.7 (September 2010)
* Add danish
* fix for russian capitalization using decode("utf-8").lower().encode("utf-8")
Version 1.6 (March 2010)
* Update style sheet for 0.9.6
* Fix for "/" link in English handbook
* Compatibility update: remove "www." from handbook links again (HTML from website changed)
* Add Hungarian, Catalan, Romanian, and Greek
* Work around lower case problem for a couple letters in Hungarian alphabet
* More flexibility with Chapter headings (numbers can go before the word chapter for Hungarian or right after without a space for Japanese)
* Update instructions in README file for adding new language
Version 1.5 (February 2010)
* Unix style command line options
* Fix: broken images
* Fix: removable of stylesheets (change in website revealed bug)
* Better handling of link checks
Version 1.4 (November 2009)
* Add sources and font directory to SVN
* Drop unimportant words (such as "a") from anchors to match URLs on website
* Repress pisa warnings unless verbos output requested
* Repress information about external CSS unless versbose output requested
* Check whether URL's in handbook match language of handbook
* Use DejaVu font for all text (allows non-latin characters for Russian handbook)
* Ability to specify a font depending on the language (for example Japanese needs its own font)
* Add Russian, Japanese, Brazillian Portuguese, and Polish
* Compatibility update: add "www." back to handbook links (HTML from website changed)
* Add "./" to start of image src's so that OpenOffice.org can understand
Version 1.3 (August 2009):
* Compatibility update: remove "www." from handbook links (HTML from website changed)
* Update CSS for release of version 0.9.5 and to embed DejaVuSans font for Mac shortcut symbols
* Add Norwegian and wrote instructions for adding new languages
* Check for broken images
* Check for base and link tags before processing them
Version 1.2 (9 July 2009):
* Style sheet designed for pisa 3.0.31 (no longer designed for 3.0.27)
* Hides breadcrumb links
* When creating all handbooks, no longer open all the PDFs (to save memory)
* Create "files" directory if it doesn't already exit
* Does not download javascript files
Version 1.1 (17 April 2009):
* Compatibility updates for language dependent images (HTML from website changed)
* Compatibility updates for cover page and last page (HTML from website changed)
* Compatibility updates for page number (workaround for bug in pisa 3.0.31)
* Last version to have a style sheet designed for 3.0.27
Version 1.0 (12 March 2009):
* Added Italian handbook (it)
* Added Finnish handbook (fi)
* Compatibility updates for internal links (HTML from website changed)
* Show warning for URLs that contain the text "freelinking"
* Add UTF-8 comment to start of script (fixes URL encoding problems with accented "e" in French handbook)
* Made "missing" the default image parameter
* Added new PDF parameters: pdf, nopdf, openpdf (openpdf is default)
Version 0.9 (29 January 2009):
* Made screen output less verbose by default
* Percent escaped id attributes (necessary for PDF links to work with non-ASCII characters)
* Removed base tag from all languages
* Added numbered chapter headings
* Updated English title page
Version 0.8 (11 January 2009):
* Compatibility updates for new release of pisa 3.0.29
* Compatibility updates for internal links (HTML from website changed)
Version 0.7 (1 January 2009):
* Add support for all handbook translations
* Code clean up and modularization
* Fix level-two headings and other improvements
* Preliminary support for command-line arguments
Version 0.5 (30 December 2008):
* Experimental version for English handbook only
|