diff --git a/j2html-ext-mathml/.gitignore b/j2html-ext-mathml/.gitignore new file mode 100644 index 0000000..a5e3074 --- /dev/null +++ b/j2html-ext-mathml/.gitignore @@ -0,0 +1,101 @@ +# Created by https://www.gitignore.io + +### Intellij ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm + +*.iml + +## Directory-based project format: +.idea/ +# if you remove the above rule, at least ignore the following: + +# User-specific stuff: +# .idea/workspace.xml +# .idea/tasks.xml +# .idea/dictionaries + +# Sensitive or high-churn files: +# .idea/dataSources.ids +# .idea/dataSources.xml +# .idea/sqlDataSources.xml +# .idea/dynamic.xml +# .idea/uiDesigner.xml + +# Gradle: +# .idea/gradle.xml +# .idea/libraries + +# Mongo Explorer plugin: +# .idea/mongoSettings.xml + +## File-based project format: +*.ipr +*.iws + +## Plugin-specific files: + +# IntelliJ +/out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties + + +### Windows ### +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Windows shortcuts +*.lnk + + +### Java ### +*.class + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.ear + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + + +### Maven ### +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml + +### Eclipse ### +.classpath +.project +.settings/ +buildNumber.properties diff --git a/j2html-ext-mathml/pom.xml b/j2html-ext-mathml/pom.xml new file mode 100644 index 0000000..3a9afb5 --- /dev/null +++ b/j2html-ext-mathml/pom.xml @@ -0,0 +1,130 @@ + + + 4.0.0 + + + com.j2html + j2html-parent + 1.6.1-SNAPSHOT + + + j2html-ext-mathml + j2html-ext-mathml + + + + junit + junit + test + + + + com.j2html + j2html + 1.6.1-SNAPSHOT + + + + jar + + + + + com.j2html + j2html-codegen-maven-plugin + 1.6.1-SNAPSHOT + + + + generate-source-files + + + + + ${project.basedir}/src/main/models/mathml.model + com.j2html.mathml.attributes + com.j2html.mathml.tags + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + + org.apache.maven.plugins + maven-release-plugin + + + default + + perform + + + pom.xml + + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + + org.apache.maven.plugins + maven-jar-plugin + + + ${project.build.outputDirectory}/META-INF/MANIFEST.MF + + true + + + com.j2html + + + + + + + org.apache.felix + maven-bundle-plugin + + + bundle-manifest + process-classes + + manifest + + + + + + + + + diff --git a/j2html-ext-mathml/src/main/java/com/j2html/mathml/MathML.java b/j2html-ext-mathml/src/main/java/com/j2html/mathml/MathML.java new file mode 100644 index 0000000..63bfd1a --- /dev/null +++ b/j2html-ext-mathml/src/main/java/com/j2html/mathml/MathML.java @@ -0,0 +1,247 @@ +package com.j2html.mathml; + +import com.j2html.mathml.tags.*; +import j2html.tags.DomContent; + +public class MathML { + + public static AnnotationTag annotation(String text) { + return new AnnotationTag().withText(text); + } + + public static AnnotationTag annotation(DomContent... dc) { + return new AnnotationTag().with(dc); + } + + public static MactionTag maction(String text) { + return new MactionTag().withText(text); + } + + public static MactionTag maction(DomContent... dc) { + return new MactionTag().with(dc); + } + + public static MathTag math(String text) { + return new MathTag().withText(text); + } + + public static MathTag math(DomContent... dc) { + return new MathTag().with(dc); + } + + public static MerrorTag merror(String text) { + return new MerrorTag().withText(text); + } + + public static MerrorTag merror(DomContent... dc) { + return new MerrorTag().with(dc); + } + + public static MfracTag mfrac(String text) { + return new MfracTag().withText(text); + } + + public static MfracTag mfrac(DomContent... dc) { + return new MfracTag().with(dc); + } + + public static MiTag mi(String text) { + return new MiTag().withText(text); + } + + public static MiTag mi(DomContent... dc) { + return new MiTag().with(dc); + } + + public static MmultiscriptsTag mmultiscripts(String text) { + return new MmultiscriptsTag().withText(text); + } + + public static MmultiscriptsTag mmultiscripts(DomContent... dc) { + return new MmultiscriptsTag().with(dc); + } + + public static MnTag mn(String text) { + return new MnTag().withText(text); + } + + public static MnTag mn(DomContent... dc) { + return new MnTag().with(dc); + } + + public static MoTag mo(String text) { + return new MoTag().withText(text); + } + + public static MoTag mo(DomContent... dc) { + return new MoTag().with(dc); + } + + public static MoverTag mover(String text) { + return new MoverTag().withText(text); + } + + public static MoverTag mover(DomContent... dc) { + return new MoverTag().with(dc); + } + + public static MpaddedTag mpadded(String text) { + return new MpaddedTag().withText(text); + } + + public static MpaddedTag mpadded(DomContent... dc) { + return new MpaddedTag().with(dc); + } + + public static MphantomTag mphantom(String text) { + return new MphantomTag().withText(text); + } + + public static MphantomTag mphantom(DomContent... dc) { + return new MphantomTag().with(dc); + } + + public static MprescriptsTag mprescripts(String text) { + return new MprescriptsTag().withText(text); + } + + public static MprescriptsTag mprescripts(DomContent... dc) { + return new MprescriptsTag().with(dc); + } + + public static MrootTag mroot(String text) { + return new MrootTag().withText(text); + } + + public static MrootTag mroot(DomContent... dc) { + return new MrootTag().with(dc); + } + + public static MrowTag mrow(String text) { + return new MrowTag().withText(text); + } + + public static MrowTag mrow(DomContent... dc) { + return new MrowTag().with(dc); + } + + public static MsTag ms(String text) { + return new MsTag().withText(text); + } + + public static MsTag ms(DomContent... dc) { + return new MsTag().with(dc); + } + + public static MspaceTag mspace(String text) { + return new MspaceTag().withText(text); + } + + public static MspaceTag mspace(DomContent... dc) { + return new MspaceTag().with(dc); + } + + public static MsqrtTag msqrt(String text) { + return new MsqrtTag().withText(text); + } + + public static MsqrtTag msqrt(DomContent... dc) { + return new MsqrtTag().with(dc); + } + + public static MstyleTag mstyle(String text) { + return new MstyleTag().withText(text); + } + + public static MstyleTag mstyle(DomContent... dc) { + return new MstyleTag().with(dc); + } + + public static MsubTag msub(String text) { + return new MsubTag().withText(text); + } + + public static MsubTag msub(DomContent... dc) { + return new MsubTag().with(dc); + } + + public static MsubsupTag msubsup(String text) { + return new MsubsupTag().withText(text); + } + + public static MsubsupTag msubsup(DomContent... dc) { + return new MsubsupTag().with(dc); + } + + public static MsupTag msup(String text) { + return new MsupTag().withText(text); + } + + public static MsupTag msup(DomContent... dc) { + return new MsupTag().with(dc); + } + + public static MtableTag mtable(String text) { + return new MtableTag().withText(text); + } + + public static MtableTag mtable(DomContent... dc) { + return new MtableTag().with(dc); + } + + public static MtdTag mtd(String text) { + return new MtdTag().withText(text); + } + + public static MtdTag mtd(DomContent... dc) { + return new MtdTag().with(dc); + } + + public static MtextTag mtext(String text) { + return new MtextTag().withText(text); + } + + public static MtextTag mtext(DomContent... dc) { + return new MtextTag().with(dc); + } + + public static MtrTag mtr(String text) { + return new MtrTag().withText(text); + } + + public static MtrTag mtr(DomContent... dc) { + return new MtrTag().with(dc); + } + + public static MunderTag munder(String text) { + return new MunderTag().withText(text); + } + + public static MunderTag munder(DomContent... dc) { + return new MunderTag().with(dc); + } + + public static MunderoverTag munderover(String text) { + return new MunderoverTag().withText(text); + } + + public static MunderoverTag munderover(DomContent... dc) { + return new MunderoverTag().with(dc); + } + + public static NoneTag none(String text) { + return new NoneTag().withText(text); + } + + public static NoneTag none(DomContent... dc) { + return new NoneTag().with(dc); + } + + public static SemanticsTag semantics(String text) { + return new SemanticsTag().withText(text); + } + + public static SemanticsTag semantics(DomContent... dc) { + return new SemanticsTag().with(dc); + } +} diff --git a/j2html-ext-mathml/src/main/models/mathml.model b/j2html-ext-mathml/src/main/models/mathml.model new file mode 100644 index 0000000..eb00be9 --- /dev/null +++ b/j2html-ext-mathml/src/main/models/mathml.model @@ -0,0 +1,254 @@ +ELEMENT[annotation] +ELEMENT[maction] +ELEMENT[math] +ELEMENT[merror] +ELEMENT[mfrac] +ELEMENT[mi] +ELEMENT[mmultiscripts] +ELEMENT[mn] +ELEMENT[mo] +ELEMENT[mover] +ELEMENT[mpadded] +ELEMENT[mphantom] +ELEMENT[mprescripts] +ELEMENT[mroot] +ELEMENT[mrow] +ELEMENT[ms] +ELEMENT[mspace] +ELEMENT[msqrt] +ELEMENT[mstyle] +ELEMENT[msub] +ELEMENT[msubsup] +ELEMENT[msup] +ELEMENT[mtable] +ELEMENT[mtd] +ELEMENT[mtext] +ELEMENT[mtr] +ELEMENT[munder] +ELEMENT[munderover] +ELEMENT[none] +ELEMENT[semantics] + +BOOLEAN[displaystyle] +ATTRIBUTE[annotation:displaystyle] +ATTRIBUTE[maction:displaystyle] +ATTRIBUTE[math:displaystyle] +ATTRIBUTE[merror:displaystyle] +ATTRIBUTE[mfrac:displaystyle] +ATTRIBUTE[mi:displaystyle] +ATTRIBUTE[mmultiscripts:displaystyle] +ATTRIBUTE[mn:displaystyle] +ATTRIBUTE[mo:displaystyle] +ATTRIBUTE[mover:displaystyle] +ATTRIBUTE[mpadded:displaystyle] +ATTRIBUTE[mphantom:displaystyle] +ATTRIBUTE[mprescripts:displaystyle] +ATTRIBUTE[mroot:displaystyle] +ATTRIBUTE[mrow:displaystyle] +ATTRIBUTE[ms:displaystyle] +ATTRIBUTE[mspace:displaystyle] +ATTRIBUTE[msqrt:displaystyle] +ATTRIBUTE[mstyle:displaystyle] +ATTRIBUTE[msub:displaystyle] +ATTRIBUTE[msubsup:displaystyle] +ATTRIBUTE[msup:displaystyle] +ATTRIBUTE[mtable:displaystyle] +ATTRIBUTE[mtd:displaystyle] +ATTRIBUTE[mtext:displaystyle] +ATTRIBUTE[mtr:displaystyle] +ATTRIBUTE[munder:displaystyle] +ATTRIBUTE[munderover:displaystyle] +ATTRIBUTE[none:displaystyle] +ATTRIBUTE[semantics:displaystyle] + +BOOLEAN[mathbackground] +ATTRIBUTE[annotation:mathbackground] +ATTRIBUTE[maction:mathbackground] +ATTRIBUTE[math:mathbackground] +ATTRIBUTE[merror:mathbackground] +ATTRIBUTE[mfrac:mathbackground] +ATTRIBUTE[mi:mathbackground] +ATTRIBUTE[mmultiscripts:mathbackground] +ATTRIBUTE[mn:mathbackground] +ATTRIBUTE[mo:mathbackground] +ATTRIBUTE[mover:mathbackground] +ATTRIBUTE[mpadded:mathbackground] +ATTRIBUTE[mphantom:mathbackground] +ATTRIBUTE[mprescripts:mathbackground] +ATTRIBUTE[mroot:mathbackground] +ATTRIBUTE[mrow:mathbackground] +ATTRIBUTE[ms:mathbackground] +ATTRIBUTE[mspace:mathbackground] +ATTRIBUTE[msqrt:mathbackground] +ATTRIBUTE[mstyle:mathbackground] +ATTRIBUTE[msub:mathbackground] +ATTRIBUTE[msubsup:mathbackground] +ATTRIBUTE[msup:mathbackground] +ATTRIBUTE[mtable:mathbackground] +ATTRIBUTE[mtd:mathbackground] +ATTRIBUTE[mtext:mathbackground] +ATTRIBUTE[mtr:mathbackground] +ATTRIBUTE[munder:mathbackground] +ATTRIBUTE[munderover:mathbackground] +ATTRIBUTE[none:mathbackground] +ATTRIBUTE[semantics:mathbackground] + +BOOLEAN[mathcolor] +ATTRIBUTE[annotation:mathcolor] +ATTRIBUTE[maction:mathcolor] +ATTRIBUTE[math:mathcolor] +ATTRIBUTE[merror:mathcolor] +ATTRIBUTE[mfrac:mathcolor] +ATTRIBUTE[mi:mathcolor] +ATTRIBUTE[mmultiscripts:mathcolor] +ATTRIBUTE[mn:mathcolor] +ATTRIBUTE[mo:mathcolor] +ATTRIBUTE[mover:mathcolor] +ATTRIBUTE[mpadded:mathcolor] +ATTRIBUTE[mphantom:mathcolor] +ATTRIBUTE[mprescripts:mathcolor] +ATTRIBUTE[mroot:mathcolor] +ATTRIBUTE[mrow:mathcolor] +ATTRIBUTE[ms:mathcolor] +ATTRIBUTE[mspace:mathcolor] +ATTRIBUTE[msqrt:mathcolor] +ATTRIBUTE[mstyle:mathcolor] +ATTRIBUTE[msub:mathcolor] +ATTRIBUTE[msubsup:mathcolor] +ATTRIBUTE[msup:mathcolor] +ATTRIBUTE[mtable:mathcolor] +ATTRIBUTE[mtd:mathcolor] +ATTRIBUTE[mtext:mathcolor] +ATTRIBUTE[mtr:mathcolor] +ATTRIBUTE[munder:mathcolor] +ATTRIBUTE[munderover:mathcolor] +ATTRIBUTE[none:mathcolor] +ATTRIBUTE[semantics:mathcolor] + +BOOLEAN[mathsize] +ATTRIBUTE[annotation:mathsize] +ATTRIBUTE[maction:mathsize] +ATTRIBUTE[math:mathsize] +ATTRIBUTE[merror:mathsize] +ATTRIBUTE[mfrac:mathsize] +ATTRIBUTE[mi:mathsize] +ATTRIBUTE[mmultiscripts:mathsize] +ATTRIBUTE[mn:mathsize] +ATTRIBUTE[mo:mathsize] +ATTRIBUTE[mover:mathsize] +ATTRIBUTE[mpadded:mathsize] +ATTRIBUTE[mphantom:mathsize] +ATTRIBUTE[mprescripts:mathsize] +ATTRIBUTE[mroot:mathsize] +ATTRIBUTE[mrow:mathsize] +ATTRIBUTE[ms:mathsize] +ATTRIBUTE[mspace:mathsize] +ATTRIBUTE[msqrt:mathsize] +ATTRIBUTE[mstyle:mathsize] +ATTRIBUTE[msub:mathsize] +ATTRIBUTE[msubsup:mathsize] +ATTRIBUTE[msup:mathsize] +ATTRIBUTE[mtable:mathsize] +ATTRIBUTE[mtd:mathsize] +ATTRIBUTE[mtext:mathsize] +ATTRIBUTE[mtr:mathsize] +ATTRIBUTE[munder:mathsize] +ATTRIBUTE[munderover:mathsize] +ATTRIBUTE[none:mathsize] +ATTRIBUTE[semantics:mathsize] + +BOOLEAN[mathvariant] +ATTRIBUTE[annotation:mathvariant] +ATTRIBUTE[maction:mathvariant] +ATTRIBUTE[math:mathvariant] +ATTRIBUTE[merror:mathvariant] +ATTRIBUTE[mfrac:mathvariant] +ATTRIBUTE[mi:mathvariant] +ATTRIBUTE[mmultiscripts:mathvariant] +ATTRIBUTE[mn:mathvariant] +ATTRIBUTE[mo:mathvariant] +ATTRIBUTE[mover:mathvariant] +ATTRIBUTE[mpadded:mathvariant] +ATTRIBUTE[mphantom:mathvariant] +ATTRIBUTE[mprescripts:mathvariant] +ATTRIBUTE[mroot:mathvariant] +ATTRIBUTE[mrow:mathvariant] +ATTRIBUTE[ms:mathvariant] +ATTRIBUTE[mspace:mathvariant] +ATTRIBUTE[msqrt:mathvariant] +ATTRIBUTE[mstyle:mathvariant] +ATTRIBUTE[msub:mathvariant] +ATTRIBUTE[msubsup:mathvariant] +ATTRIBUTE[msup:mathvariant] +ATTRIBUTE[mtable:mathvariant] +ATTRIBUTE[mtd:mathvariant] +ATTRIBUTE[mtext:mathvariant] +ATTRIBUTE[mtr:mathvariant] +ATTRIBUTE[munder:mathvariant] +ATTRIBUTE[munderover:mathvariant] +ATTRIBUTE[none:mathvariant] +ATTRIBUTE[semantics:mathvariant] + +BOOLEAN[nonce] +ATTRIBUTE[annotation:nonce] +ATTRIBUTE[maction:nonce] +ATTRIBUTE[math:nonce] +ATTRIBUTE[merror:nonce] +ATTRIBUTE[mfrac:nonce] +ATTRIBUTE[mi:nonce] +ATTRIBUTE[mmultiscripts:nonce] +ATTRIBUTE[mn:nonce] +ATTRIBUTE[mo:nonce] +ATTRIBUTE[mover:nonce] +ATTRIBUTE[mpadded:nonce] +ATTRIBUTE[mphantom:nonce] +ATTRIBUTE[mprescripts:nonce] +ATTRIBUTE[mroot:nonce] +ATTRIBUTE[mrow:nonce] +ATTRIBUTE[ms:nonce] +ATTRIBUTE[mspace:nonce] +ATTRIBUTE[msqrt:nonce] +ATTRIBUTE[mstyle:nonce] +ATTRIBUTE[msub:nonce] +ATTRIBUTE[msubsup:nonce] +ATTRIBUTE[msup:nonce] +ATTRIBUTE[mtable:nonce] +ATTRIBUTE[mtd:nonce] +ATTRIBUTE[mtext:nonce] +ATTRIBUTE[mtr:nonce] +ATTRIBUTE[munder:nonce] +ATTRIBUTE[munderover:nonce] +ATTRIBUTE[none:nonce] +ATTRIBUTE[semantics:nonce] + +BOOLEAN[scriptlevel] +ATTRIBUTE[annotation:scriptlevel] +ATTRIBUTE[maction:scriptlevel] +ATTRIBUTE[math:scriptlevel] +ATTRIBUTE[merror:scriptlevel] +ATTRIBUTE[mfrac:scriptlevel] +ATTRIBUTE[mi:scriptlevel] +ATTRIBUTE[mmultiscripts:scriptlevel] +ATTRIBUTE[mn:scriptlevel] +ATTRIBUTE[mo:scriptlevel] +ATTRIBUTE[mover:scriptlevel] +ATTRIBUTE[mpadded:scriptlevel] +ATTRIBUTE[mphantom:scriptlevel] +ATTRIBUTE[mprescripts:scriptlevel] +ATTRIBUTE[mroot:scriptlevel] +ATTRIBUTE[mrow:scriptlevel] +ATTRIBUTE[ms:scriptlevel] +ATTRIBUTE[mspace:scriptlevel] +ATTRIBUTE[msqrt:scriptlevel] +ATTRIBUTE[mstyle:scriptlevel] +ATTRIBUTE[msub:scriptlevel] +ATTRIBUTE[msubsup:scriptlevel] +ATTRIBUTE[msup:scriptlevel] +ATTRIBUTE[mtable:scriptlevel] +ATTRIBUTE[mtd:scriptlevel] +ATTRIBUTE[mtext:scriptlevel] +ATTRIBUTE[mtr:scriptlevel] +ATTRIBUTE[munder:scriptlevel] +ATTRIBUTE[munderover:scriptlevel] +ATTRIBUTE[none:scriptlevel] +ATTRIBUTE[semantics:scriptlevel] diff --git a/j2html-ext-mathml/src/test/java/MathMLTests.java b/j2html-ext-mathml/src/test/java/MathMLTests.java new file mode 100644 index 0000000..3376a71 --- /dev/null +++ b/j2html-ext-mathml/src/test/java/MathMLTests.java @@ -0,0 +1,42 @@ +import org.junit.Test; + +import static com.j2html.mathml.MathML.*; +import static org.junit.Assert.assertEquals; + +public class MathMLTests { + + @Test + public void all_tags_render_containers(){ + assertEquals("", annotation().render()); + assertEquals("", maction().render()); + assertEquals("", math().render()); + assertEquals("", merror().render()); + assertEquals("", mfrac().render()); + assertEquals("", mi().render()); + assertEquals("", mmultiscripts().render()); + assertEquals("", mn().render()); + assertEquals("", mo().render()); + assertEquals("", mover().render()); + assertEquals("", mpadded().render()); + assertEquals("", mphantom().render()); + assertEquals("", mprescripts().render()); + assertEquals("", mroot().render()); + assertEquals("", mrow().render()); + assertEquals("", ms().render()); + assertEquals("", mspace().render()); + assertEquals("", msqrt().render()); + assertEquals("", mstyle().render()); + assertEquals("", msub().render()); + assertEquals("", msubsup().render()); + assertEquals("", msup().render()); + assertEquals("", mtable().render()); + assertEquals("", mtd().render()); + assertEquals("", mtext().render()); + assertEquals("", mtr().render()); + assertEquals("", munder().render()); + assertEquals("", munderover().render()); + assertEquals("", none().render()); + assertEquals("", semantics().render()); + } + +} diff --git a/pom.xml b/pom.xml index 8b7aaa0..919ca8b 100644 --- a/pom.xml +++ b/pom.xml @@ -53,6 +53,7 @@ j2html j2html-codegen + j2html-ext-mathml j2html-website