/* * [Amper.java] * * Summary: amper, converts invalid & to & in html. * * Copyright: (c) 1999-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 1.1 2006-03-05 * 1.2 2007-03-26 fix bug in StripEntities. Was not doing ￿ properly. * 1.3 2007-04-07 recover from crash. Tidy code. * 1.4 2007-05-10 add icon, PAD file. * 1.5 2007-06-29 add -q command line support. New CommandLine interface. * 1.6 2008-08-03 change detail parameter so that you can request three levels of detail, rather than two. * 1.7 2012-01-25 now handles HTML5 entities. It now leaves any unusual entities as is. * 1.8 2012-02-09 fix bug. Now handles even very longest HTML5 entities. No longer extends DeEntifyStrings. * 1.9 2012-06-18 allow you to ampify .htm and .csv files * 2.0 2012-11-03 deal text inside "; /** * date this version released. * * @noinspection UnusedDeclaration */ private static final String RELEASE_DATE = "2012-11-03"; /** * how to use the command line */ private static final String USAGE = "\nAmper needs a filename.html or a space-separated list of filenames, " + "with optional -s -q -v switches"; /** * embedded version string. * * @noinspection UnusedDeclaration */ private static final String VERSION_STRING = "2.0"; /** * constructor, not used. * * @noinspection WeakerAccess */ private Amper() { } /** * convert all & except ones in comments to &. * * @param big string possibly containing & and comments, but no = 2 ) { out.println( "- " + EIO.getCanOrAbsPath( fileBeingProcessed ) ); } return; } // generate output into a temporary file until we are sure all is ok. // create a temp file in the same directory as filename if ( detail >= 1 ) { // it changed out.println( "* " + EIO.getCanOrAbsPath( fileBeingProcessed ) ); } final File tempFile = HunkIO.createTempFile( "temp_", ".tmp", fileBeingProcessed ); FileWriter emit = new FileWriter( tempFile ); emit.write( result ); emit.close(); // successfully created output in same directory as input, // Now make it replace the input file. HunkIO.deleteAndRename( tempFile, fileBeingProcessed ); } /** * convert all & except ones in comments to &. * * @param big string possibly containing & and comments, but no