|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object cz.kebrt.html2latex.Convertor
class Convertor
Class which converts HTML into LaTeX format.
Plain HTML elements are converted using
commonElementStart()
and
commonElementEnd()
methods. Elements requiring special care during
the conversion are converted by calling special methods like
tableRowStart()
.
Field Summary | |
---|---|
private java.util.HashMap<java.lang.String,java.lang.String> |
_biblio
Document's bibliography. |
private Configuration |
_config
Program configuration. |
private int |
_countIgnoreContentElements
Counter telling in how many elements with "ignoreContent" attribute the parser is. |
private int |
_countLeaveTextElements
Counter telling in how many elements with "leaveText" attribute the parser is. |
private boolean |
_firstCell
If table cell is reached is it first table cell? |
private boolean |
_firstRow
If table row is reached is it first table row? |
private java.io.FileWriter |
_fw
Output file. |
private java.io.File |
_outputFile
Output file. |
private boolean |
_printBorder
Shall border be printed in current table. |
private java.io.BufferedWriter |
_writer
Output file. |
Constructor Summary | |
---|---|
Convertor(java.io.File outputFile)
Opens the output file. |
Method Summary | |
---|---|
void |
anchorEnd(ElementEnd element,
ElementStart es)
Called when A end element is reached. |
void |
anchorStart(ElementStart e)
Called when A start element is reached. |
void |
bodyEnd(ElementEnd element,
ElementStart es)
Called when end element is reached. |
void |
bodyStart(ElementStart es)
Called when BODY start element is reached. |
void |
comment(java.lang.String comment)
Called when comment is reached in the input HTML document. |
void |
commonElementEnd(ElementEnd element,
ElementStart es)
Called when HTML end element is reached and special method for the element doesn't exist. |
void |
commonElementStart(ElementStart element)
Called when HTML start element is reached and special method for the element doesn't exist. |
private java.lang.String |
convertCharEntitites(java.lang.String str)
Converts HTML character entities to LaTeX commands. |
private java.lang.String |
convertLaTeXSpecialChars(java.lang.String str)
Converts LaTeX special characters (ie. '{') to LaTeX commands. |
void |
cssStyleEnd(ElementStart e)
Prints CSS style converted to LaTeX command. |
void |
cssStyleStart(ElementStart e)
Prints CSS style converted to LaTeX command. |
void |
destroy()
Closes the output file. |
private CSSStyle[] |
findStyles(ElementStart e)
Finds styles for the specified element. |
void |
fontEnd(ElementEnd e,
ElementStart es)
Called when FONT end element is reached. |
void |
fontStart(ElementStart es)
Called when FONT start element is reached. |
void |
characters(java.lang.String str)
Called when text content is reached in the input HTML document. |
void |
imgStart(ElementStart es)
Called when IMG start element is reached. |
void |
metaStart(ElementStart es)
Called when META start element is reached. |
private void |
processAttributes(ElementStart element)
Processes HTML elements' attributes. |
void |
tableCellEnd(ElementEnd element,
ElementStart e)
Called when TD end element is reached. |
void |
tableCellStart(ElementStart e)
Called when TD start element is reached. |
void |
tableEnd(ElementEnd e,
ElementStart es)
Called when TABLE end element is reached. |
void |
tableRowEnd(ElementEnd e,
ElementStart es)
Called when TR end element is reached. |
void |
tableRowStart(ElementStart e)
Called when TR start element is reached. |
void |
tableStart(ElementStart e)
Called when TABLE start element is reached. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private Configuration _config
private java.io.File _outputFile
private java.io.FileWriter _fw
private java.io.BufferedWriter _writer
private int _countLeaveTextElements
private int _countIgnoreContentElements
private boolean _firstCell
private boolean _firstRow
private boolean _printBorder
private java.util.HashMap<java.lang.String,java.lang.String> _biblio
Constructor Detail |
---|
Convertor(java.io.File outputFile) throws FatalErrorException
outputFile
- output LaTeX file
FatalErrorException
- when output file can't be openedMethod Detail |
---|
public void destroy()
public void commonElementStart(ElementStart element) throws java.io.IOException, NoItemException
element
- HTML start tag
java.io.IOException
- output error occurs
NoItemException
- tag not found in the configurationpublic void commonElementEnd(ElementEnd element, ElementStart es) throws java.io.IOException, NoItemException
element
- corresponding end tages
- start tag
java.io.IOException
- output error occurs
NoItemException
- tag not found in the configurationpublic void characters(java.lang.String str) throws java.io.IOException
str
- text content reached
java.io.IOException
- when output error occurspublic void comment(java.lang.String comment) throws java.io.IOException
comment
- comment (without <!-- and -->)
java.io.IOException
- when output error occursprivate java.lang.String convertLaTeXSpecialChars(java.lang.String str)
str
- input string
private java.lang.String convertCharEntitites(java.lang.String str)
str
- input string
private void processAttributes(ElementStart element) throws java.io.IOException
element
- HTML start tag
java.io.IOException
- when output error occurspublic void cssStyleStart(ElementStart e) throws java.io.IOException
e
- HTML start element
java.io.IOException
- when output error occurspublic void cssStyleEnd(ElementStart e) throws java.io.IOException
e
- corresponding HTML start element
java.io.IOException
- when output error occursprivate CSSStyle[] findStyles(ElementStart e)
e
- HTML element
public void anchorStart(ElementStart e) throws java.io.IOException, NoItemException
e
- start tag
java.io.IOException
- output error occurs
NoItemException
- tag not found in the configurationpublic void anchorEnd(ElementEnd element, ElementStart es) throws java.io.IOException, NoItemException
element
- corresponding end tages
- start tag
java.io.IOException
- output error occurs
NoItemException
- tag not found in the configurationpublic void tableRowStart(ElementStart e) throws java.io.IOException, NoItemException
e
- start tag
java.io.IOException
- output error occurs
NoItemException
- tag not found in the configurationpublic void tableRowEnd(ElementEnd e, ElementStart es) throws java.io.IOException
e
- corresponding end tages
- start tag
java.io.IOException
- output error occurspublic void tableCellStart(ElementStart e) throws java.io.IOException, NoItemException
e
- start tag
java.io.IOException
- output error occurs
NoItemException
- tag not found in the configurationpublic void tableCellEnd(ElementEnd element, ElementStart e) throws java.io.IOException, NoItemException
element
- corresponding end tage
- start tag
java.io.IOException
- output error occurs
NoItemException
- tag not found in the configurationpublic void tableStart(ElementStart e) throws java.io.IOException, NoItemException
e
- start tag
java.io.IOException
- output error occurs
NoItemException
- tag not found in the configurationpublic void tableEnd(ElementEnd e, ElementStart es) throws java.io.IOException, NoItemException
e
- corresponding end tages
- start tag
java.io.IOException
- output error occurs
NoItemException
- tag not found in the configurationpublic void bodyStart(ElementStart es) throws java.io.IOException, NoItemException
es
- start tag
java.io.IOException
- output error occurs
NoItemException
- tag not found in the configurationpublic void imgStart(ElementStart es) throws java.io.IOException, NoItemException
es
- start tag
java.io.IOException
- output error occurs
NoItemException
- tag not found in the configurationpublic void metaStart(ElementStart es) throws java.io.IOException, NoItemException
es
- start tag
java.io.IOException
- output error occurs
NoItemException
- tag not found in the configurationpublic void fontStart(ElementStart es) throws java.io.IOException, NoItemException
es
- start tag
java.io.IOException
- output error occurs
NoItemException
- tag not found in the configurationpublic void fontEnd(ElementEnd e, ElementStart es) throws java.io.IOException, NoItemException
e
- corresponding end tages
- start tag
java.io.IOException
- output error occurs
NoItemException
- tag not found in the configurationpublic void bodyEnd(ElementEnd element, ElementStart es) throws java.io.IOException, NoItemException
element
- corresponding end tages
- start tag
java.io.IOException
- output error occurs
NoItemException
- tag not found in the configuration
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |