diff --git a/js/src/test/scala/com/thirdparty/CompileSpec.scala b/js/src/test/scala/com/thirdparty/CompileSpec.scala index fe485ea3..9dcc4d94 100644 --- a/js/src/test/scala/com/thirdparty/CompileSpec.scala +++ b/js/src/test/scala/com/thirdparty/CompileSpec.scala @@ -1,12 +1,12 @@ package com.thirdparty -import com.thirdparty.defs.attrs.{AriaAttrs, HtmlAttrs, SvgAttrs} +import com.thirdparty.defs.attrs.{AriaAttrs, HtmlAttrs, SvgAttrs, MathMLAttrs} import com.thirdparty.defs.complex.{ComplexHtmlKeys, ComplexSvgKeys} import com.thirdparty.defs.eventProps.{DocumentEventProps, GlobalEventProps, WindowEventProps} import com.thirdparty.defs.props.Props import com.thirdparty.defs.styles.StyleProps import com.thirdparty.defs.styles.units.{Calc, Color, Length, Time, Url} -import com.thirdparty.defs.tags.{HtmlTags, SvgTags} +import com.thirdparty.defs.tags.{HtmlTags, SvgTags, MathMLTags} import com.thirdparty.keys.{DerivedStyleBuilder, DerivedStyleProp, StyleProp, SvgAttr} import com.thirdparty.setters.StyleSetter import com.thirdparty.tags.HtmlTag @@ -49,6 +49,10 @@ class CompileSpec extends AnyFunSpec with Matchers { with SvgAttrs with ComplexSvgKeys + object mathml + extends MathMLTags + with MathMLAttrs + object aria extends AriaAttrs @@ -99,6 +103,34 @@ class CompileSpec extends AnyFunSpec with Matchers { assert(svg.xlinkHref.qualifiedName == "xlink:href") assert(SvgAttr.namespaceUrl(svg.xlinkHref.namespace.get) == "http://www.w3.org/1999/xlink") + // MathML basic functionality + + assert(mathml.math.domName == "math") + assert(mathml.mi.domName == "mi") + assert(mathml.mn.domName == "mn") + assert(mathml.mo.domName == "mo") + assert(mathml.mrow.domName == "mrow") + assert(mathml.mfrac.domName == "mfrac") + assert(mathml.msup.domName == "msup") + assert(mathml.msub.domName == "msub") + + // MathML attributes + + assert(mathml.display.domName == "display") + assert(mathml.mathvariant.domName == "mathvariant") + assert(mathml.mathsize.domName == "mathsize") + assert(mathml.mathcolor.domName == "mathcolor") + assert(mathml.mathbackground.domName == "mathbackground") + assert(mathml.displaystyle.domName == "displaystyle") + assert(mathml.scriptlevel.domName == "scriptlevel") + assert(mathml.xmlns.domName == "xmlns") + + // xmlns attribute available on all element types + + assert(html.xmlns.domName == "xmlns") // HTML xmlns + assert(svg.xmlns.domName == "xmlns") // SVG xmlns + assert(mathml.xmlns.domName == "xmlns") // MathML xmlns + // Aliases assert(html.typ == html.`type`) diff --git a/js/src/test/scala/com/thirdparty/codecs/package.scala b/js/src/test/scala/com/thirdparty/codecs/package.scala index 2f8d5a1e..40daeb8c 100644 --- a/js/src/test/scala/com/thirdparty/codecs/package.scala +++ b/js/src/test/scala/com/thirdparty/codecs/package.scala @@ -5,6 +5,7 @@ package object codecs { // String Codecs object StringAsIsCodec extends AsIsCodec[String] + val StringAsIs = StringAsIsCodec // Int Codecs @@ -14,6 +15,7 @@ package object codecs { override def decode(domValue: String): Int = domValue.toInt // @TODO this can throw exception. How do we handle this? override def encode(scalaValue: Int): String = scalaValue.toString } + val IntAsString = IntAsStringCodec // Double Codecs @@ -32,6 +34,7 @@ package object codecs { override def decode(domValue: String): Boolean = domValue != null override def encode(scalaValue: Boolean): String = if (scalaValue) "" else null } + val BooleanAsPresence = BooleanAsAttrPresenceCodec object BooleanAsTrueFalseStringCodec extends Codec[Boolean, String] { override def decode(domValue: String): Boolean = domValue == "true" diff --git a/js/src/test/scala/com/thirdparty/defs/attrs/HtmlAttrs.scala b/js/src/test/scala/com/thirdparty/defs/attrs/HtmlAttrs.scala index 11b0474b..01ee4742 100644 --- a/js/src/test/scala/com/thirdparty/defs/attrs/HtmlAttrs.scala +++ b/js/src/test/scala/com/thirdparty/defs/attrs/HtmlAttrs.scala @@ -181,5 +181,14 @@ trait HtmlAttrs { */ lazy val widthAttr: HtmlAttr[Int] = intHtmlAttr("width") + /** + * The xmlns attribute specifies the XML namespace for the element. + * This is especially important when mixing HTML with other XML vocabularies + * like SVG or MathML. + * + * [[https://developer.mozilla.org/en-US/docs/Web/API/Element/namespaceURI namespaceURI @ MDN]] + */ + lazy val xmlns: HtmlAttr[String] = stringHtmlAttr("xmlns") + } diff --git a/js/src/test/scala/com/thirdparty/defs/attrs/MathMLAttrs.scala b/js/src/test/scala/com/thirdparty/defs/attrs/MathMLAttrs.scala new file mode 100644 index 00000000..9e86f0e8 --- /dev/null +++ b/js/src/test/scala/com/thirdparty/defs/attrs/MathMLAttrs.scala @@ -0,0 +1,93 @@ +package com.thirdparty.defs.attrs + +import com.thirdparty.keys.MathMLAttr +import com.thirdparty.codecs._ + +// #NOTE: GENERATED CODE +// - This file is generated at compile time from the data in Scala DOM Types +// - See `GeneratorSpec.scala` for code generation params +// - Contribute to https://github.com/raquo/scala-dom-types to add missing tags / attrs / props / etc. + +trait MathMLAttrs { + + def stringMathMLAttr(name: String, namespace: Option[String] = None): MathMLAttr[String] = new MathMLAttr(name, StringAsIs, namespace) + def booleanMathMLAttr(name: String, namespace: Option[String] = None): MathMLAttr[Boolean] = new MathMLAttr(name, BooleanAsPresence, namespace) + def intMathMLAttr(name: String, namespace: Option[String] = None): MathMLAttr[Int] = new MathMLAttr(name, IntAsString, namespace) + + /** + * This enumerated attribute specifies how the enclosed MathML markup should be rendered. + * It can have one of the following values: + * - block, which means that this element will be displayed in its own block outside the current span of text + * - inline, which means that this element will be displayed inside the current span of text + * + * If not present, its default value is inline. + * + * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Global_attributes/display display @ MDN]] + */ + lazy val display: MathMLAttr[String] = stringMathMLAttr("display") + + /** + * This attribute specifies the logical class of the identifier, which varies + * in typography. That is, although the names suggest the typographic style for + * the class, semantically, items with the same class are treated "the same" + * within an expression, which might or might not involve displaying them with + * the same typography. + * + * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Global_attributes/mathvariant mathvariant @ MDN]] + */ + lazy val mathvariant: MathMLAttr[String] = stringMathMLAttr("mathvariant") + + /** + * This attribute specifies the size of the content. Possible values are: + * - small: The content is rendered smaller than the surrounding text. + * - normal: The content is rendered at the same size as the surrounding text. + * - big: The content is rendered larger than the surrounding text. + * - A length value like '12pt', '2em', etc. + * + * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Global_attributes/mathsize mathsize @ MDN]] + */ + lazy val mathsize: MathMLAttr[String] = stringMathMLAttr("mathsize") + + /** + * This attribute sets the text color and also the fraction line color. + * You can use named colors or RGB format like #rgb, #rrggbb and CSS color names. + * + * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Global_attributes/mathcolor mathcolor @ MDN]] + */ + lazy val mathcolor: MathMLAttr[String] = stringMathMLAttr("mathcolor") + + /** + * This attribute sets the background color. You can use named colors + * or RGB format like #rgb, #rrggbb and CSS color names. + * + * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Global_attributes/mathbackground mathbackground @ MDN]] + */ + lazy val mathbackground: MathMLAttr[String] = stringMathMLAttr("mathbackground") + + /** + * This Boolean attribute specifies whether more vertical space is used + * for displayed equations or, if set to false, a more compact layout + * is used to display formulas. + * + * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Global_attributes/displaystyle displaystyle @ MDN]] + */ + lazy val displaystyle: MathMLAttr[Boolean] = booleanMathMLAttr("displaystyle") + + /** + * This attribute specifies a scriptlevel for the element. Larger values + * mean smaller font sizes. The scriptlevel is used to control the font size + * in a context-dependent way. + * + * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Global_attributes/scriptlevel scriptlevel @ MDN]] + */ + lazy val scriptlevel: MathMLAttr[Int] = intMathMLAttr("scriptlevel") + + /** + * The xmlns attribute specifies the XML namespace for the MathML element. + * For MathML, this should typically be 'http://www.w3.org/1998/Math/MathML'. + * + * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Element/math#xmlns xmlns @ MDN]] + */ + lazy val xmlns: MathMLAttr[String] = stringMathMLAttr("xmlns") + +} \ No newline at end of file diff --git a/js/src/test/scala/com/thirdparty/defs/tags/MathMLTags.scala b/js/src/test/scala/com/thirdparty/defs/tags/MathMLTags.scala new file mode 100644 index 00000000..f9d127d4 --- /dev/null +++ b/js/src/test/scala/com/thirdparty/defs/tags/MathMLTags.scala @@ -0,0 +1,89 @@ +package com.thirdparty.defs.tags + +import com.thirdparty.tags.MathMLTag +import org.scalajs.dom + +// #NOTE: GENERATED CODE +// - This file is generated at compile time from the data in Scala DOM Types +// - See `GeneratorSpec.scala` for code generation params +// - Contribute to https://github.com/raquo/scala-dom-types to add missing tags / attrs / props / etc. + +trait MathMLTags { + + def mathMLTag[El <: dom.Element](name: String): MathMLTag[El] = new MathMLTag(name) + + /** + * The top-level element in MathML is math. Every valid MathML instance + * must be wrapped in math tags. In addition you must not nest a second + * math element in another, but you can have an arbitrary number of other + * child elements in it. + * + * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Element/math math @ MDN]] + */ + lazy val math: MathMLTag[dom.Element] = mathMLTag("math") + + /** + * The mi element indicates that the content should be rendered as an + * identifier such as function names, variables or symbolic constants. + * You can also have arbitrary text in it to mark up terms. + * + * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mi mi @ MDN]] + */ + lazy val mi: MathMLTag[dom.Element] = mathMLTag("mi") + + /** + * The mn element represents a numeric literal which is normally a + * sequence of digits with a possible separator (a dot or a comma). + * However, it is also allowed to have arbitrary text in it which is + * actually a numeric quantity, for example "eleven". + * + * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mn mn @ MDN]] + */ + lazy val mn: MathMLTag[dom.Element] = mathMLTag("mn") + + /** + * The mo element represents an operator in a broad sense. Besides + * operators in strict mathematical meaning, this element also includes + * "operators" like parentheses, separators like comma and semicolon, + * or "absolute value" bars. + * + * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo mo @ MDN]] + */ + lazy val mo: MathMLTag[dom.Element] = mathMLTag("mo") + + /** + * The mrow element is used to group sub-expressions, which usually + * contain one or more operators with their respective operands + * (such as mi and mn). This element renders as a horizontal row + * containing its arguments. + * + * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mrow mrow @ MDN]] + */ + lazy val mrow: MathMLTag[dom.Element] = mathMLTag("mrow") + + /** + * The mfrac element is used to display fractions. It can also be + * used to mark up fraction-like objects such as binomial coefficients + * and Legendre symbols. + * + * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mfrac mfrac @ MDN]] + */ + lazy val mfrac: MathMLTag[dom.Element] = mathMLTag("mfrac") + + /** + * The msup element is used to attach a superscript to an expression. + * It uses the syntax: msup base superscript + * + * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Element/msup msup @ MDN]] + */ + lazy val msup: MathMLTag[dom.Element] = mathMLTag("msup") + + /** + * The msub element is used to attach a subscript to an expression. + * It uses the syntax: msub base subscript + * + * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Element/msub msub @ MDN]] + */ + lazy val msub: MathMLTag[dom.Element] = mathMLTag("msub") + +} \ No newline at end of file diff --git a/js/src/test/scala/com/thirdparty/keys/MathMLAttr.scala b/js/src/test/scala/com/thirdparty/keys/MathMLAttr.scala new file mode 100644 index 00000000..0a92bebd --- /dev/null +++ b/js/src/test/scala/com/thirdparty/keys/MathMLAttr.scala @@ -0,0 +1,7 @@ +package com.thirdparty.keys + +class MathMLAttr[V]( + override val domName: String, + override val codec: com.thirdparty.codecs.Codec[V, String], + val namespace: Option[String] +) extends Attr[V] \ No newline at end of file diff --git a/js/src/test/scala/com/thirdparty/tags/MathMLTag.scala b/js/src/test/scala/com/thirdparty/tags/MathMLTag.scala new file mode 100644 index 00000000..8f0d5567 --- /dev/null +++ b/js/src/test/scala/com/thirdparty/tags/MathMLTag.scala @@ -0,0 +1,5 @@ +package com.thirdparty.tags + +import org.scalajs.dom + +class MathMLTag[El <: dom.Element](val domName: String) extends Tag[El] \ No newline at end of file diff --git a/jvm/src/test/scala/com/raquo/domtypes/GeneratorSpec.scala b/jvm/src/test/scala/com/raquo/domtypes/GeneratorSpec.scala index afbca7d3..b86c1687 100644 --- a/jvm/src/test/scala/com/raquo/domtypes/GeneratorSpec.scala +++ b/jvm/src/test/scala/com/raquo/domtypes/GeneratorSpec.scala @@ -2,7 +2,7 @@ package com.raquo.domtypes import com.raquo.domtypes.codegen.DefType.LazyVal import com.raquo.domtypes.codegen._ -import com.raquo.domtypes.common.{HtmlTagType, SvgTagType} +import com.raquo.domtypes.common.{HtmlTagType, SvgTagType, MathMLTagType} import com.raquo.domtypes.defs.styles.StyleTraitDefs import org.scalatest.funspec.AnyFunSpec import org.scalatest.matchers.should.Matchers @@ -90,6 +90,31 @@ class GeneratorSpec extends AnyFunSpec with Matchers { ) } + it("Generate MathML tags") { + println("=== MATHML TAGS ===") + + val traitName = "MathMLTags" + + val fileContent = generator.generateTagsTrait( + tagType = MathMLTagType, + defGroups = defGroups.mathMLTagsDefGroups, + printDefGroupComments = false, + traitCommentLines = Nil, + traitModifiers = Nil, + traitName = traitName, + keyKind = "MathMLTag", + baseImplDefComments = Nil, + keyImplName = "mathMLTag", + defType = LazyVal + ) + + generator.writeToFile( + packagePath = generator.tagDefsPackagePath, + fileName = traitName, + fileContent = fileContent + ) + } + it("Generate HTML attributes ") { println("=== HTML ATTRS ===") @@ -174,6 +199,34 @@ class GeneratorSpec extends AnyFunSpec with Matchers { ) } + it("Generate MathML attributes ") { + println("=== MATHML ATTRS ===") + + val traitName = "MathMLAttrs" + + val fileContent = generator.generateAttrsTrait( + defGroups = defGroups.mathMLAttrDefGroups, + printDefGroupComments = false, + traitModifiers = Nil, + traitName = traitName, + traitCommentLines = Nil, + keyKind = "MathMLAttr", + implNameSuffix = "MathMLAttr", + baseImplDefComments = Nil, + baseImplName = "mathMLAttr", + namespaceImports = Nil, + namespaceImpl = _ => ???, + transformAttrDomName = identity, + defType = LazyVal + ) + + generator.writeToFile( + packagePath = generator.attrDefsPackagePath, + fileName = traitName, + fileContent = fileContent + ) + } + it("Generate HTML Props") { println("=== HTML Props ===") diff --git a/sbt b/sbt new file mode 100755 index 00000000..6d7bad84 --- /dev/null +++ b/sbt @@ -0,0 +1,664 @@ +#!/usr/bin/env bash +# +# A more capable sbt runner, coincidentally also called sbt. +# Author: Paul Phillips +# https://github.com/paulp/sbt-extras +# +# Generated from http://www.opensource.org/licenses/bsd-license.php +# Copyright (c) 2011, Paul Phillips. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the author nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +set -o pipefail + +declare -r sbt_release_version="1.11.3" +declare -r sbt_unreleased_version="1.11.3" + +declare -r latest_213="2.13.16" +declare -r latest_212="2.12.20" +declare -r latest_211="2.11.12" +declare -r latest_210="2.10.7" +declare -r latest_29="2.9.3" +declare -r latest_28="2.8.2" + +declare -r buildProps="project/build.properties" + +declare -r sbt_launch_ivy_release_repo="https://repo.typesafe.com/typesafe/ivy-releases" +declare -r sbt_launch_ivy_snapshot_repo="https://repo.scala-sbt.org/scalasbt/ivy-snapshots" +declare -r sbt_launch_mvn_release_repo="https://repo1.maven.org/maven2" +declare -r sbt_launch_mvn_snapshot_repo="https://repo.scala-sbt.org/scalasbt/maven-snapshots" + +declare -r default_jvm_opts_common="-Xms512m -Xss2m -XX:MaxInlineLevel=18" +declare -r noshare_opts="-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy -Dsbt.coursier.home=project/.coursier" + +declare sbt_jar sbt_dir sbt_create sbt_version sbt_script sbt_new +declare sbt_explicit_version +declare verbose noshare batch trace_level + +declare java_cmd="java" +declare sbt_launch_dir="$HOME/.sbt/launchers" +declare sbt_launch_repo + +# pull -J and -D options to give to java. +declare -a java_args scalac_args sbt_commands residual_args + +# args to jvm/sbt via files or environment variables +declare -a extra_jvm_opts extra_sbt_opts + +echoerr() { echo >&2 "$@"; } +vlog() { [[ -n "$verbose" ]] && echoerr "$@"; } +die() { + echo "Aborting: $*" + exit 1 +} + +setTrapExit() { + # save stty and trap exit, to ensure echo is re-enabled if we are interrupted. + SBT_STTY="$(stty -g 2>/dev/null)" + export SBT_STTY + + # restore stty settings (echo in particular) + onSbtRunnerExit() { + [ -t 0 ] || return + vlog "" + vlog "restoring stty: $SBT_STTY" + stty "$SBT_STTY" + } + + vlog "saving stty: $SBT_STTY" + trap onSbtRunnerExit EXIT +} + +# this seems to cover the bases on OSX, and someone will +# have to tell me about the others. +get_script_path() { + local path="$1" + [[ -L "$path" ]] || { + echo "$path" + return + } + + local -r target="$(readlink "$path")" + if [[ "${target:0:1}" == "/" ]]; then + echo "$target" + else + echo "${path%/*}/$target" + fi +} + +script_path="$(get_script_path "${BASH_SOURCE[0]}")" +declare -r script_path +script_name="${script_path##*/}" +declare -r script_name + +init_default_option_file() { + local overriding_var="${!1}" + local default_file="$2" + if [[ ! -r "$default_file" && "$overriding_var" =~ ^@(.*)$ ]]; then + local envvar_file="${BASH_REMATCH[1]}" + if [[ -r "$envvar_file" ]]; then + default_file="$envvar_file" + fi + fi + echo "$default_file" +} + +sbt_opts_file="$(init_default_option_file SBT_OPTS .sbtopts)" +sbtx_opts_file="$(init_default_option_file SBTX_OPTS .sbtxopts)" +jvm_opts_file="$(init_default_option_file JVM_OPTS .jvmopts)" + +build_props_sbt() { + [[ -r "$buildProps" ]] && + grep '^sbt\.version' "$buildProps" | tr '=\r' ' ' | awk '{ print $2; }' +} + +set_sbt_version() { + sbt_version="${sbt_explicit_version:-$(build_props_sbt)}" + [[ -n "$sbt_version" ]] || sbt_version=$sbt_release_version + export sbt_version +} + +url_base() { + local version="$1" + + case "$version" in + 0.7.*) echo "https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/simple-build-tool" ;; + 0.10.*) echo "$sbt_launch_ivy_release_repo" ;; + 0.11.[12]) echo "$sbt_launch_ivy_release_repo" ;; + 0.*-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9][0-9][0-9]) # ie "*-yyyymmdd-hhMMss" + echo "$sbt_launch_ivy_snapshot_repo" ;; + 0.*) echo "$sbt_launch_ivy_release_repo" ;; + *-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]T[0-9][0-9][0-9][0-9][0-9][0-9]) # ie "*-yyyymmddThhMMss" + echo "$sbt_launch_mvn_snapshot_repo" ;; + *) echo "$sbt_launch_mvn_release_repo" ;; + esac +} + +make_url() { + local version="$1" + + local base="${sbt_launch_repo:-$(url_base "$version")}" + + case "$version" in + 0.7.*) echo "$base/sbt-launch-0.7.7.jar" ;; + 0.10.*) echo "$base/org.scala-tools.sbt/sbt-launch/$version/sbt-launch.jar" ;; + 0.11.[12]) echo "$base/org.scala-tools.sbt/sbt-launch/$version/sbt-launch.jar" ;; + 0.*) echo "$base/org.scala-sbt/sbt-launch/$version/sbt-launch.jar" ;; + *) echo "$base/org/scala-sbt/sbt-launch/$version/sbt-launch-${version}.jar" ;; + esac +} + +addJava() { + vlog "[addJava] arg = '$1'" + java_args+=("$1") +} +addSbt() { + vlog "[addSbt] arg = '$1'" + sbt_commands+=("$1") +} +addScalac() { + vlog "[addScalac] arg = '$1'" + scalac_args+=("$1") +} +addResidual() { + vlog "[residual] arg = '$1'" + residual_args+=("$1") +} + +addResolver() { addSbt "set resolvers += $1"; } + +addDebugger() { addJava "-Xdebug" && addJava "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=$1"; } + +setThisBuild() { + vlog "[addBuild] args = '$*'" + local key="$1" && shift + addSbt "set $key in ThisBuild := $*" +} +setScalaVersion() { + [[ "$1" == *"-SNAPSHOT" ]] && addResolver 'Resolver.sonatypeRepo("snapshots")' + addSbt "++ $1" +} +setJavaHome() { + java_cmd="$1/bin/java" + setThisBuild javaHome "_root_.scala.Some(file(\"$1\"))" + export JAVA_HOME="$1" + export JDK_HOME="$1" + export PATH="$JAVA_HOME/bin:$PATH" +} + +getJavaVersion() { + local -r str=$("$1" -version 2>&1 | grep -E -e '(java|openjdk) version' | awk '{ print $3 }' | tr -d '"') + + # java -version on java8 says 1.8.x + # but on 9 and 10 it's 9.x.y and 10.x.y. + if [[ "$str" =~ ^1\.([0-9]+)(\..*)?$ ]]; then + echo "${BASH_REMATCH[1]}" + # Fixes https://github.com/dwijnand/sbt-extras/issues/326 + elif [[ "$str" =~ ^([0-9]+)(\..*)?(-ea)?$ ]]; then + echo "${BASH_REMATCH[1]}" + elif [[ -n "$str" ]]; then + echoerr "Can't parse java version from: $str" + fi +} + +checkJava() { + # Warn if there is a Java version mismatch between PATH and JAVA_HOME/JDK_HOME + + [[ -n "$JAVA_HOME" && -e "$JAVA_HOME/bin/java" ]] && java="$JAVA_HOME/bin/java" + [[ -n "$JDK_HOME" && -e "$JDK_HOME/lib/tools.jar" ]] && java="$JDK_HOME/bin/java" + + if [[ -n "$java" ]]; then + pathJavaVersion=$(getJavaVersion java) + homeJavaVersion=$(getJavaVersion "$java") + if [[ "$pathJavaVersion" != "$homeJavaVersion" ]]; then + echoerr "Warning: Java version mismatch between PATH and JAVA_HOME/JDK_HOME, sbt will use the one in PATH" + echoerr " Either: fix your PATH, remove JAVA_HOME/JDK_HOME or use -java-home" + echoerr " java version from PATH: $pathJavaVersion" + echoerr " java version from JAVA_HOME/JDK_HOME: $homeJavaVersion" + fi + fi +} + +java_version() { + local -r version=$(getJavaVersion "$java_cmd") + vlog "Detected Java version: $version" + echo "$version" +} + +is_apple_silicon() { [[ "$(uname -s)" == "Darwin" && "$(uname -m)" == "arm64" ]]; } + +# MaxPermSize critical on pre-8 JVMs but incurs noisy warning on 8+ +default_jvm_opts() { + local -r v="$(java_version)" + if [[ $v -ge 17 ]]; then + echo "$default_jvm_opts_common" + elif [[ $v -ge 10 ]]; then + if is_apple_silicon; then + # As of Dec 2020, JVM for Apple Silicon (M1) doesn't support JVMCI + echo "$default_jvm_opts_common" + else + echo "$default_jvm_opts_common -XX:+UnlockExperimentalVMOptions -XX:+UseJVMCICompiler" + fi + elif [[ $v -ge 8 ]]; then + echo "$default_jvm_opts_common" + else + echo "-XX:MaxPermSize=384m $default_jvm_opts_common" + fi +} + +execRunner() { + # print the arguments one to a line, quoting any containing spaces + vlog "# Executing command line:" && { + for arg; do + if [[ -n "$arg" ]]; then + if printf "%s\n" "$arg" | grep -q ' '; then + printf >&2 "\"%s\"\n" "$arg" + else + printf >&2 "%s\n" "$arg" + fi + fi + done + vlog "" + } + + setTrapExit + + if [[ -n "$batch" ]]; then + "$@" /dev/null 2>&1; then + curl --fail --silent --location "$url" --output "$jar" + elif command -v wget >/dev/null 2>&1; then + wget -q -O "$jar" "$url" + fi + } && [[ -r "$jar" ]] +} + +acquire_sbt_jar() { + { + sbt_jar="$(jar_file "$sbt_version")" + [[ -r "$sbt_jar" ]] + } || { + sbt_jar="$HOME/.ivy2/local/org.scala-sbt/sbt-launch/$sbt_version/jars/sbt-launch.jar" + [[ -r "$sbt_jar" ]] + } || { + sbt_jar="$(jar_file "$sbt_version")" + jar_url="$(make_url "$sbt_version")" + + echoerr "Downloading sbt launcher for ${sbt_version}:" + echoerr " From ${jar_url}" + echoerr " To ${sbt_jar}" + + download_url "${jar_url}" "${sbt_jar}" + + case "${sbt_version}" in + 0.*) + vlog "SBT versions < 1.0 do not have published MD5 checksums, skipping check" + echo "" + ;; + *) verify_sbt_jar "${sbt_jar}" ;; + esac + } +} + +verify_sbt_jar() { + local jar="${1}" + local md5="${jar}.md5" + md5url="$(make_url "${sbt_version}").md5" + + echoerr "Downloading sbt launcher ${sbt_version} md5 hash:" + echoerr " From ${md5url}" + echoerr " To ${md5}" + + download_url "${md5url}" "${md5}" >/dev/null 2>&1 + + if command -v md5sum >/dev/null 2>&1; then + if echo "$(cat "${md5}") ${jar}" | md5sum -c -; then + rm -rf "${md5}" + return 0 + else + echoerr "Checksum does not match" + return 1 + fi + elif command -v md5 >/dev/null 2>&1; then + if [ "$(md5 -q "${jar}")" == "$(cat "${md5}")" ]; then + rm -rf "${md5}" + return 0 + else + echoerr "Checksum does not match" + return 1 + fi + elif command -v openssl >/dev/null 2>&1; then + if [ "$(openssl md5 -r "${jar}" | awk '{print $1}')" == "$(cat "${md5}")" ]; then + rm -rf "${md5}" + return 0 + else + echoerr "Checksum does not match" + return 1 + fi + else + echoerr "Could not find an MD5 command" + return 1 + fi +} + +usage() { + set_sbt_version + cat < display stack traces with a max of frames (default: -1, traces suppressed) + -debug-inc enable debugging log for the incremental compiler + -no-colors disable ANSI color codes + -sbt-create start sbt even if current directory contains no sbt project + -sbt-dir path to global settings/plugins directory (default: ~/.sbt/) + -sbt-boot path to shared boot directory (default: ~/.sbt/boot in 0.11+) + -ivy path to local Ivy repository (default: ~/.ivy2) + -no-share use all local caches; no sharing + -offline put sbt in offline mode + -jvm-debug Turn on JVM debugging, open at the given port. + -batch Disable interactive mode + -prompt Set the sbt prompt; in expr, 's' is the State and 'e' is Extracted + -script Run the specified file as a scala script + + # sbt version (default: sbt.version from $buildProps if present, otherwise $sbt_release_version) + -sbt-version use the specified version of sbt (default: $sbt_release_version) + -sbt-force-latest force the use of the latest release of sbt: $sbt_release_version + -sbt-dev use the latest pre-release version of sbt: $sbt_unreleased_version + -sbt-jar use the specified jar as the sbt launcher + -sbt-launch-dir directory to hold sbt launchers (default: $sbt_launch_dir) + -sbt-launch-repo repo url for downloading sbt launcher jar (default: $(url_base "$sbt_version")) + + # scala version (default: as chosen by sbt) + -28 use $latest_28 + -29 use $latest_29 + -210 use $latest_210 + -211 use $latest_211 + -212 use $latest_212 + -213 use $latest_213 + -scala-home use the scala build at the specified directory + -scala-version use the specified version of scala + -binary-version use the specified scala version when searching for dependencies + + # java version (default: java from PATH, currently $(java -version 2>&1 | grep version)) + -java-home alternate JAVA_HOME + + # passing options to the jvm - note it does NOT use JAVA_OPTS due to pollution + # The default set is used if JVM_OPTS is unset and no -jvm-opts file is found + $(default_jvm_opts) + JVM_OPTS environment variable holding either the jvm args directly, or + the reference to a file containing jvm args if given path is prepended by '@' (e.g. '@/etc/jvmopts') + Note: "@"-file is overridden by local '.jvmopts' or '-jvm-opts' argument. + -jvm-opts file containing jvm args (if not given, .jvmopts in project root is used if present) + -Dkey=val pass -Dkey=val directly to the jvm + -J-X pass option -X directly to the jvm (-J is stripped) + + # passing options to sbt, OR to this runner + SBT_OPTS environment variable holding either the sbt args directly, or + the reference to a file containing sbt args if given path is prepended by '@' (e.g. '@/etc/sbtopts') + Note: "@"-file is overridden by local '.sbtopts' or '-sbt-opts' argument. + -sbt-opts file containing sbt args (if not given, .sbtopts in project root is used if present) + -S-X add -X to sbt's scalacOptions (-S is stripped) + + # passing options exclusively to this runner + SBTX_OPTS environment variable holding either the sbt-extras args directly, or + the reference to a file containing sbt-extras args if given path is prepended by '@' (e.g. '@/etc/sbtxopts') + Note: "@"-file is overridden by local '.sbtxopts' or '-sbtx-opts' argument. + -sbtx-opts file containing sbt-extras args (if not given, .sbtxopts in project root is used if present) +EOM + exit 0 +} + +process_args() { + require_arg() { + local type="$1" + local opt="$2" + local arg="$3" + + if [[ -z "$arg" ]] || [[ "${arg:0:1}" == "-" ]]; then + die "$opt requires <$type> argument" + fi + } + while [[ $# -gt 0 ]]; do + case "$1" in + -h | -help) usage ;; + -v) verbose=true && shift ;; + -d) addSbt "--debug" && shift ;; + -w) addSbt "--warn" && shift ;; + -q) addSbt "--error" && shift ;; + -x) shift ;; # currently unused + -trace) require_arg integer "$1" "$2" && trace_level="$2" && shift 2 ;; + -debug-inc) addJava "-Dxsbt.inc.debug=true" && shift ;; + + -no-colors) addJava "-Dsbt.log.noformat=true" && addJava "-Dsbt.color=false" && shift ;; + -sbt-create) sbt_create=true && shift ;; + -sbt-dir) require_arg path "$1" "$2" && sbt_dir="$2" && shift 2 ;; + -sbt-boot) require_arg path "$1" "$2" && addJava "-Dsbt.boot.directory=$2" && shift 2 ;; + -ivy) require_arg path "$1" "$2" && addJava "-Dsbt.ivy.home=$2" && shift 2 ;; + -no-share) noshare=true && shift ;; + -offline) addSbt "set offline in Global := true" && shift ;; + -jvm-debug) require_arg port "$1" "$2" && addDebugger "$2" && shift 2 ;; + -batch) batch=true && shift ;; + -prompt) require_arg "expr" "$1" "$2" && setThisBuild shellPrompt "(s => { val e = Project.extract(s) ; $2 })" && shift 2 ;; + -script) require_arg file "$1" "$2" && sbt_script="$2" && addJava "-Dsbt.main.class=sbt.ScriptMain" && shift 2 ;; + + -sbt-version) require_arg version "$1" "$2" && sbt_explicit_version="$2" && shift 2 ;; + -sbt-force-latest) sbt_explicit_version="$sbt_release_version" && shift ;; + -sbt-dev) sbt_explicit_version="$sbt_unreleased_version" && shift ;; + -sbt-jar) require_arg path "$1" "$2" && sbt_jar="$2" && shift 2 ;; + -sbt-launch-dir) require_arg path "$1" "$2" && sbt_launch_dir="$2" && shift 2 ;; + -sbt-launch-repo) require_arg path "$1" "$2" && sbt_launch_repo="$2" && shift 2 ;; + + -28) setScalaVersion "$latest_28" && shift ;; + -29) setScalaVersion "$latest_29" && shift ;; + -210) setScalaVersion "$latest_210" && shift ;; + -211) setScalaVersion "$latest_211" && shift ;; + -212) setScalaVersion "$latest_212" && shift ;; + -213) setScalaVersion "$latest_213" && shift ;; + + -scala-version) require_arg version "$1" "$2" && setScalaVersion "$2" && shift 2 ;; + -binary-version) require_arg version "$1" "$2" && setThisBuild scalaBinaryVersion "\"$2\"" && shift 2 ;; + -scala-home) require_arg path "$1" "$2" && setThisBuild scalaHome "_root_.scala.Some(file(\"$2\"))" && shift 2 ;; + -java-home) require_arg path "$1" "$2" && setJavaHome "$2" && shift 2 ;; + -sbt-opts) require_arg path "$1" "$2" && sbt_opts_file="$2" && shift 2 ;; + -sbtx-opts) require_arg path "$1" "$2" && sbtx_opts_file="$2" && shift 2 ;; + -jvm-opts) require_arg path "$1" "$2" && jvm_opts_file="$2" && shift 2 ;; + + -D*) addJava "$1" && shift ;; + -J*) addJava "${1:2}" && shift ;; + -S*) addScalac "${1:2}" && shift ;; + + new) sbt_new=true && : "${sbt_explicit_version:=$sbt_release_version}" && addResidual "$1" && shift ;; + + *) addResidual "$1" && shift ;; + esac + done +} + +# process the direct command line arguments +process_args "$@" + +# skip #-styled comments and blank lines +readConfigFile() { + local end=false + until $end; do + read -r || end=true + [[ $REPLY =~ ^# ]] || [[ -z $REPLY ]] || echo "$REPLY" + done <"$1" +} + +# if there are file/environment sbt_opts, process again so we +# can supply args to this runner +if [[ -r "$sbt_opts_file" ]]; then + vlog "Using sbt options defined in file $sbt_opts_file" + while read -r opt; do extra_sbt_opts+=("$opt"); done < <(readConfigFile "$sbt_opts_file") +elif [[ -n "$SBT_OPTS" && ! ("$SBT_OPTS" =~ ^@.*) ]]; then + vlog "Using sbt options defined in variable \$SBT_OPTS" + IFS=" " read -r -a extra_sbt_opts <<<"$SBT_OPTS" +else + vlog "No extra sbt options have been defined" +fi + +# if there are file/environment sbtx_opts, process again so we +# can supply args to this runner +if [[ -r "$sbtx_opts_file" ]]; then + vlog "Using sbt options defined in file $sbtx_opts_file" + while read -r opt; do extra_sbt_opts+=("$opt"); done < <(readConfigFile "$sbtx_opts_file") +elif [[ -n "$SBTX_OPTS" && ! ("$SBTX_OPTS" =~ ^@.*) ]]; then + vlog "Using sbt options defined in variable \$SBTX_OPTS" + IFS=" " read -r -a extra_sbt_opts <<<"$SBTX_OPTS" +else + vlog "No extra sbt options have been defined" +fi + +[[ -n "${extra_sbt_opts[*]}" ]] && process_args "${extra_sbt_opts[@]}" + +# reset "$@" to the residual args +set -- "${residual_args[@]}" +argumentCount=$# + +# set sbt version +set_sbt_version + +checkJava + +# only exists in 0.12+ +setTraceLevel() { + case "$sbt_version" in + "0.7."* | "0.10."* | "0.11."*) echoerr "Cannot set trace level in sbt version $sbt_version" ;; + *) setThisBuild traceLevel "$trace_level" ;; + esac +} + +# set scalacOptions if we were given any -S opts +[[ ${#scalac_args[@]} -eq 0 ]] || addSbt "set scalacOptions in ThisBuild += \"${scalac_args[*]}\"" + +[[ -n "$sbt_explicit_version" && -z "$sbt_new" ]] && addJava "-Dsbt.version=$sbt_explicit_version" +vlog "Detected sbt version $sbt_version" + +if [[ -n "$sbt_script" ]]; then + residual_args=("$sbt_script" "${residual_args[@]}") +else + # no args - alert them there's stuff in here + ((argumentCount > 0)) || { + vlog "Starting $script_name: invoke with -help for other options" + residual_args=(shell) + } +fi + +# verify this is an sbt dir, -create was given or user attempts to run a scala script +[[ -r ./build.sbt || -d ./project || -n "$sbt_create" || -n "$sbt_script" || -n "$sbt_new" ]] || { + cat < SvgTagDefs.defs, ) + val mathMLTagsDefGroups: List[(String, List[TagDef])] = List( + "MathML Tags" -> MathMlTagDefs.defs, + ) + val htmlAttrDefGroups: List[(String, List[AttrDef])] = List( "HTML Attrs" -> HtmlAttrDefs.defs ) @@ -33,6 +37,10 @@ class CanonicalDefGroups { "SVG Attrs" -> SvgAttrDefs.defs ) + val mathMLAttrDefGroups: List[(String, List[AttrDef])] = List( + "MathML Attrs" -> MathMLDefs.defs + ) + val ariaAttrDefGroups: List[(String, List[AttrDef])] = List( "Aria Attrs" -> AriaAttrDefs.defs ) diff --git a/shared/src/main/scala/com/raquo/domtypes/common/TagType.scala b/shared/src/main/scala/com/raquo/domtypes/common/TagType.scala index 60c2d9cd..75fc85f1 100644 --- a/shared/src/main/scala/com/raquo/domtypes/common/TagType.scala +++ b/shared/src/main/scala/com/raquo/domtypes/common/TagType.scala @@ -16,3 +16,7 @@ object HtmlTagType extends TagType { object SvgTagType extends TagType { override val sourceStr: String = "SvgTagType" } + +object MathMLTagType extends TagType { + override val sourceStr: String = "MathMLTagType" +} diff --git a/shared/src/main/scala/com/raquo/domtypes/defs/attrs/HtmlAttrDefs.scala b/shared/src/main/scala/com/raquo/domtypes/defs/attrs/HtmlAttrDefs.scala index d270158c..c7648eb8 100644 --- a/shared/src/main/scala/com/raquo/domtypes/defs/attrs/HtmlAttrDefs.scala +++ b/shared/src/main/scala/com/raquo/domtypes/defs/attrs/HtmlAttrDefs.scala @@ -288,6 +288,23 @@ object HtmlAttrDefs { ), ), + AttrDef( + tagType = HtmlTagType, + scalaName = "xmlns", + domName = "xmlns", + namespace = None, + scalaValueType = "String", + codec = "StringAsIs", + commentLines = List( + "The xmlns attribute specifies the XML namespace for the element.", + "This is especially important when mixing HTML with other XML vocabularies", + "like SVG or MathML.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/API/Element/namespaceURI", + ), + ), + ) } diff --git a/shared/src/main/scala/com/raquo/domtypes/defs/attrs/MathMLDefs.scala b/shared/src/main/scala/com/raquo/domtypes/defs/attrs/MathMLDefs.scala new file mode 100644 index 00000000..bcf1b2bf --- /dev/null +++ b/shared/src/main/scala/com/raquo/domtypes/defs/attrs/MathMLDefs.scala @@ -0,0 +1,374 @@ +package com.raquo.domtypes.defs.attrs + +import com.raquo.domtypes.common.{AttrDef, MathMLTagType} + +object MathMLDefs { + + val defs: List[AttrDef] = List( + + AttrDef( + tagType = MathMLTagType, + scalaName = "display", + domName = "display", + namespace = None, + scalaValueType = "String", + codec = "StringAsIs", + commentLines = List( + "This enumerated attribute specifies how the enclosed MathML markup should be rendered.", + "It can have one of the following values:", + "- block, which means that this element will be displayed in its own block outside the current span of text", + "- inline, which means that this element will be displayed inside the current span of text", + "", + "If not present, its default value is inline.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Global_attributes/display", + ), + ), + + AttrDef( + tagType = MathMLTagType, + scalaName = "mathvariant", + domName = "mathvariant", + namespace = None, + scalaValueType = "String", + codec = "StringAsIs", + commentLines = List( + "This attribute specifies the logical class of the identifier, which varies", + "in typography. That is, although the names suggest the typographic style for", + "the class, semantically, items with the same class are treated \"the same\"", + "within an expression, which might or might not involve displaying them with", + "the same typography.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Global_attributes/mathvariant", + ), + ), + + AttrDef( + tagType = MathMLTagType, + scalaName = "mathsize", + domName = "mathsize", + namespace = None, + scalaValueType = "String", + codec = "StringAsIs", + commentLines = List( + "This attribute specifies the size of the content. Possible values are:", + "- small: The content is rendered smaller than the surrounding text.", + "- normal: The content is rendered at the same size as the surrounding text.", + "- big: The content is rendered larger than the surrounding text.", + "- A length value like '12pt', '2em', etc.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Global_attributes/mathsize", + ), + ), + + AttrDef( + tagType = MathMLTagType, + scalaName = "mathcolor", + domName = "mathcolor", + namespace = None, + scalaValueType = "String", + codec = "StringAsIs", + commentLines = List( + "This attribute sets the text color and also the fraction line color.", + "You can use named colors or RGB format like #rgb, #rrggbb and CSS color names.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Global_attributes/mathcolor", + ), + ), + + AttrDef( + tagType = MathMLTagType, + scalaName = "mathbackground", + domName = "mathbackground", + namespace = None, + scalaValueType = "String", + codec = "StringAsIs", + commentLines = List( + "This attribute sets the background color. You can use named colors", + "or RGB format like #rgb, #rrggbb and CSS color names.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Global_attributes/mathbackground", + ), + ), + + AttrDef( + tagType = MathMLTagType, + scalaName = "displaystyle", + domName = "displaystyle", + namespace = None, + scalaValueType = "Boolean", + codec = "BooleanAsPresence", + commentLines = List( + "This Boolean attribute specifies whether more vertical space is used", + "for displayed equations or, if set to false, a more compact layout", + "is used to display formulas.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Global_attributes/displaystyle", + ), + ), + + AttrDef( + tagType = MathMLTagType, + scalaName = "scriptlevel", + domName = "scriptlevel", + namespace = None, + scalaValueType = "Int", + codec = "IntAsString", + commentLines = List( + "This attribute specifies a scriptlevel for the element. Larger values", + "mean smaller font sizes. The scriptlevel is used to control the font size", + "in a context-dependent way.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Global_attributes/scriptlevel", + ), + ), + + AttrDef( + tagType = MathMLTagType, + scalaName = "linethickness", + domName = "linethickness", + namespace = None, + scalaValueType = "String", + codec = "StringAsIs", + commentLines = List( + "This attribute specifies the thickness of the horizontal fraction line.", + "Possible values: a length value like '2px', 'thin', 'medium', 'thick', or 0 for no line.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mfrac#linethickness", + ), + ), + + AttrDef( + tagType = MathMLTagType, + scalaName = "numalign", + domName = "numalign", + namespace = None, + scalaValueType = "String", + codec = "StringAsIs", + commentLines = List( + "This attribute specifies the alignment of the numerator over the fraction line.", + "Possible values are: left, center (default), and right.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mfrac#numalign", + ), + ), + + AttrDef( + tagType = MathMLTagType, + scalaName = "denomalign", + domName = "denomalign", + namespace = None, + scalaValueType = "String", + codec = "StringAsIs", + commentLines = List( + "This attribute specifies the alignment of the denominator under the fraction line.", + "Possible values are: left, center (default), and right.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mfrac#denomalign", + ), + ), + + AttrDef( + tagType = MathMLTagType, + scalaName = "separator", + domName = "separator", + namespace = None, + scalaValueType = "Boolean", + codec = "BooleanAsPresence", + commentLines = List( + "This Boolean attribute specifies whether the operator is a separator", + "(such as commas). There is no visual effect for this attribute.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo#separator", + ), + ), + + AttrDef( + tagType = MathMLTagType, + scalaName = "fence", + domName = "fence", + namespace = None, + scalaValueType = "Boolean", + codec = "BooleanAsPresence", + commentLines = List( + "This Boolean attribute specifies whether the operator is a fence", + "(such as parentheses). There is no visual effect for this attribute.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo#fence", + ), + ), + + AttrDef( + tagType = MathMLTagType, + scalaName = "stretchy", + domName = "stretchy", + namespace = None, + scalaValueType = "Boolean", + codec = "BooleanAsPresence", + commentLines = List( + "This Boolean attribute specifies whether the operator stretches to the", + "size of the adjacent element.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo#stretchy", + ), + ), + + AttrDef( + tagType = MathMLTagType, + scalaName = "symmetric", + domName = "symmetric", + namespace = None, + scalaValueType = "Boolean", + codec = "BooleanAsPresence", + commentLines = List( + "This Boolean attribute specifies whether a stretchy operator should be", + "vertically symmetric around the imaginary math axis (centered fraction line).", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo#symmetric", + ), + ), + + AttrDef( + tagType = MathMLTagType, + scalaName = "largeop", + domName = "largeop", + namespace = None, + scalaValueType = "Boolean", + codec = "BooleanAsPresence", + commentLines = List( + "This Boolean attribute specifies whether the operator should be drawn larger", + "than normal when displaystyle is true.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo#largeop", + ), + ), + + AttrDef( + tagType = MathMLTagType, + scalaName = "movablelimits", + domName = "movablelimits", + namespace = None, + scalaValueType = "Boolean", + codec = "BooleanAsPresence", + commentLines = List( + "This Boolean attribute specifies whether attached under- and overscripts", + "move to sub- and superscript positions when displaystyle is false.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo#movablelimits", + ), + ), + + AttrDef( + tagType = MathMLTagType, + scalaName = "lspace", + domName = "lspace", + namespace = None, + scalaValueType = "String", + codec = "StringAsIs", + commentLines = List( + "This attribute specifies the amount of space before the operator.", + "Values can be length values or named space constants like 'thickmathspace'.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo#lspace", + ), + ), + + AttrDef( + tagType = MathMLTagType, + scalaName = "rspace", + domName = "rspace", + namespace = None, + scalaValueType = "String", + codec = "StringAsIs", + commentLines = List( + "This attribute specifies the amount of space after the operator.", + "Values can be length values or named space constants like 'thickmathspace'.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo#rspace", + ), + ), + + AttrDef( + tagType = MathMLTagType, + scalaName = "width", + domName = "width", + namespace = None, + scalaValueType = "String", + codec = "StringAsIs", + commentLines = List( + "This attribute specifies the desired width. See length for possible values.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mspace#width", + ), + ), + + AttrDef( + tagType = MathMLTagType, + scalaName = "height", + domName = "height", + namespace = None, + scalaValueType = "String", + codec = "StringAsIs", + commentLines = List( + "This attribute specifies the desired height above the baseline.", + "See length for possible values.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mspace#height", + ), + ), + + AttrDef( + tagType = MathMLTagType, + scalaName = "depth", + domName = "depth", + namespace = None, + scalaValueType = "String", + codec = "StringAsIs", + commentLines = List( + "This attribute specifies the desired depth below the baseline.", + "See length for possible values.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mspace#depth", + ), + ), + + AttrDef( + tagType = MathMLTagType, + scalaName = "xmlns", + domName = "xmlns", + namespace = None, + scalaValueType = "String", + codec = "StringAsIs", + commentLines = List( + "The xmlns attribute specifies the XML namespace for the MathML element.", + "For MathML, this should typically be 'http://www.w3.org/1998/Math/MathML'.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/math#xmlns", + ), + ), + + ) + +} \ No newline at end of file diff --git a/shared/src/main/scala/com/raquo/domtypes/defs/tags/MathMlTagDefs.scala b/shared/src/main/scala/com/raquo/domtypes/defs/tags/MathMlTagDefs.scala new file mode 100644 index 00000000..39f0c4e9 --- /dev/null +++ b/shared/src/main/scala/com/raquo/domtypes/defs/tags/MathMlTagDefs.scala @@ -0,0 +1,282 @@ +package com.raquo.domtypes.defs.tags + +import com.raquo.domtypes.common.{MathMLTagType, TagDef} + +object MathMlTagDefs { + + val defs: List[TagDef] = List( + + TagDef( + tagType = MathMLTagType, + scalaName = "math", + domName = "math", + isVoid = false, + scalaJsElementTypeAlias = "dom.html.Element", + javascriptElementType = "Element", + commentLines = List( + "The top-level element in MathML is math. Every valid MathML instance", + "must be wrapped in math tags. In addition you must not nest a second", + "math element in another, but you can have an arbitrary number of other", + "child elements in it.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/math", + ), + ), + + TagDef( + tagType = MathMLTagType, + scalaName = "mi", + domName = "mi", + isVoid = false, + scalaJsElementTypeAlias = "dom.html.Element", + javascriptElementType = "Element", + commentLines = List( + "The mi element indicates that the content should be rendered as an", + "identifier such as function names, variables or symbolic constants.", + "You can also have arbitrary text in it to mark up terms.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mi", + ), + ), + + TagDef( + tagType = MathMLTagType, + scalaName = "mn", + domName = "mn", + isVoid = false, + scalaJsElementTypeAlias = "dom.html.Element", + javascriptElementType = "Element", + commentLines = List( + "The mn element represents a numeric literal which is normally a", + "sequence of digits with a possible separator (a dot or a comma).", + "However, it is also allowed to have arbitrary text in it which is", + "actually a numeric quantity, for example \"eleven\".", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mn", + ), + ), + + TagDef( + tagType = MathMLTagType, + scalaName = "mo", + domName = "mo", + isVoid = false, + scalaJsElementTypeAlias = "dom.html.Element", + javascriptElementType = "Element", + commentLines = List( + "The mo element represents an operator in a broad sense. Besides", + "operators in strict mathematical meaning, this element also includes", + "\"operators\" like parentheses, separators like comma and semicolon,", + "or \"absolute value\" bars.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo", + ), + ), + + TagDef( + tagType = MathMLTagType, + scalaName = "mrow", + domName = "mrow", + isVoid = false, + scalaJsElementTypeAlias = "dom.html.Element", + javascriptElementType = "Element", + commentLines = List( + "The mrow element is used to group sub-expressions, which usually", + "contain one or more operators with their respective operands", + "(such as mi and mn). This element renders as a horizontal row", + "containing its arguments.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mrow", + ), + ), + + TagDef( + tagType = MathMLTagType, + scalaName = "mfrac", + domName = "mfrac", + isVoid = false, + scalaJsElementTypeAlias = "dom.html.Element", + javascriptElementType = "Element", + commentLines = List( + "The mfrac element is used to display fractions. It can also be", + "used to mark up fraction-like objects such as binomial coefficients", + "and Legendre symbols.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mfrac", + ), + ), + + TagDef( + tagType = MathMLTagType, + scalaName = "msup", + domName = "msup", + isVoid = false, + scalaJsElementTypeAlias = "dom.html.Element", + javascriptElementType = "Element", + commentLines = List( + "The msup element is used to attach a superscript to an expression.", + "It uses the syntax: msup base superscript", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/msup", + ), + ), + + TagDef( + tagType = MathMLTagType, + scalaName = "msub", + domName = "msub", + isVoid = false, + scalaJsElementTypeAlias = "dom.html.Element", + javascriptElementType = "Element", + commentLines = List( + "The msub element is used to attach a subscript to an expression.", + "It uses the syntax: msub base subscript", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/msub", + ), + ), + + TagDef( + tagType = MathMLTagType, + scalaName = "msubsup", + domName = "msubsup", + isVoid = false, + scalaJsElementTypeAlias = "dom.html.Element", + javascriptElementType = "Element", + commentLines = List( + "The msubsup element is used to attach both a subscript and a", + "superscript, together, to an expression.", + "It uses the syntax: msubsup base subscript superscript", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/msubsup", + ), + ), + + TagDef( + tagType = MathMLTagType, + scalaName = "msqrt", + domName = "msqrt", + isVoid = false, + scalaJsElementTypeAlias = "dom.html.Element", + javascriptElementType = "Element", + commentLines = List( + "The msqrt element is used to display square roots (no index is", + "displayed). The square root accepts only one argument, which leads", + "to the following syntax: msqrt base", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/msqrt", + ), + ), + + TagDef( + tagType = MathMLTagType, + scalaName = "mroot", + domName = "mroot", + isVoid = false, + scalaJsElementTypeAlias = "dom.html.Element", + javascriptElementType = "Element", + commentLines = List( + "The mroot element is used to display roots with an explicit index.", + "Two arguments are accepted, which leads to the syntax: mroot base index", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mroot", + ), + ), + + TagDef( + tagType = MathMLTagType, + scalaName = "mtext", + domName = "mtext", + isVoid = false, + scalaJsElementTypeAlias = "dom.html.Element", + javascriptElementType = "Element", + commentLines = List( + "The mtext element is used to render arbitrary text with no notational", + "meaning, such as comments or annotations. To display text with notational", + "meaning, use mi and mo instead.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mtext", + ), + ), + + TagDef( + tagType = MathMLTagType, + scalaName = "mspace", + domName = "mspace", + isVoid = true, + scalaJsElementTypeAlias = "dom.html.Element", + javascriptElementType = "Element", + commentLines = List( + "The mspace element is used to display a blank space, whose size is", + "set by its attributes.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mspace", + ), + ), + + TagDef( + tagType = MathMLTagType, + scalaName = "mtable", + domName = "mtable", + isVoid = false, + scalaJsElementTypeAlias = "dom.html.Element", + javascriptElementType = "Element", + commentLines = List( + "The mtable element allows you to create tables or matrices.", + "Inside a mtable only mtr and mtd elements may appear.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mtable", + ), + ), + + TagDef( + tagType = MathMLTagType, + scalaName = "mtr", + domName = "mtr", + isVoid = false, + scalaJsElementTypeAlias = "dom.html.Element", + javascriptElementType = "Element", + commentLines = List( + "The mtr element represents a row in a table or a matrix.", + "It may only appear in a mtable element. This element is similar", + "to the tr element of HTML.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mtr", + ), + ), + + TagDef( + tagType = MathMLTagType, + scalaName = "mtd", + domName = "mtd", + isVoid = false, + scalaJsElementTypeAlias = "dom.html.Element", + javascriptElementType = "Element", + commentLines = List( + "The mtd element represents a cell in a table or a matrix.", + "It may only appear in a mtr element. This element is similar", + "to the td element of HTML.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mtd", + ), + ), + + ) + +} \ No newline at end of file