2009-07-15 04:39:30 +04:00
If this is your first time building the HTML5 parser, you need to execute the
following commands (from this directory) to bootstrap the translation:
2010-04-22 12:24:54 +04:00
make sync # fetch remote source files and licenses
2017-07-04 11:00:03 +03:00
make translate # perform the Java-to-C++ translation from the remote
2010-04-22 12:24:54 +04:00
# sources
make named_characters # Generate tables for named character tokenization
2009-07-15 04:39:30 +04:00
If you make changes to the translator or the javaparser, you can rebuild by
2010-04-22 12:24:54 +04:00
retyping 'make' in this directory. If you make changes to the HTML5 Java
2017-07-04 11:00:03 +03:00
implementation, you can retranslate the Java sources from the htmlparser
2010-04-22 12:24:54 +04:00
repository by retyping 'make translate' in this directory.
The makefile supports the following targets:
sync_htmlparser:
2017-07-04 11:00:03 +03:00
Retrieves the HTML parser and Java to C++ translator sources from Mozilla's
2010-04-22 12:24:54 +04:00
htmlparser repository.
sync_javaparser:
2016-08-11 16:09:17 +03:00
Retrieves the javaparser sources from GitHub.
2010-04-22 12:24:54 +04:00
sync:
Runs both sync_javaparser and sync_htmlparser.
javaparser:
2017-07-04 11:00:03 +03:00
Builds the javaparser library retrieved earlier by sync_javaparser.
2010-04-22 12:24:54 +04:00
translator:
2017-07-04 11:00:03 +03:00
Runs the javaparser target and then builds the Java to C++ translator from
2010-04-22 12:24:54 +04:00
sources retrieved earlier by sync_htmlparser.
libs:
The default target. Alias for translator
translate:
2017-07-04 11:00:03 +03:00
Runs the translator target and then translates the HTML parser sources
2010-04-22 12:24:54 +04:00
retrieved by sync_htmlparser copying the Java sources to ../javasrc.
2017-07-04 11:00:03 +03:00
translate_from_snapshot:
Runs the translator target and then translates the HTML parser sources
2010-04-22 12:24:54 +04:00
stored in ../javasrc.
named_characters:
Generates data tables for named character tokenization.
clean_javaparser:
Removes the build products of the javaparser target.
clean_htmlparser:
Removes the build products of the translator target.
clean:
Runs both clean_javaparser and clean_htmlparser.
2009-07-15 04:39:30 +04:00
2017-07-04 11:00:03 +03:00
## How to add an attribute
# starting from the root of a mozilla-central checkout
cd parser/html/java/
make sync
# now you have a clone of https://hg.mozilla.org/projects/htmlparser/ in parser/html/java/htmlparser/
cd htmlparser/src/
$EDITOR nu/validator/htmlparser/impl/AttributeName.java
# Search for the word "uncomment" and uncomment stuff according to the comments that talk about uncommenting
# Duplicate the declaration a normal attribute (nothings special in SVG mode, etc.). Let's use "alt", since it's the first one.
# In the duplicate, replace ALT with the new name in all caps and "alt" with the new name in quotes in lower case.
# Search for "ALT,", duplicate that line and change the duplicate to say the new name in all caps followed by comma.
# Save.
javac nu/validator/htmlparser/impl/AttributeName.java
java nu.validator.htmlparser.impl.AttributeName
# Copy and paste the output into nu/validator/htmlparser/impl/AttributeName.java replacing the text below the comment "START GENERATED CODE" and above the very last "}".
# Recomment the bits that you uncommented earlier.
# Save.
cd ../.. # Back to parser/html/java/
make translate
cd ../../..
./mach clang-format
## How to add an element
# First, add an entry to parser/htmlparser/nsHTMLTagList.h or dom/svg/SVGTagList.h!
# Then, starting from the root of a mozilla-central checkout
cd parser/html/java/
make sync
# now you have a clone of https://hg.mozilla.org/projects/htmlparser/ in parser/html/java/htmlparser/
cd htmlparser/src/
$EDITOR nu/validator/htmlparser/impl/ElementName.java
# Search for the word "uncomment" and uncomment stuff according to the comments that talk about uncommenting
# Duplicate the declaration a normal element. Let's use "bdo", since it's the first normal one.
# In the duplicate, replace BDO with the new name in all caps and "bdo" with the new name in quotes in lower case (twice).
# Search for "BDO,", duplicate that line and change the duplicate to say the new name in all caps followed by comma.
# Save.
javac nu/validator/htmlparser/impl/ElementName.java
java nu.validator.htmlparser.impl.ElementName ../../../../../parser/htmlparser/nsHTMLTagList.h ../../../../../dom/svg/SVGTagList.h
# Copy and paste the output into nu/validator/htmlparser/impl/ElementName.java replacing the text below the comment "START GENERATED CODE" and above the very last "}".
# Recomment the bits that you uncommented earlier.
# Save.
cd ../.. # Back to parser/html/java/
make translate
cd ../../..
./mach clang-format
2009-09-23 06:46:51 +04:00
Ben Newman (23 September 2009)
2017-07-04 11:00:03 +03:00
Henri Sivonen (10 August 2017)