summaryrefslogtreecommitdiffstats
path: root/parser/html/java
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:44:51 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:44:51 +0000
commit9e3c08db40b8916968b9f30096c7be3f00ce9647 (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /parser/html/java
parentInitial commit. (diff)
downloadthunderbird-9e3c08db40b8916968b9f30096c7be3f00ce9647.tar.xz
thunderbird-9e3c08db40b8916968b9f30096c7be3f00ce9647.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'parser/html/java')
-rw-r--r--parser/html/java/Makefile52
-rw-r--r--parser/html/java/README.txt86
-rw-r--r--parser/html/java/manifest.txt2
3 files changed, 140 insertions, 0 deletions
diff --git a/parser/html/java/Makefile b/parser/html/java/Makefile
new file mode 100644
index 0000000000..5dd7d6bb0a
--- /dev/null
+++ b/parser/html/java/Makefile
@@ -0,0 +1,52 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+libs:: translator
+
+translator:: javaparser \
+; mkdir -p htmlparser/bin && \
+ find htmlparser/translator-src/nu/validator/htmlparser -name "*.java" | \
+ xargs javac -cp javaparser.jar -g -d htmlparser/bin && \
+ jar cfm translator.jar manifest.txt -C htmlparser/bin .
+
+javaparser:: \
+; mkdir -p javaparser/bin && \
+ find javaparser/src -name "*.java" | \
+ xargs javac -encoding ISO-8859-1 -g -d javaparser/bin && \
+ jar cf javaparser.jar -C javaparser/bin .
+
+sync_javaparser:: \
+; if [ ! -d javaparser/.git ] ; \
+ then rm -rf javaparser ; \
+ git clone https://github.com/javaparser/javaparser.git ; \
+ fi ; \
+ cd javaparser ; git checkout javaparser-1.0.6 ; cd ..
+
+sync_htmlparser:: \
+; if [ -d htmlparser/.hg ] ; \
+ then echo "The htmlparser repo has move to GitHub. Please remove the htmlparser directory and resync." ; exit ; \
+ elif [ ! -d htmlparser/.git ] ; \
+ then rm -rf htmlparser ; \
+ git clone https://github.com/validator/htmlparser.git ; \
+ cd htmlparser ; git checkout master ; cd .. ; \
+ fi
+
+sync:: sync_javaparser sync_htmlparser
+
+translate:: translator \
+; mkdir -p ../javasrc ; \
+ java -jar translator.jar \
+ htmlparser/src/nu/validator/htmlparser/impl \
+ .. ../../../xpcom/ds/StaticAtoms.py ../../../xpcom/ds/HTMLAtoms.py
+
+translate_from_snapshot:: translator \
+; mkdir -p ../javasrc ; \
+ java -jar translator.jar \
+ ../javasrc \
+ .. ../../../xpcom/ds/StaticAtoms.py ../../../xpcom/ds/HTMLAtoms.py
+
+named_characters:: translator \
+; java -cp translator.jar \
+ nu.validator.htmlparser.generator.GenerateNamedCharactersCpp \
+ named-character-references.html ../
diff --git a/parser/html/java/README.txt b/parser/html/java/README.txt
new file mode 100644
index 0000000000..13eeb9a5cf
--- /dev/null
+++ b/parser/html/java/README.txt
@@ -0,0 +1,86 @@
+If this is your first time building the HTML5 parser, you need to execute the
+following commands (from this directory) to bootstrap the translation:
+
+ make sync # fetch remote source files and licenses
+ make translate # perform the Java-to-C++ translation from the remote
+ # sources
+ make named_characters # Generate tables for named character tokenization
+
+If you make changes to the translator or the javaparser, you can rebuild by
+retyping 'make' in this directory. If you make changes to the HTML5 Java
+implementation, you can retranslate the Java sources from the htmlparser
+repository by retyping 'make translate' in this directory.
+
+The makefile supports the following targets:
+
+sync_htmlparser:
+ Retrieves the HTML parser and Java to C++ translator sources from GitHub.
+sync_javaparser:
+ Retrieves the javaparser sources from GitHub.
+sync:
+ Runs both sync_javaparser and sync_htmlparser.
+javaparser:
+ Builds the javaparser library retrieved earlier by sync_javaparser.
+translator:
+ Runs the javaparser target and then builds the Java to C++ translator from
+ sources retrieved earlier by sync_htmlparser.
+libs:
+ The default target. Alias for translator
+translate:
+ Runs the translator target and then translates the HTML parser sources
+ retrieved by sync_htmlparser copying the Java sources to ../javasrc.
+translate_from_snapshot:
+ Runs the translator target and then translates the HTML parser sources
+ stored in ../javasrc.
+named_characters:
+ Generates data tables for named character tokenization.
+
+## 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://github.com/validator/htmlparser/tree/master 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://github.com/validator/htmlparser/tree/master 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
+
+Ben Newman (23 September 2009)
+Henri Sivonen (10 August 2017, 10 February 2020)
diff --git a/parser/html/java/manifest.txt b/parser/html/java/manifest.txt
new file mode 100644
index 0000000000..14cd9d0819
--- /dev/null
+++ b/parser/html/java/manifest.txt
@@ -0,0 +1,2 @@
+Main-Class: nu.validator.htmlparser.cpptranslate.Main
+Class-Path: javaparser.jar