@simonklee/opentui-tex-native-source 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +674 -0
- package/LICENSE-PROJECT +21 -0
- package/README.md +7 -0
- package/build.zig +112 -0
- package/build.zig.zon +12 -0
- package/native/lib.zig +280 -0
- package/native/nanosvg.c +4 -0
- package/native/vendor/.bootstrap-v5 +1 -0
- package/native/vendor/LICENSE-NANOSVG +18 -0
- package/native/vendor/microtex/.clang-format +26 -0
- package/native/vendor/microtex/.github/workflows/ubuntu.yml +92 -0
- package/native/vendor/microtex/.github/workflows/windows-gdi.yml +34 -0
- package/native/vendor/microtex/.github/workflows/windows-qt.yml +52 -0
- package/native/vendor/microtex/CMakeLists.txt +110 -0
- package/native/vendor/microtex/LICENSE +21 -0
- package/native/vendor/microtex/MicroTeXInstall.cmake +42 -0
- package/native/vendor/microtex/README.md +600 -0
- package/native/vendor/microtex/build.zig +209 -0
- package/native/vendor/microtex/clatexmath.wrap +6 -0
- package/native/vendor/microtex/doc/meson.build +38 -0
- package/native/vendor/microtex/doc/microtex-doc.toml.in +47 -0
- package/native/vendor/microtex/doc/microtex.svg +39 -0
- package/native/vendor/microtex/doc/urlmap.js +6 -0
- package/native/vendor/microtex/example/gtk/CMakeLists.txt +68 -0
- package/native/vendor/microtex/example/gtk/gtk_main.c +170 -0
- package/native/vendor/microtex/example/gtk/isamples.cpp +21 -0
- package/native/vendor/microtex/example/gtk/isamples.h +15 -0
- package/native/vendor/microtex/example/gtk/meson.build +27 -0
- package/native/vendor/microtex/example/gtk/microtex-gtk.gresource.xml +6 -0
- package/native/vendor/microtex/example/gtk/microtex-gtk.ui +117 -0
- package/native/vendor/microtex/example/gtkmm/CMakeLists.txt +19 -0
- package/native/vendor/microtex/example/gtkmm/gtkmm_main.cpp +531 -0
- package/native/vendor/microtex/example/gtkmm/meson.build +19 -0
- package/native/vendor/microtex/example/memcheck/CMakeLists.txt +12 -0
- package/native/vendor/microtex/example/memcheck/mem_check_main.cpp +154 -0
- package/native/vendor/microtex/example/qt/CMakeLists.txt +37 -0
- package/native/vendor/microtex/example/qt/meson.build +25 -0
- package/native/vendor/microtex/example/qt/qt_main.cpp +70 -0
- package/native/vendor/microtex/example/qt/qt_mainwindow.cpp +107 -0
- package/native/vendor/microtex/example/qt/qt_mainwindow.h +40 -0
- package/native/vendor/microtex/example/qt/qt_skiatexwidget.cpp +149 -0
- package/native/vendor/microtex/example/qt/qt_skiatexwidget.h +48 -0
- package/native/vendor/microtex/example/qt/qt_tex_render.h +15 -0
- package/native/vendor/microtex/example/qt/qt_texqmlitem.cpp +56 -0
- package/native/vendor/microtex/example/qt/qt_texqmlitem.h +31 -0
- package/native/vendor/microtex/example/qt/qt_texwidget.cpp +62 -0
- package/native/vendor/microtex/example/qt/qt_texwidget.h +31 -0
- package/native/vendor/microtex/example/qtpng/CMakeLists.txt +11 -0
- package/native/vendor/microtex/example/qtpng/latex2png.cpp +115 -0
- package/native/vendor/microtex/example/samples/samples.cpp +52 -0
- package/native/vendor/microtex/example/samples/samples.h +32 -0
- package/native/vendor/microtex/example/win32/CMakeLists.txt +15 -0
- package/native/vendor/microtex/example/win32/meson.build +18 -0
- package/native/vendor/microtex/example/win32/win32_main.cpp +375 -0
- package/native/vendor/microtex/githooks/pre-commit +19 -0
- package/native/vendor/microtex/githooks/pre-push +103 -0
- package/native/vendor/microtex/lib/CMakeLists.txt +234 -0
- package/native/vendor/microtex/lib/atom/atom.cpp +14 -0
- package/native/vendor/microtex/lib/atom/atom.h +96 -0
- package/native/vendor/microtex/lib/atom/atom_accent.cpp +115 -0
- package/native/vendor/microtex/lib/atom/atom_accent.h +53 -0
- package/native/vendor/microtex/lib/atom/atom_basic.cpp +146 -0
- package/native/vendor/microtex/lib/atom/atom_basic.h +273 -0
- package/native/vendor/microtex/lib/atom/atom_box.cpp +41 -0
- package/native/vendor/microtex/lib/atom/atom_box.h +70 -0
- package/native/vendor/microtex/lib/atom/atom_char.cpp +99 -0
- package/native/vendor/microtex/lib/atom/atom_char.h +147 -0
- package/native/vendor/microtex/lib/atom/atom_delim.cpp +65 -0
- package/native/vendor/microtex/lib/atom/atom_delim.h +58 -0
- package/native/vendor/microtex/lib/atom/atom_fence.cpp +65 -0
- package/native/vendor/microtex/lib/atom/atom_fence.h +56 -0
- package/native/vendor/microtex/lib/atom/atom_font.cpp +20 -0
- package/native/vendor/microtex/lib/atom/atom_font.h +49 -0
- package/native/vendor/microtex/lib/atom/atom_frac.cpp +101 -0
- package/native/vendor/microtex/lib/atom/atom_frac.h +42 -0
- package/native/vendor/microtex/lib/atom/atom_matrix.cpp +756 -0
- package/native/vendor/microtex/lib/atom/atom_matrix.h +268 -0
- package/native/vendor/microtex/lib/atom/atom_misc.cpp +230 -0
- package/native/vendor/microtex/lib/atom/atom_misc.h +200 -0
- package/native/vendor/microtex/lib/atom/atom_operator.cpp +51 -0
- package/native/vendor/microtex/lib/atom/atom_operator.h +41 -0
- package/native/vendor/microtex/lib/atom/atom_root.cpp +61 -0
- package/native/vendor/microtex/lib/atom/atom_root.h +27 -0
- package/native/vendor/microtex/lib/atom/atom_row.cpp +334 -0
- package/native/vendor/microtex/lib/atom/atom_row.h +176 -0
- package/native/vendor/microtex/lib/atom/atom_scripts.cpp +182 -0
- package/native/vendor/microtex/lib/atom/atom_scripts.h +52 -0
- package/native/vendor/microtex/lib/atom/atom_sideset.cpp +92 -0
- package/native/vendor/microtex/lib/atom/atom_sideset.h +24 -0
- package/native/vendor/microtex/lib/atom/atom_space.cpp +22 -0
- package/native/vendor/microtex/lib/atom/atom_space.h +38 -0
- package/native/vendor/microtex/lib/atom/atom_stack.cpp +117 -0
- package/native/vendor/microtex/lib/atom/atom_stack.h +103 -0
- package/native/vendor/microtex/lib/atom/atom_text.cpp +17 -0
- package/native/vendor/microtex/lib/atom/atom_text.h +33 -0
- package/native/vendor/microtex/lib/atom/atom_vrow.cpp +96 -0
- package/native/vendor/microtex/lib/atom/atom_vrow.h +47 -0
- package/native/vendor/microtex/lib/atom/atom_zstack.cpp +66 -0
- package/native/vendor/microtex/lib/atom/atom_zstack.h +37 -0
- package/native/vendor/microtex/lib/atom/colors_def.cpp +157 -0
- package/native/vendor/microtex/lib/atom/meson.build +50 -0
- package/native/vendor/microtex/lib/box/box.cpp +49 -0
- package/native/vendor/microtex/lib/box/box.h +184 -0
- package/native/vendor/microtex/lib/box/box_factory.cpp +162 -0
- package/native/vendor/microtex/lib/box/box_factory.h +24 -0
- package/native/vendor/microtex/lib/box/box_group.cpp +503 -0
- package/native/vendor/microtex/lib/box/box_group.h +285 -0
- package/native/vendor/microtex/lib/box/box_single.cpp +179 -0
- package/native/vendor/microtex/lib/box/box_single.h +157 -0
- package/native/vendor/microtex/lib/box/meson.build +15 -0
- package/native/vendor/microtex/lib/core/debug_config.cpp +3 -0
- package/native/vendor/microtex/lib/core/debug_config.h +24 -0
- package/native/vendor/microtex/lib/core/formula.cpp +180 -0
- package/native/vendor/microtex/lib/core/formula.h +137 -0
- package/native/vendor/microtex/lib/core/formula_def.cpp +167 -0
- package/native/vendor/microtex/lib/core/glue.cpp +108 -0
- package/native/vendor/microtex/lib/core/glue.h +55 -0
- package/native/vendor/microtex/lib/core/localized_num.cpp +51 -0
- package/native/vendor/microtex/lib/core/meson.build +19 -0
- package/native/vendor/microtex/lib/core/parser.cpp +874 -0
- package/native/vendor/microtex/lib/core/parser.h +306 -0
- package/native/vendor/microtex/lib/core/split.cpp +185 -0
- package/native/vendor/microtex/lib/core/split.h +40 -0
- package/native/vendor/microtex/lib/env/env.cpp +141 -0
- package/native/vendor/microtex/lib/env/env.h +221 -0
- package/native/vendor/microtex/lib/env/meson.build +11 -0
- package/native/vendor/microtex/lib/env/units.cpp +109 -0
- package/native/vendor/microtex/lib/env/units.h +61 -0
- package/native/vendor/microtex/lib/graphic/font_style.cpp +63 -0
- package/native/vendor/microtex/lib/graphic/font_style.h +61 -0
- package/native/vendor/microtex/lib/graphic/graphic.cpp +38 -0
- package/native/vendor/microtex/lib/graphic/graphic.h +314 -0
- package/native/vendor/microtex/lib/graphic/graphic_basic.cpp +44 -0
- package/native/vendor/microtex/lib/graphic/graphic_basic.h +131 -0
- package/native/vendor/microtex/lib/graphic/meson.build +13 -0
- package/native/vendor/microtex/lib/macro/macro.cpp +143 -0
- package/native/vendor/microtex/lib/macro/macro.h +155 -0
- package/native/vendor/microtex/lib/macro/macro_accent.cpp +50 -0
- package/native/vendor/microtex/lib/macro/macro_accent.h +61 -0
- package/native/vendor/microtex/lib/macro/macro_boxes.h +68 -0
- package/native/vendor/microtex/lib/macro/macro_colors.cpp +42 -0
- package/native/vendor/microtex/lib/macro/macro_colors.h +42 -0
- package/native/vendor/microtex/lib/macro/macro_decl.h +16 -0
- package/native/vendor/microtex/lib/macro/macro_def.cpp +418 -0
- package/native/vendor/microtex/lib/macro/macro_delims.cpp +56 -0
- package/native/vendor/microtex/lib/macro/macro_delims.h +73 -0
- package/native/vendor/microtex/lib/macro/macro_env.h +212 -0
- package/native/vendor/microtex/lib/macro/macro_fonts.cpp +53 -0
- package/native/vendor/microtex/lib/macro/macro_fonts.h +78 -0
- package/native/vendor/microtex/lib/macro/macro_frac.cpp +138 -0
- package/native/vendor/microtex/lib/macro/macro_frac.h +50 -0
- package/native/vendor/microtex/lib/macro/macro_misc.cpp +211 -0
- package/native/vendor/microtex/lib/macro/macro_misc.h +217 -0
- package/native/vendor/microtex/lib/macro/macro_scripts.cpp +32 -0
- package/native/vendor/microtex/lib/macro/macro_scripts.h +17 -0
- package/native/vendor/microtex/lib/macro/macro_sizes.h +110 -0
- package/native/vendor/microtex/lib/macro/macro_space.cpp +31 -0
- package/native/vendor/microtex/lib/macro/macro_space.h +17 -0
- package/native/vendor/microtex/lib/macro/macro_styles.cpp +45 -0
- package/native/vendor/microtex/lib/macro/macro_styles.h +22 -0
- package/native/vendor/microtex/lib/macro/macro_types.h +48 -0
- package/native/vendor/microtex/lib/macro/meson.build +33 -0
- package/native/vendor/microtex/lib/meson.build +102 -0
- package/native/vendor/microtex/lib/microtex.cpp +208 -0
- package/native/vendor/microtex/lib/microtex.h +225 -0
- package/native/vendor/microtex/lib/microtexConfig.cmake.in +2 -0
- package/native/vendor/microtex/lib/microtexapi.h +22 -0
- package/native/vendor/microtex/lib/microtexconfig.h.in +7 -0
- package/native/vendor/microtex/lib/microtexexport.h +31 -0
- package/native/vendor/microtex/lib/otf/clm.cpp +405 -0
- package/native/vendor/microtex/lib/otf/clm.h +61 -0
- package/native/vendor/microtex/lib/otf/fontsense.cpp +191 -0
- package/native/vendor/microtex/lib/otf/fontsense.h +20 -0
- package/native/vendor/microtex/lib/otf/glyph.cpp +53 -0
- package/native/vendor/microtex/lib/otf/glyph.h +384 -0
- package/native/vendor/microtex/lib/otf/math_consts.h +154 -0
- package/native/vendor/microtex/lib/otf/meson.build +18 -0
- package/native/vendor/microtex/lib/otf/otf.cpp +84 -0
- package/native/vendor/microtex/lib/otf/otf.h +177 -0
- package/native/vendor/microtex/lib/otf/otfconfig.h +32 -0
- package/native/vendor/microtex/lib/otf/path.cpp +187 -0
- package/native/vendor/microtex/lib/otf/path.h +120 -0
- package/native/vendor/microtex/lib/render/builder.cpp +68 -0
- package/native/vendor/microtex/lib/render/builder.h +73 -0
- package/native/vendor/microtex/lib/render/meson.build +11 -0
- package/native/vendor/microtex/lib/render/render.cpp +136 -0
- package/native/vendor/microtex/lib/render/render.h +59 -0
- package/native/vendor/microtex/lib/unimath/font_meta.h +22 -0
- package/native/vendor/microtex/lib/unimath/font_src.cpp +21 -0
- package/native/vendor/microtex/lib/unimath/font_src.h +61 -0
- package/native/vendor/microtex/lib/unimath/math_type.cpp +318 -0
- package/native/vendor/microtex/lib/unimath/math_type.h +105 -0
- package/native/vendor/microtex/lib/unimath/meson.build +18 -0
- package/native/vendor/microtex/lib/unimath/uni_char.cpp +121 -0
- package/native/vendor/microtex/lib/unimath/uni_char.h +109 -0
- package/native/vendor/microtex/lib/unimath/uni_font.cpp +248 -0
- package/native/vendor/microtex/lib/unimath/uni_font.h +139 -0
- package/native/vendor/microtex/lib/unimath/uni_symbol.cpp +2929 -0
- package/native/vendor/microtex/lib/unimath/uni_symbol.h +31 -0
- package/native/vendor/microtex/lib/utils/dict_tree.h +68 -0
- package/native/vendor/microtex/lib/utils/exceptions.h +61 -0
- package/native/vendor/microtex/lib/utils/log.h +34 -0
- package/native/vendor/microtex/lib/utils/meson.build +18 -0
- package/native/vendor/microtex/lib/utils/nums.h +24 -0
- package/native/vendor/microtex/lib/utils/string_utils.cpp +85 -0
- package/native/vendor/microtex/lib/utils/string_utils.h +130 -0
- package/native/vendor/microtex/lib/utils/types.h +152 -0
- package/native/vendor/microtex/lib/utils/utf.cpp +115 -0
- package/native/vendor/microtex/lib/utils/utf.h +58 -0
- package/native/vendor/microtex/lib/utils/utils.cpp +40 -0
- package/native/vendor/microtex/lib/utils/utils.h +88 -0
- package/native/vendor/microtex/lib/wrapper/byte_seq.cpp +46 -0
- package/native/vendor/microtex/lib/wrapper/byte_seq.h +70 -0
- package/native/vendor/microtex/lib/wrapper/callback.cpp +10 -0
- package/native/vendor/microtex/lib/wrapper/callback.h +72 -0
- package/native/vendor/microtex/lib/wrapper/cwrapper.cpp +206 -0
- package/native/vendor/microtex/lib/wrapper/cwrapper.h +305 -0
- package/native/vendor/microtex/lib/wrapper/graphic_wrapper.cpp +211 -0
- package/native/vendor/microtex/lib/wrapper/graphic_wrapper.h +159 -0
- package/native/vendor/microtex/lib/wrapper/meson.build +22 -0
- package/native/vendor/microtex/meson.build +75 -0
- package/native/vendor/microtex/meson_options.txt +29 -0
- package/native/vendor/microtex/platform/cairo/CMakeLists.txt +36 -0
- package/native/vendor/microtex/platform/cairo/graphic_cairo.cpp +384 -0
- package/native/vendor/microtex/platform/cairo/graphic_cairo.h +119 -0
- package/native/vendor/microtex/platform/cairo/meson.build +47 -0
- package/native/vendor/microtex/platform/cairo/microtex-cairoConfig.cmake.in +11 -0
- package/native/vendor/microtex/platform/flutter/microtex/.metadata +10 -0
- package/native/vendor/microtex/platform/flutter/microtex/CHANGELOG.md +3 -0
- package/native/vendor/microtex/platform/flutter/microtex/LICENSE +1 -0
- package/native/vendor/microtex/platform/flutter/microtex/README.md +15 -0
- package/native/vendor/microtex/platform/flutter/microtex/analysis_options.yaml +4 -0
- package/native/vendor/microtex/platform/flutter/microtex/android/build.gradle +56 -0
- package/native/vendor/microtex/platform/flutter/microtex/android/settings.gradle +1 -0
- package/native/vendor/microtex/platform/flutter/microtex/android/src/main/AndroidManifest.xml +3 -0
- package/native/vendor/microtex/platform/flutter/microtex/android/src/main/kotlin/io/nano/microtex/microtex/MicrotexPlugin.kt +35 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/.metadata +10 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/README.md +16 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/analysis_options.yaml +31 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/android/app/build.gradle +68 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/android/app/src/debug/AndroidManifest.xml +7 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/android/app/src/main/AndroidManifest.xml +34 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/android/app/src/main/kotlin/io/nano/microtex/microtex_example/MainActivity.kt +6 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/android/app/src/main/res/drawable/launch_background.xml +12 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/android/app/src/main/res/drawable-v21/launch_background.xml +12 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/android/app/src/main/res/values/styles.xml +18 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/android/app/src/main/res/values-night/styles.xml +18 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/android/app/src/profile/AndroidManifest.xml +7 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/android/build.gradle +31 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/android/gradle/wrapper/gradle-wrapper.properties +6 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/android/gradle.properties +3 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/android/settings.gradle +11 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Flutter/AppFrameworkInfo.plist +26 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Flutter/Debug.xcconfig +2 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Flutter/Release.xcconfig +2 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Podfile +41 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Podfile.lock +22 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/AppDelegate.swift +13 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json +122 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json +23 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md +5 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Base.lproj/LaunchScreen.storyboard +37 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Base.lproj/Main.storyboard +26 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Info.plist +49 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Runner-Bridging-Header.h +1 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner.xcodeproj/project.pbxproj +549 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +8 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +87 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner.xcworkspace/contents.xcworkspacedata +10 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +8 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/lib/main.dart +23 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/lib/screen/edit_in_one.dart +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/lib/screen/edit_screen.dart +208 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/lib/utils/convert_spans.dart +63 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/lib/utils/string_ext.dart +10 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/lib/widget/cmp.dart +118 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/lib/widget/draggable.dart +75 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/lib/widget/rich.dart +23 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/lib/widget/split.dart +72 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/lib/widget/tex_highlight_controller.dart +66 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/lib/widget/tex_input_controller.dart +19 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/linux/CMakeLists.txt +116 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/linux/flutter/CMakeLists.txt +87 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/linux/flutter/generated_plugin_registrant.cc +15 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/linux/flutter/generated_plugin_registrant.h +15 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/linux/flutter/generated_plugins.cmake +24 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/linux/main.cc +6 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/linux/my_application.cc +104 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/linux/my_application.h +18 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Flutter/Flutter-Debug.xcconfig +2 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Flutter/Flutter-Release.xcconfig +2 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Flutter/GeneratedPluginRegistrant.swift +12 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Podfile +40 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Podfile.lock +22 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner/AppDelegate.swift +9 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json +68 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner/Base.lproj/MainMenu.xib +343 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner/Configs/AppInfo.xcconfig +14 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner/Configs/Debug.xcconfig +2 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner/Configs/Release.xcconfig +2 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner/Configs/Warnings.xcconfig +13 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner/DebugProfile.entitlements +12 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner/Info.plist +32 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner/MainFlutterWindow.swift +15 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner/Release.entitlements +8 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner.xcodeproj/project.pbxproj +633 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +87 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner.xcworkspace/contents.xcworkspacedata +10 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/pubspec.lock +191 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/pubspec.yaml +56 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/test/widget_test.dart +26 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/windows/CMakeLists.txt +95 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/windows/flutter/CMakeLists.txt +103 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/windows/flutter/generated_plugin_registrant.cc +14 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/windows/flutter/generated_plugin_registrant.h +15 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/windows/flutter/generated_plugins.cmake +24 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/windows/runner/CMakeLists.txt +17 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/windows/runner/Runner.rc +121 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/windows/runner/flutter_window.cpp +61 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/windows/runner/flutter_window.h +33 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/windows/runner/main.cpp +43 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/windows/runner/resource.h +16 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/windows/runner/resources/app_icon.ico +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/windows/runner/runner.exe.manifest +20 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/windows/runner/utils.cpp +64 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/windows/runner/utils.h +19 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/windows/runner/win32_window.cpp +245 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/windows/runner/win32_window.h +98 -0
- package/native/vendor/microtex/platform/flutter/microtex/ios/Assets/.gitkeep +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/ios/Classes/MicrotexPlugin.h +4 -0
- package/native/vendor/microtex/platform/flutter/microtex/ios/Classes/MicrotexPlugin.m +19 -0
- package/native/vendor/microtex/platform/flutter/microtex/ios/Classes/SwiftMicrotexPlugin.swift +14 -0
- package/native/vendor/microtex/platform/flutter/microtex/ios/Classes/dummy.h +4 -0
- package/native/vendor/microtex/platform/flutter/microtex/ios/microtex.podspec +27 -0
- package/native/vendor/microtex/platform/flutter/microtex/lib/microtex.dart +7 -0
- package/native/vendor/microtex/platform/flutter/microtex/lib/src/bindings.dart +218 -0
- package/native/vendor/microtex/platform/flutter/microtex/lib/src/bounds.dart +10 -0
- package/native/vendor/microtex/platform/flutter/microtex/lib/src/context.dart +205 -0
- package/native/vendor/microtex/platform/flutter/microtex/lib/src/fontdesc.dart +14 -0
- package/native/vendor/microtex/platform/flutter/microtex/lib/src/fontmeta.dart +14 -0
- package/native/vendor/microtex/platform/flutter/microtex/lib/src/pathcache.dart +17 -0
- package/native/vendor/microtex/platform/flutter/microtex/lib/src/render.dart +291 -0
- package/native/vendor/microtex/platform/flutter/microtex/lib/src/texstyle.dart +11 -0
- package/native/vendor/microtex/platform/flutter/microtex/lib/src/textlayout.dart +93 -0
- package/native/vendor/microtex/platform/flutter/microtex/lib/src/widget.dart +163 -0
- package/native/vendor/microtex/platform/flutter/microtex/linux/CMakeLists.txt +33 -0
- package/native/vendor/microtex/platform/flutter/microtex/linux/include/microtex/microtex_plugin.h +26 -0
- package/native/vendor/microtex/platform/flutter/microtex/linux/microtex_plugin.cc +70 -0
- package/native/vendor/microtex/platform/flutter/microtex/macos/Classes/MicrotexPlugin.swift +20 -0
- package/native/vendor/microtex/platform/flutter/microtex/macos/Classes/dummy.h +4 -0
- package/native/vendor/microtex/platform/flutter/microtex/macos/Classes/microtex-Bridging-Header.h +1 -0
- package/native/vendor/microtex/platform/flutter/microtex/macos/microtex.podspec +26 -0
- package/native/vendor/microtex/platform/flutter/microtex/nativelib/CMakeLists.txt +44 -0
- package/native/vendor/microtex/platform/flutter/microtex/nativelib/builddarwin.sh +108 -0
- package/native/vendor/microtex/platform/flutter/microtex/pubspec.yaml +37 -0
- package/native/vendor/microtex/platform/flutter/microtex/test/microtex_test.dart +23 -0
- package/native/vendor/microtex/platform/flutter/microtex/windows/CMakeLists.txt +32 -0
- package/native/vendor/microtex/platform/flutter/microtex/windows/include/microtex/microtex_plugin.h +23 -0
- package/native/vendor/microtex/platform/flutter/microtex/windows/microtex_plugin.cpp +82 -0
- package/native/vendor/microtex/platform/gdi_win/CMakeLists.txt +20 -0
- package/native/vendor/microtex/platform/gdi_win/graphic_win32.cpp +352 -0
- package/native/vendor/microtex/platform/gdi_win/graphic_win32.h +137 -0
- package/native/vendor/microtex/platform/gdi_win/meson.build +39 -0
- package/native/vendor/microtex/platform/gtk/CMakeLists.txt +36 -0
- package/native/vendor/microtex/platform/gtk/meson.build +65 -0
- package/native/vendor/microtex/platform/gtk/microtex-gtkConfig.cmake.in +11 -0
- package/native/vendor/microtex/platform/gtk/microtexequation.cpp +708 -0
- package/native/vendor/microtex/platform/gtk/microtexequation.h +72 -0
- package/native/vendor/microtex/platform/qt/CMakeLists.txt +37 -0
- package/native/vendor/microtex/platform/qt/graphic_qt.cpp +355 -0
- package/native/vendor/microtex/platform/qt/graphic_qt.h +116 -0
- package/native/vendor/microtex/platform/qt/meson.build +38 -0
- package/native/vendor/microtex/platform/qt/microtex-qtConfig.cmake.in +7 -0
- package/native/vendor/microtex/platform/skia/CMakeLists.txt +46 -0
- package/native/vendor/microtex/platform/skia/graphic_skia.cpp +306 -0
- package/native/vendor/microtex/platform/skia/graphic_skia.h +125 -0
- package/native/vendor/microtex/platform/skia/microtex-skiaConfig.cmake.in +6 -0
- package/native/vendor/microtex/platform/wasm/CMakeLists.txt +38 -0
- package/native/vendor/microtex/platform/wasm/emscripten.cross +31 -0
- package/native/vendor/microtex/platform/wasm/main.cpp +15 -0
- package/native/vendor/microtex/platform/wasm/meson.build +8 -0
- package/native/vendor/microtex/platform/wasm/prebuild-example-meson.sh +21 -0
- package/native/vendor/microtex/platform/wasm/prebuild-example.sh +21 -0
- package/native/vendor/microtex/platform/wasm/prebuild-lib-meson.sh +28 -0
- package/native/vendor/microtex/platform/wasm/prebuild-lib.sh +31 -0
- package/native/vendor/microtex/platform/wasm/web/.babelrc +10 -0
- package/native/vendor/microtex/platform/wasm/web/example/examples.js +43 -0
- package/native/vendor/microtex/platform/wasm/web/example/hello.js +31 -0
- package/native/vendor/microtex/platform/wasm/web/example/index.html +55 -0
- package/native/vendor/microtex/platform/wasm/web/example/index.js +243 -0
- package/native/vendor/microtex/platform/wasm/web/example/styles.css +86 -0
- package/native/vendor/microtex/platform/wasm/web/example/utils.js +47 -0
- package/native/vendor/microtex/platform/wasm/web/lib/context.js +271 -0
- package/native/vendor/microtex/platform/wasm/web/lib/index.js +10 -0
- package/native/vendor/microtex/platform/wasm/web/lib/render.js +293 -0
- package/native/vendor/microtex/platform/wasm/web/lib/runtime.js +14 -0
- package/native/vendor/microtex/platform/wasm/web/lib/svg.js +237 -0
- package/native/vendor/microtex/platform/wasm/web/lib/textlayout.js +88 -0
- package/native/vendor/microtex/platform/wasm/web/package-lock.json +5931 -0
- package/native/vendor/microtex/platform/wasm/web/package.json +45 -0
- package/native/vendor/microtex/platform/wasm/web/publish-example.sh +17 -0
- package/native/vendor/microtex/platform/wasm/web/rollup.config.example.js +24 -0
- package/native/vendor/microtex/platform/wasm/web/rollup.config.lib.js +16 -0
- package/native/vendor/microtex/prebuilt/otf2clm.py +807 -0
- package/native/vendor/microtex/prebuilt/otf2clm.sh +9 -0
- package/native/vendor/microtex/prebuilt/preclms.sh +17 -0
- package/native/vendor/microtex/readme/example_bw_false.svg +680 -0
- package/native/vendor/microtex/readme/example_bw_true.svg +680 -0
- package/native/vendor/microtex/readme/example_cjk_trying.svg +54 -0
- package/native/vendor/microtex/readme/example_custom_symbols.svg +92 -0
- package/native/vendor/microtex/readme/example_debug.svg +764 -0
- package/native/vendor/microtex/readme/example_emoji.svg +199 -0
- package/native/vendor/microtex/readme/example_have_log.svg +79 -0
- package/native/vendor/microtex/readme/example_keep_trying.svg +101 -0
- package/native/vendor/microtex/readme/example_logos.svg +50 -0
- package/native/vendor/microtex/readme/example_ubuntu.png +0 -0
- package/native/vendor/microtex/readme/example_windows.png +0 -0
- package/native/vendor/microtex/readme/samples/sample_0.svg +665 -0
- package/native/vendor/microtex/readme/samples/sample_1.svg +1259 -0
- package/native/vendor/microtex/readme/samples/sample_10.svg +333 -0
- package/native/vendor/microtex/readme/samples/sample_11.svg +306 -0
- package/native/vendor/microtex/readme/samples/sample_2.svg +2461 -0
- package/native/vendor/microtex/readme/samples/sample_3.svg +2653 -0
- package/native/vendor/microtex/readme/samples/sample_4.svg +554 -0
- package/native/vendor/microtex/readme/samples/sample_5.svg +247 -0
- package/native/vendor/microtex/readme/samples/sample_6.svg +1082 -0
- package/native/vendor/microtex/readme/samples/sample_7.svg +518 -0
- package/native/vendor/microtex/readme/samples/sample_8.svg +529 -0
- package/native/vendor/microtex/readme/samples/sample_9.svg +1702 -0
- package/native/vendor/microtex/readme/samples.md +301 -0
- package/native/vendor/microtex/readme/tex_logo.svg +19 -0
- package/native/vendor/microtex/res/EXAMPLE.txt +25 -0
- package/native/vendor/microtex/res/SAMPLES.tex +946 -0
- package/native/vendor/microtex/res/firamath/FiraMath-Regular.clm1 +0 -0
- package/native/vendor/microtex/res/firamath/FiraMath-Regular.clm2 +0 -0
- package/native/vendor/microtex/res/firamath/FiraMath-Regular.otf +0 -0
- package/native/vendor/microtex/res/firamath/README.md +42 -0
- package/native/vendor/microtex/res/lm-math/README +92 -0
- package/native/vendor/microtex/res/lm-math/latinmodern-math.clm1 +0 -0
- package/native/vendor/microtex/res/lm-math/latinmodern-math.clm2 +0 -0
- package/native/vendor/microtex/res/lm-math/latinmodern-math.otf +0 -0
- package/native/vendor/microtex/res/tex-gyre/README-TeX-Gyre-DejaVu-Math.txt +82 -0
- package/native/vendor/microtex/res/tex-gyre/texgyredejavu-math.clm1 +0 -0
- package/native/vendor/microtex/res/tex-gyre/texgyredejavu-math.clm2 +0 -0
- package/native/vendor/microtex/res/tex-gyre/texgyredejavu-math.otf +0 -0
- package/native/vendor/microtex/res/xits/FONTLOG.txt +246 -0
- package/native/vendor/microtex/res/xits/OFL.txt +98 -0
- package/native/vendor/microtex/res/xits/README.txt +15 -0
- package/native/vendor/microtex/res/xits/XITS-Bold.clm1 +0 -0
- package/native/vendor/microtex/res/xits/XITS-Bold.clm2 +0 -0
- package/native/vendor/microtex/res/xits/XITS-Bold.otf +0 -0
- package/native/vendor/microtex/res/xits/XITS-BoldItalic.clm1 +0 -0
- package/native/vendor/microtex/res/xits/XITS-BoldItalic.clm2 +0 -0
- package/native/vendor/microtex/res/xits/XITS-BoldItalic.otf +0 -0
- package/native/vendor/microtex/res/xits/XITS-Italic.clm1 +0 -0
- package/native/vendor/microtex/res/xits/XITS-Italic.clm2 +0 -0
- package/native/vendor/microtex/res/xits/XITS-Italic.otf +0 -0
- package/native/vendor/microtex/res/xits/XITS-Regular.clm1 +0 -0
- package/native/vendor/microtex/res/xits/XITS-Regular.clm2 +0 -0
- package/native/vendor/microtex/res/xits/XITS-Regular.otf +0 -0
- package/native/vendor/microtex/res/xits/XITSMath-Bold.clm1 +0 -0
- package/native/vendor/microtex/res/xits/XITSMath-Bold.clm2 +0 -0
- package/native/vendor/microtex/res/xits/XITSMath-Bold.otf +0 -0
- package/native/vendor/microtex/res/xits/XITSMath-Regular.clm1 +0 -0
- package/native/vendor/microtex/res/xits/XITSMath-Regular.clm2 +0 -0
- package/native/vendor/microtex/res/xits/XITSMath-Regular.otf +0 -0
- package/native/vendor/microtex/test/clm/meson.build +10 -0
- package/native/vendor/microtex/test/clm/test_clm.cpp +140 -0
- package/native/vendor/microtex/test/env/meson.build +10 -0
- package/native/vendor/microtex/test/env/test_env.cpp +100 -0
- package/native/vendor/microtex/test/fuzzer/afl.native +20 -0
- package/native/vendor/microtex/test/fuzzer/fuzz.sh +135 -0
- package/native/vendor/microtex/test/fuzzer/fuzzer.cpp +61 -0
- package/native/vendor/microtex/test/fuzzer/generateSeed.java +33 -0
- package/native/vendor/microtex/test/fuzzer/meson.build +9 -0
- package/native/vendor/microtex/test/fuzzer/microtex.dict +3708 -0
- package/native/vendor/microtex/test/fuzzer/platform_none.cpp +100 -0
- package/native/vendor/microtex/test/has_filesystem.cpp +8 -0
- package/native/vendor/microtex/test/meson.build +6 -0
- package/native/vendor/nanosvg.h +3278 -0
- package/native/vendor/nanosvgrast.h +1472 -0
- package/native/vendor/zigtex/.github/assets/example.svg +27 -0
- package/native/vendor/zigtex/LICENSE +674 -0
- package/native/vendor/zigtex/README.md +52 -0
- package/native/vendor/zigtex/build.zig +52 -0
- package/native/vendor/zigtex/build.zig.zon +16 -0
- package/native/vendor/zigtex/fonts/latinmodern-math.clm2 +0 -0
- package/native/vendor/zigtex/src/main.zig +22 -0
- package/native/vendor/zigtex/src/root.zig +124 -0
- package/native/vendor/zigtex/src/svg.zig +273 -0
- package/native/vendor/zigtex/src/tex.zig +383 -0
- package/native/zigtex-0.16.patch +35 -0
- package/package.json +27 -0
- package/scripts/bootstrap-native +89 -0
|
@@ -0,0 +1,874 @@
|
|
|
1
|
+
#include "core/parser.h"
|
|
2
|
+
|
|
3
|
+
#include "atom/atom.h"
|
|
4
|
+
#include "atom/atom_basic.h"
|
|
5
|
+
#include "atom/atom_delim.h"
|
|
6
|
+
#include "atom/atom_font.h"
|
|
7
|
+
#include "atom/atom_operator.h"
|
|
8
|
+
#include "atom/atom_scripts.h"
|
|
9
|
+
#include "core/formula.h"
|
|
10
|
+
#include "env/units.h"
|
|
11
|
+
#include "graphic/graphic.h"
|
|
12
|
+
#include "macro/macro.h"
|
|
13
|
+
#include "utils/exceptions.h"
|
|
14
|
+
#include "utils/string_utils.h"
|
|
15
|
+
#include "utils/utf.h"
|
|
16
|
+
|
|
17
|
+
using namespace std;
|
|
18
|
+
using namespace microtex;
|
|
19
|
+
|
|
20
|
+
namespace {
|
|
21
|
+
|
|
22
|
+
/** escape character */
|
|
23
|
+
static constexpr char ESCAPE = '\\';
|
|
24
|
+
/** grouping characters (for parsing) */
|
|
25
|
+
static constexpr char L_GROUP = '{';
|
|
26
|
+
static constexpr char R_GROUP = '}';
|
|
27
|
+
static constexpr char L_BRACK = '[';
|
|
28
|
+
static constexpr char R_BRACK = ']';
|
|
29
|
+
static constexpr char DOLLAR = '$';
|
|
30
|
+
static constexpr char DQUOTE = '\"';
|
|
31
|
+
/** percent char for comments */
|
|
32
|
+
static constexpr char PERCENT = '%';
|
|
33
|
+
/** script character (for parsing) */
|
|
34
|
+
static constexpr char SUB_SCRIPT = '_';
|
|
35
|
+
static constexpr char SUPER_SCRIPT = '^';
|
|
36
|
+
static constexpr char PRIME = '\'';
|
|
37
|
+
static constexpr char BACKPRIME = '`';
|
|
38
|
+
|
|
39
|
+
} // namespace
|
|
40
|
+
|
|
41
|
+
void Parser::init(bool isPartial, const string& latex, Formula* formula, bool firstPass) {
|
|
42
|
+
_pos = _spos = _len = 0;
|
|
43
|
+
_group = 0;
|
|
44
|
+
_atIsLetter = 0;
|
|
45
|
+
_insertion = _arrayMode = _isMathMode = false;
|
|
46
|
+
_isPartial = true;
|
|
47
|
+
|
|
48
|
+
_formula = formula;
|
|
49
|
+
_isMathMode = true;
|
|
50
|
+
_isPartial = isPartial;
|
|
51
|
+
if (!latex.empty()) {
|
|
52
|
+
_latex = latex;
|
|
53
|
+
_len = latex.length();
|
|
54
|
+
_pos = 0;
|
|
55
|
+
if (firstPass) preprocess();
|
|
56
|
+
} else {
|
|
57
|
+
_latex = "";
|
|
58
|
+
_pos = 0;
|
|
59
|
+
_len = 0;
|
|
60
|
+
}
|
|
61
|
+
_arrayMode = formula->isArrayMode();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
void Parser::reset(const string& latex) {
|
|
65
|
+
_latex = latex;
|
|
66
|
+
_len = latex.length();
|
|
67
|
+
_formula->_root = nullptr;
|
|
68
|
+
_pos = 0;
|
|
69
|
+
_spos = 0;
|
|
70
|
+
_group = 0;
|
|
71
|
+
_insertion = false;
|
|
72
|
+
_atIsLetter = 0;
|
|
73
|
+
_arrayMode = false;
|
|
74
|
+
_isMathMode = true;
|
|
75
|
+
preprocess();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
sptr<Atom> Parser::popBack() const {
|
|
79
|
+
auto a = _formula->_root;
|
|
80
|
+
auto* ra = dynamic_cast<RowAtom*>(a.get());
|
|
81
|
+
if (ra != nullptr) return ra->popBack();
|
|
82
|
+
_formula->_root = nullptr;
|
|
83
|
+
return a;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
sptr<Atom> Parser::popFormulaAtom() const {
|
|
87
|
+
auto a = _formula->_root;
|
|
88
|
+
_formula->_root = nullptr;
|
|
89
|
+
return a;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
void Parser::addAtom(const sptr<Atom>& atom) const {
|
|
93
|
+
_formula->add(atom);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
void Parser::addRow() const {
|
|
97
|
+
if (!_arrayMode) throw ex_parse("Can not add row in none-array mode!");
|
|
98
|
+
((ArrayFormula*)_formula)->addRow();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
string Parser::getGroup(char openclose) {
|
|
102
|
+
int spos = _pos;
|
|
103
|
+
char ch;
|
|
104
|
+
|
|
105
|
+
do {
|
|
106
|
+
ch = _latex[_pos++];
|
|
107
|
+
if (ch == ESCAPE) _pos++;
|
|
108
|
+
} while (_pos < _len && ch != openclose);
|
|
109
|
+
|
|
110
|
+
if (ch == openclose) return _latex.substr(spos, _pos - spos - 1);
|
|
111
|
+
return _latex.substr(spos, _pos - spos);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
string Parser::getGroup(char open, char close) {
|
|
115
|
+
if (_pos == _len) return "";
|
|
116
|
+
|
|
117
|
+
int group, spos;
|
|
118
|
+
char ch = _latex[_pos];
|
|
119
|
+
|
|
120
|
+
if (_pos < _len && ch == open) {
|
|
121
|
+
group = 1;
|
|
122
|
+
spos = _pos;
|
|
123
|
+
while (_pos < _len - 1 && group != 0) {
|
|
124
|
+
_pos++;
|
|
125
|
+
ch = _latex[_pos];
|
|
126
|
+
if (ch == open)
|
|
127
|
+
group++;
|
|
128
|
+
else if (ch == close)
|
|
129
|
+
group--;
|
|
130
|
+
else if (ch == ESCAPE && _pos != _len - 1)
|
|
131
|
+
_pos++;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
_pos++;
|
|
135
|
+
|
|
136
|
+
if (group != 0) return _latex.substr(spos + 1, _pos - spos - 1);
|
|
137
|
+
return _latex.substr(spos + 1, _pos - spos - 2);
|
|
138
|
+
}
|
|
139
|
+
throw ex_parse("Missing '" + toString((char)open) + "'!");
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
string Parser::getGroup(const string& open, const string& close) {
|
|
143
|
+
int group = 1;
|
|
144
|
+
int ol = open.length();
|
|
145
|
+
int cl = close.length();
|
|
146
|
+
bool lastO = isValidCharInCmd(open[ol - 1]);
|
|
147
|
+
bool lastC = isValidCharInCmd(close[cl - 1]);
|
|
148
|
+
int oc = 0;
|
|
149
|
+
int cc = 0;
|
|
150
|
+
int startC = 0;
|
|
151
|
+
char prev = '\0';
|
|
152
|
+
string buf;
|
|
153
|
+
|
|
154
|
+
while (_pos < _len && group != 0) {
|
|
155
|
+
char c = _latex[_pos];
|
|
156
|
+
char c1;
|
|
157
|
+
|
|
158
|
+
if (prev != ESCAPE && c == ' ') {
|
|
159
|
+
while (_pos < _len && _latex[_pos++] == ' ') buf.append(1, ' ');
|
|
160
|
+
c = _latex[--_pos];
|
|
161
|
+
if (isValidCharInCmd(prev) && isValidCharInCmd(c)) {
|
|
162
|
+
oc = cc = 0;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (c == open[oc])
|
|
167
|
+
oc++;
|
|
168
|
+
else
|
|
169
|
+
oc = 0;
|
|
170
|
+
|
|
171
|
+
if (c == close[cc]) {
|
|
172
|
+
if (cc == 0) startC = _pos;
|
|
173
|
+
cc++;
|
|
174
|
+
} else {
|
|
175
|
+
cc = 0;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (_pos + 1 < _len) {
|
|
179
|
+
c1 = _latex[_pos + 1];
|
|
180
|
+
|
|
181
|
+
if (oc == ol) {
|
|
182
|
+
if (!lastO || !isValidCharInCmd(c1)) group++;
|
|
183
|
+
oc = 0;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (cc == cl) {
|
|
187
|
+
if (!lastC || !isValidCharInCmd(c1)) group--;
|
|
188
|
+
cc = 0;
|
|
189
|
+
}
|
|
190
|
+
} else {
|
|
191
|
+
if (oc == ol) {
|
|
192
|
+
group++;
|
|
193
|
+
oc = 0;
|
|
194
|
+
}
|
|
195
|
+
if (cc == cl) {
|
|
196
|
+
group--;
|
|
197
|
+
cc = 0;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
prev = c;
|
|
202
|
+
buf.append(1, c);
|
|
203
|
+
_pos++;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (group != 0) {
|
|
207
|
+
if (_isPartial) return buf;
|
|
208
|
+
throw ex_parse("Parse string not closed correctly!");
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return buf.substr(0, buf.length() - _pos + startC);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
string Parser::getOverArgument() {
|
|
215
|
+
if (_pos == _len) return "";
|
|
216
|
+
|
|
217
|
+
int ogroup = 1, spos;
|
|
218
|
+
char ch = '\0';
|
|
219
|
+
|
|
220
|
+
spos = _pos;
|
|
221
|
+
while (_pos < _len && ogroup != 0) {
|
|
222
|
+
ch = _latex[_pos];
|
|
223
|
+
switch (ch) {
|
|
224
|
+
case L_GROUP: ogroup++; break;
|
|
225
|
+
case '&':
|
|
226
|
+
// if a & is encountered at the same level as \over we must break the argument
|
|
227
|
+
if (ogroup == 1) ogroup--;
|
|
228
|
+
break;
|
|
229
|
+
case R_GROUP: ogroup--; break;
|
|
230
|
+
case ESCAPE:
|
|
231
|
+
_pos++;
|
|
232
|
+
// if a \\ or \cr is encountered at the same level as \over
|
|
233
|
+
// we must break the argument
|
|
234
|
+
if (_pos < _len && _latex[_pos] == '\\' && ogroup == 1) {
|
|
235
|
+
ogroup--;
|
|
236
|
+
_pos--;
|
|
237
|
+
// clang-format off
|
|
238
|
+
} else if (
|
|
239
|
+
_pos < _len - 1
|
|
240
|
+
&& _latex[_pos] == 'c'
|
|
241
|
+
&& _latex[_pos + 1] == 'r'
|
|
242
|
+
&& ogroup == 1
|
|
243
|
+
) {
|
|
244
|
+
// clang-format on
|
|
245
|
+
ogroup--;
|
|
246
|
+
_pos--;
|
|
247
|
+
}
|
|
248
|
+
default: break;
|
|
249
|
+
}
|
|
250
|
+
_pos++;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// end of string reached, but not processed properly
|
|
254
|
+
if (ogroup >= 2) throw ex_parse("Illegal end, missing '}'!");
|
|
255
|
+
|
|
256
|
+
string str;
|
|
257
|
+
if (ogroup == 0) {
|
|
258
|
+
str = _latex.substr(spos, _pos - spos - 1);
|
|
259
|
+
} else {
|
|
260
|
+
str = _latex.substr(spos, _pos - spos);
|
|
261
|
+
ch = '\0';
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
if (ch == '&' || ch == '\\' || ch == R_GROUP) _pos--;
|
|
265
|
+
|
|
266
|
+
return str;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
string Parser::getCmd() {
|
|
270
|
+
int spos = ++_pos;
|
|
271
|
+
char ch = '\0';
|
|
272
|
+
|
|
273
|
+
while (_pos < _len) {
|
|
274
|
+
ch = _latex[_pos];
|
|
275
|
+
if (!isAlpha(ch) && (_atIsLetter == 0 || ch != '@')) break;
|
|
276
|
+
_pos++;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
if (ch == '\0') return "";
|
|
280
|
+
if (_pos == spos) _pos++;
|
|
281
|
+
string com = _latex.substr(spos, _pos - spos);
|
|
282
|
+
if (com == "cr" && _pos < _len && _latex[_pos] == ' ') _pos++;
|
|
283
|
+
return com;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
void Parser::insert(int beg, int end, const string& formula) {
|
|
287
|
+
_latex.replace(beg, end - beg, formula);
|
|
288
|
+
_len = _latex.length();
|
|
289
|
+
_pos = beg;
|
|
290
|
+
_insertion = true;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
string Parser::getCmdWithArgs(const string& cmd) {
|
|
294
|
+
if (cmd == "left") return getGroup("\\left", "\\right");
|
|
295
|
+
|
|
296
|
+
auto mac = MacroInfo::get(cmd);
|
|
297
|
+
if (mac == nullptr) {
|
|
298
|
+
return "\\" + cmd;
|
|
299
|
+
}
|
|
300
|
+
int mac_opts = mac->opt;
|
|
301
|
+
|
|
302
|
+
// return as format: \cmd[opt][...]{arg}{...}
|
|
303
|
+
|
|
304
|
+
vector<string> mac_args;
|
|
305
|
+
getOptsArgs(mac->argc, mac_opts, mac_args);
|
|
306
|
+
string mac_arg("\\");
|
|
307
|
+
mac_arg.append(cmd);
|
|
308
|
+
for (int j = 0; j < mac->opt; j++) {
|
|
309
|
+
string arg_t = mac_args[mac->argc + j + 1];
|
|
310
|
+
if (!arg_t.empty()) {
|
|
311
|
+
mac_arg.append("[").append(arg_t).append("]");
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
for (int j = 0; j < mac->argc; j++) {
|
|
316
|
+
string arg_t = mac_args[j + 1];
|
|
317
|
+
if (!arg_t.empty()) {
|
|
318
|
+
mac_arg.append("{").append(arg_t).append("}");
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
return mac_arg;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
void Parser::skipWhiteSpace(int count) {
|
|
326
|
+
count = count >= 0 ? count : std::numeric_limits<int>::max();
|
|
327
|
+
char c;
|
|
328
|
+
while (_pos < _len && count > 0) {
|
|
329
|
+
c = _latex[_pos];
|
|
330
|
+
if (c != ' ' && c != '\t' && c != '\n' && c != '\r') break;
|
|
331
|
+
_pos++;
|
|
332
|
+
count--;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
string Parser::forwardBalancedGroup() {
|
|
337
|
+
if (_group == 0) {
|
|
338
|
+
const string& sub = _latex.substr(_pos);
|
|
339
|
+
finish();
|
|
340
|
+
return sub;
|
|
341
|
+
}
|
|
342
|
+
int closing = _group;
|
|
343
|
+
auto i = _latex.length() - 1;
|
|
344
|
+
for (; i >= _pos; i--) {
|
|
345
|
+
auto ch = _latex[i];
|
|
346
|
+
if (ch == R_GROUP) {
|
|
347
|
+
closing--;
|
|
348
|
+
if (closing == 0) break;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
if (closing != 0) {
|
|
352
|
+
throw ex_parse("Found a closing '}' without an opening '{'!");
|
|
353
|
+
}
|
|
354
|
+
const string& sub = _latex.substr(_pos, i - _pos);
|
|
355
|
+
_pos = i;
|
|
356
|
+
return sub;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
string Parser::forward(std::function<bool(char)>&& f) {
|
|
360
|
+
const auto p = _pos;
|
|
361
|
+
while (_pos < _len && f(_latex[_pos])) ++_pos;
|
|
362
|
+
return _latex.substr(p, _pos - p);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
void Parser::getOptsArgs(int argc, int opts, Args& args) {
|
|
366
|
+
// A maximum of 10 options can be passed to a command,
|
|
367
|
+
// the value will be added at the tail of the args if found any,
|
|
368
|
+
// the last (maximum to 12th) value is reserved for returned value
|
|
369
|
+
args.resize(argc + 10 + 1 + 1);
|
|
370
|
+
|
|
371
|
+
auto getOpts = [&]() {
|
|
372
|
+
int j = argc + 1;
|
|
373
|
+
try {
|
|
374
|
+
for (; j < argc + 11; j++) {
|
|
375
|
+
skipWhiteSpace();
|
|
376
|
+
args[j] = getGroup(L_BRACK, R_BRACK);
|
|
377
|
+
}
|
|
378
|
+
} catch (ex_parse& e) {
|
|
379
|
+
args[j] = "";
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
auto getArg = [&](int i) { // NOLINT(misc-no-recursion)
|
|
384
|
+
skipWhiteSpace();
|
|
385
|
+
try {
|
|
386
|
+
args[i] = getGroup(L_GROUP, R_GROUP);
|
|
387
|
+
} catch (ex_parse& e) {
|
|
388
|
+
if (_latex[_pos] != '\\') {
|
|
389
|
+
args[i] = toString(_latex[_pos]);
|
|
390
|
+
_pos++;
|
|
391
|
+
} else {
|
|
392
|
+
args[i] = getCmdWithArgs(getCmd());
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
// we get the options just after the command name
|
|
398
|
+
if (opts == 1) getOpts();
|
|
399
|
+
|
|
400
|
+
if (argc != 0) {
|
|
401
|
+
// we get the first argument
|
|
402
|
+
getArg(1);
|
|
403
|
+
// we get the options after the first argument
|
|
404
|
+
if (opts == 2) getOpts();
|
|
405
|
+
// we get the next arguments
|
|
406
|
+
for (int i = 2; i <= argc; i++) {
|
|
407
|
+
getArg(i);
|
|
408
|
+
}
|
|
409
|
+
// TODO skip whitespace?
|
|
410
|
+
// if (_isMathMode) skipWhiteSpace();
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
bool Parser::isValidCmd(const string& cmd) const {
|
|
415
|
+
if (cmd.empty()) return false;
|
|
416
|
+
if (cmd[0] != '\\') return false;
|
|
417
|
+
|
|
418
|
+
char c = '\0';
|
|
419
|
+
int p = 1;
|
|
420
|
+
int l = cmd.length();
|
|
421
|
+
while (p < l) {
|
|
422
|
+
c = cmd[p];
|
|
423
|
+
if (!isAlpha(c) && (_atIsLetter == 0 || c != '@')) break;
|
|
424
|
+
p++;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
return isAlpha(c);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
bool Parser::isValidCharInCmd(char ch) const {
|
|
431
|
+
return isAlpha(ch) || (_atIsLetter != 0 && ch == '@');
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
sptr<Atom> Parser::processEscape() {
|
|
435
|
+
_spos = _pos;
|
|
436
|
+
const string cmd = getCmd();
|
|
437
|
+
|
|
438
|
+
if (cmd.length() == 0) return sptrOf<EmptyAtom>();
|
|
439
|
+
|
|
440
|
+
auto mac = MacroInfo::get(cmd);
|
|
441
|
+
if (mac != nullptr) {
|
|
442
|
+
return processCmd(cmd, mac);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
sptr<Formula> predef = Formula::get(cmd);
|
|
446
|
+
if (predef != nullptr) return predef->_root;
|
|
447
|
+
|
|
448
|
+
sptr<Atom> sym = SymbolAtom::get(cmd);
|
|
449
|
+
if (sym != nullptr) return sym;
|
|
450
|
+
|
|
451
|
+
// not a valid command or symbol or predefined Formula found
|
|
452
|
+
if (!_isPartial) {
|
|
453
|
+
throw ex_parse("Unknown symbol or command or predefined Formula: '" + cmd + "'");
|
|
454
|
+
}
|
|
455
|
+
auto rm = sptrOf<FontStyleAtom>(
|
|
456
|
+
FontStyle::tt,
|
|
457
|
+
false,
|
|
458
|
+
Formula("\\mathtt{{\\backslash}" + cmd + "}")._root
|
|
459
|
+
);
|
|
460
|
+
return sptrOf<ColorAtom>(rm, TRANSPARENT, RED);
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
sptr<Atom> Parser::processCmd(const string& cmd, MacroInfo* mac) {
|
|
464
|
+
int opts = mac->opt;
|
|
465
|
+
|
|
466
|
+
Args args;
|
|
467
|
+
getOptsArgs(mac->argc, opts, args);
|
|
468
|
+
// we promise the first argument is the command name itself
|
|
469
|
+
args[0] = cmd;
|
|
470
|
+
|
|
471
|
+
if (NewCommandMacro::isMacro(cmd)) {
|
|
472
|
+
// The last value in "args" is the replacement string
|
|
473
|
+
auto ret = mac->invoke(*this, args);
|
|
474
|
+
insert(_spos, _pos, args.back());
|
|
475
|
+
return ret;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
return mac->invoke(*this, args);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
sptr<Atom> Parser::getScripts(char first) {
|
|
482
|
+
_pos++;
|
|
483
|
+
// get the sub script (assume the first is the sub script)
|
|
484
|
+
sptr<Atom> sub = getArgument();
|
|
485
|
+
sptr<Atom> sup(nullptr);
|
|
486
|
+
char second = '\0';
|
|
487
|
+
|
|
488
|
+
if (_pos < _len) second = _latex[_pos];
|
|
489
|
+
|
|
490
|
+
// 4 conditions:
|
|
491
|
+
// 1. \cmd_{\sub}^{\super}
|
|
492
|
+
// 2. \cmd^{\super}_{\sub}
|
|
493
|
+
// 3. \cmd_{\sub}
|
|
494
|
+
// 4. \cmd^{\super}
|
|
495
|
+
if (first == SUPER_SCRIPT && second == SUPER_SCRIPT) {
|
|
496
|
+
sup = sub;
|
|
497
|
+
sub = nullptr;
|
|
498
|
+
} else if (first == SUB_SCRIPT && second == SUPER_SCRIPT) {
|
|
499
|
+
_pos++;
|
|
500
|
+
sup = getArgument();
|
|
501
|
+
} else if (first == SUPER_SCRIPT && second == SUB_SCRIPT) {
|
|
502
|
+
_pos++;
|
|
503
|
+
sup = sub;
|
|
504
|
+
sub = getArgument();
|
|
505
|
+
} else if (first == SUPER_SCRIPT && second != SUB_SCRIPT) {
|
|
506
|
+
sup = sub;
|
|
507
|
+
sub = nullptr;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
sptr<Atom> atom;
|
|
511
|
+
RowAtom* rm = nullptr;
|
|
512
|
+
if (_formula->_root == nullptr) {
|
|
513
|
+
// If there's no root exists, passing a null atom to ScriptsAtom as base is OK,
|
|
514
|
+
// the ScriptsAtom will handle it
|
|
515
|
+
return sptrOf<ScriptsAtom>(nullptr, sub, sup);
|
|
516
|
+
} else if ((rm = dynamic_cast<RowAtom*>(_formula->_root.get()))) {
|
|
517
|
+
atom = rm->popBack();
|
|
518
|
+
} else {
|
|
519
|
+
atom = _formula->_root;
|
|
520
|
+
_formula->_root = nullptr;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
// Check if previous atom is CumulativeScriptsAtom
|
|
524
|
+
auto* ca = dynamic_cast<CumulativeScriptsAtom*>(atom.get());
|
|
525
|
+
if (ca != nullptr) {
|
|
526
|
+
ca->addSubscript(sub);
|
|
527
|
+
ca->addSuperscript(sup);
|
|
528
|
+
return atom;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
if (atom->rightType() == AtomType::bigOperator) {
|
|
532
|
+
return sptrOf<OperatorAtom>(atom, sub, sup);
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
return sptrOf<ScriptsAtom>(atom, sub, sup);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
sptr<Atom> Parser::getArgument() {
|
|
539
|
+
skipWhiteSpace();
|
|
540
|
+
char ch;
|
|
541
|
+
if (_pos < _len)
|
|
542
|
+
ch = _latex[_pos];
|
|
543
|
+
else
|
|
544
|
+
return sptrOf<EmptyAtom>();
|
|
545
|
+
|
|
546
|
+
if (ch == L_GROUP) {
|
|
547
|
+
_pos++;
|
|
548
|
+
_group++;
|
|
549
|
+
|
|
550
|
+
Formula f;
|
|
551
|
+
Formula* t = _formula;
|
|
552
|
+
|
|
553
|
+
const bool arrayMode = isArrayMode();
|
|
554
|
+
_arrayMode = false;
|
|
555
|
+
_formula = &f;
|
|
556
|
+
parse();
|
|
557
|
+
_formula = t;
|
|
558
|
+
_arrayMode = arrayMode;
|
|
559
|
+
|
|
560
|
+
if (_formula->_root == nullptr) {
|
|
561
|
+
auto rm = sptrOf<RowAtom>();
|
|
562
|
+
rm->add(f._root);
|
|
563
|
+
return rm;
|
|
564
|
+
}
|
|
565
|
+
return f._root;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
if (ch == ESCAPE) {
|
|
569
|
+
auto atom = processEscape();
|
|
570
|
+
if (_insertion) {
|
|
571
|
+
_insertion = false;
|
|
572
|
+
return getArgument();
|
|
573
|
+
}
|
|
574
|
+
return atom;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
auto atom = getCharAtom();
|
|
578
|
+
_pos++;
|
|
579
|
+
return atom;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
Dimen Parser::getDimen() {
|
|
583
|
+
if (_pos == _len) return {0.f, UnitType::none};
|
|
584
|
+
|
|
585
|
+
char ch = '\0';
|
|
586
|
+
|
|
587
|
+
skipWhiteSpace();
|
|
588
|
+
const int start = _pos;
|
|
589
|
+
while (_pos < _len && ch != ' ' && ch != '\t' && ch != '\r' && ch != '\n' && ch != ESCAPE) {
|
|
590
|
+
ch = _latex[_pos++];
|
|
591
|
+
}
|
|
592
|
+
const int end = _pos;
|
|
593
|
+
if (ch == '\\')
|
|
594
|
+
_pos--;
|
|
595
|
+
else
|
|
596
|
+
skipWhiteSpace();
|
|
597
|
+
|
|
598
|
+
return Units::getDimen(_latex.substr(start, end - start - 1));
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
void Parser::preprocess(string& cmd, Args& args, int& pos) {
|
|
602
|
+
if (cmd == "newcommand" || cmd == "renewcommand") {
|
|
603
|
+
preprocessNewCmd(cmd, args, pos);
|
|
604
|
+
} else if (cmd == "newenvironment" || cmd == "renewenvironment") {
|
|
605
|
+
preprocessNewCmd(cmd, args, pos);
|
|
606
|
+
} else if (NewCommandMacro::isMacro(cmd)) {
|
|
607
|
+
inflateNewCmd(cmd, args, pos);
|
|
608
|
+
} else if (cmd == "begin") {
|
|
609
|
+
inflateEnv(cmd, args, pos);
|
|
610
|
+
} else if (cmd == "makeatletter") {
|
|
611
|
+
_atIsLetter++;
|
|
612
|
+
} else if (cmd == "makeatother") {
|
|
613
|
+
_atIsLetter--;
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
void Parser::preprocessNewCmd(string& cmd, Args& args, int& pos) {
|
|
618
|
+
// The macro must exists
|
|
619
|
+
auto mac = MacroInfo::get(cmd);
|
|
620
|
+
getOptsArgs(mac->argc, mac->opt, args);
|
|
621
|
+
mac->invoke(*this, args);
|
|
622
|
+
_latex.erase(pos, _pos - pos);
|
|
623
|
+
_len = _latex.length();
|
|
624
|
+
_pos = pos;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
void Parser::inflateNewCmd(string& cmd, Args& args, int& pos) {
|
|
628
|
+
// The macro must exists
|
|
629
|
+
auto mac = MacroInfo::get(cmd);
|
|
630
|
+
getOptsArgs(mac->argc, mac->opt, args);
|
|
631
|
+
args[0] = cmd;
|
|
632
|
+
try {
|
|
633
|
+
mac->invoke(*this, args);
|
|
634
|
+
// The last element is the returned value (after inflated macro)
|
|
635
|
+
_latex.replace(pos, _pos - pos, args.back());
|
|
636
|
+
} catch (ex_parse& e) {
|
|
637
|
+
if (!_isPartial) throw e;
|
|
638
|
+
pos += cmd.length() + 1;
|
|
639
|
+
}
|
|
640
|
+
_len = _latex.length();
|
|
641
|
+
_pos = pos;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
void Parser::inflateEnv(string& cmd, Args& args, int& pos) {
|
|
645
|
+
getOptsArgs(1, 0, args);
|
|
646
|
+
string env = args[1] + "@env";
|
|
647
|
+
auto mac = MacroInfo::get(env);
|
|
648
|
+
if (mac == nullptr) {
|
|
649
|
+
throw ex_parse("Unknown environment: " + args[1]);
|
|
650
|
+
}
|
|
651
|
+
vector<string> optargs;
|
|
652
|
+
getOptsArgs(mac->argc - 1, 0, optargs);
|
|
653
|
+
string grp = getGroup("\\begin{" + args[1] + "}", "\\end{" + args[1] + "}");
|
|
654
|
+
string expr = "{\\makeatletter \\" + args[1] + "@env";
|
|
655
|
+
for (int i = 1; i <= mac->argc - 1; i++) expr += "{" + optargs[i] + "}";
|
|
656
|
+
expr += "{" + grp + "}\\makeatother}";
|
|
657
|
+
_latex.replace(pos, _pos - pos, expr);
|
|
658
|
+
_len = _latex.length();
|
|
659
|
+
_pos = pos;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
void Parser::preprocess() {
|
|
663
|
+
if (_len == 0) return;
|
|
664
|
+
|
|
665
|
+
char ch;
|
|
666
|
+
int spos;
|
|
667
|
+
vector<string> args;
|
|
668
|
+
while (_pos < _len) {
|
|
669
|
+
ch = _latex[_pos];
|
|
670
|
+
switch (ch) {
|
|
671
|
+
case ESCAPE: {
|
|
672
|
+
spos = _pos;
|
|
673
|
+
string cmd = getCmd();
|
|
674
|
+
try {
|
|
675
|
+
preprocess(cmd, args, spos);
|
|
676
|
+
} catch (ex_parse& e) {
|
|
677
|
+
if (!_isPartial) throw e;
|
|
678
|
+
}
|
|
679
|
+
args.clear();
|
|
680
|
+
break;
|
|
681
|
+
}
|
|
682
|
+
case PERCENT: {
|
|
683
|
+
spos = _pos++;
|
|
684
|
+
char chr;
|
|
685
|
+
while (_pos < _len) {
|
|
686
|
+
chr = _latex[_pos++];
|
|
687
|
+
if (chr == '\r' || chr == '\n') break;
|
|
688
|
+
}
|
|
689
|
+
if (_pos < _len) _pos--;
|
|
690
|
+
_latex.replace(spos, _pos - spos, "");
|
|
691
|
+
_len = _latex.length();
|
|
692
|
+
_pos = spos;
|
|
693
|
+
break;
|
|
694
|
+
}
|
|
695
|
+
default: _pos++; break;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
_pos = 0;
|
|
699
|
+
_len = _latex.length();
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
void Parser::parse() {
|
|
703
|
+
if (_len == 0) {
|
|
704
|
+
if (_formula->_root == nullptr && !_arrayMode) _formula->add(sptrOf<EmptyAtom>());
|
|
705
|
+
return;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
char ch;
|
|
709
|
+
while (_pos < _len) {
|
|
710
|
+
ch = _latex[_pos];
|
|
711
|
+
|
|
712
|
+
switch (ch) {
|
|
713
|
+
case '\n':
|
|
714
|
+
case '\t':
|
|
715
|
+
case '\r':
|
|
716
|
+
case ' ': {
|
|
717
|
+
_pos++;
|
|
718
|
+
if (!_isMathMode) { // we are in text mode
|
|
719
|
+
_formula->add(sptrOf<SpaceAtom>(false));
|
|
720
|
+
_formula->add(sptrOf<BreakMarkAtom>());
|
|
721
|
+
while (_pos < _len) {
|
|
722
|
+
ch = _latex[_pos];
|
|
723
|
+
if (ch != ' ' || ch != '\t' || ch != '\r') break;
|
|
724
|
+
_pos++;
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
} break;
|
|
728
|
+
case DOLLAR: {
|
|
729
|
+
_pos++;
|
|
730
|
+
if (!_isMathMode) { // we are in text mode
|
|
731
|
+
TexStyle style = TexStyle::text;
|
|
732
|
+
bool doubleDollar = false;
|
|
733
|
+
if (_latex[_pos] == DOLLAR) {
|
|
734
|
+
style = TexStyle::display;
|
|
735
|
+
doubleDollar = true;
|
|
736
|
+
_pos++;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
auto atom = sptrOf<MathAtom>(Formula(*this, getGroup(DOLLAR), false)._root, style);
|
|
740
|
+
_formula->add(atom);
|
|
741
|
+
if (doubleDollar) {
|
|
742
|
+
if (_latex[_pos] == DOLLAR) _pos++;
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
} break;
|
|
746
|
+
case ESCAPE: {
|
|
747
|
+
sptr<Atom> atom = processEscape();
|
|
748
|
+
_formula->add(atom);
|
|
749
|
+
auto* h = dynamic_cast<HlineAtom*>(atom.get());
|
|
750
|
+
if (_arrayMode && h != nullptr) ((ArrayFormula*)_formula)->addRow();
|
|
751
|
+
if (_insertion) _insertion = false;
|
|
752
|
+
} break;
|
|
753
|
+
case L_GROUP: {
|
|
754
|
+
auto atom = getArgument();
|
|
755
|
+
if (atom != nullptr) {
|
|
756
|
+
atom->_type = AtomType::ordinary;
|
|
757
|
+
}
|
|
758
|
+
_formula->add(atom);
|
|
759
|
+
} break;
|
|
760
|
+
case R_GROUP: {
|
|
761
|
+
_group--;
|
|
762
|
+
_pos++;
|
|
763
|
+
if (_group == -1) {
|
|
764
|
+
throw ex_parse("Found a closing '}' without an opening '{'!");
|
|
765
|
+
}
|
|
766
|
+
// End of a group
|
|
767
|
+
return;
|
|
768
|
+
}
|
|
769
|
+
case SUPER_SCRIPT:
|
|
770
|
+
case SUB_SCRIPT: {
|
|
771
|
+
if (_isMathMode) {
|
|
772
|
+
_formula->add(getScripts(ch));
|
|
773
|
+
} else {
|
|
774
|
+
_formula->add(getCharAtom());
|
|
775
|
+
_pos++;
|
|
776
|
+
}
|
|
777
|
+
} break;
|
|
778
|
+
case '&': {
|
|
779
|
+
if (!_arrayMode) {
|
|
780
|
+
throw ex_parse("Character '&' is only available in array mode!");
|
|
781
|
+
}
|
|
782
|
+
((ArrayFormula*)_formula)->addCol();
|
|
783
|
+
_pos++;
|
|
784
|
+
} break;
|
|
785
|
+
case '~': {
|
|
786
|
+
_formula->add(sptrOf<SpaceAtom>());
|
|
787
|
+
_pos++;
|
|
788
|
+
} break;
|
|
789
|
+
case PRIME:
|
|
790
|
+
case BACKPRIME: {
|
|
791
|
+
// special case for ` and '
|
|
792
|
+
if (_isMathMode) {
|
|
793
|
+
auto atom =
|
|
794
|
+
sptrOf<CumulativeScriptsAtom>(popBack(), nullptr, getSimpleScripts(ch != BACKPRIME));
|
|
795
|
+
_formula->add(atom);
|
|
796
|
+
} else {
|
|
797
|
+
_formula->add(getCharAtom());
|
|
798
|
+
_pos++;
|
|
799
|
+
}
|
|
800
|
+
} break;
|
|
801
|
+
case DQUOTE: {
|
|
802
|
+
if (_isMathMode) {
|
|
803
|
+
auto atom = sptrOf<CumulativeScriptsAtom>(
|
|
804
|
+
popBack(),
|
|
805
|
+
nullptr,
|
|
806
|
+
sptrOf<CharAtom>(0x02033, _isMathMode)
|
|
807
|
+
);
|
|
808
|
+
_formula->add(atom);
|
|
809
|
+
} else {
|
|
810
|
+
_formula->add(getCharAtom());
|
|
811
|
+
}
|
|
812
|
+
_pos++;
|
|
813
|
+
} break;
|
|
814
|
+
default: {
|
|
815
|
+
_formula->add(getCharAtom());
|
|
816
|
+
_pos++;
|
|
817
|
+
} break;
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
sptr<Atom> Parser::getCharAtom() {
|
|
823
|
+
int n = 0, m = 0, cnt = 0;
|
|
824
|
+
c32 chr = 0;
|
|
825
|
+
const auto next = [&]() { return microtex::nextUnicode(_latex, _pos + n, m); };
|
|
826
|
+
const auto collect = [&](c32 code) {
|
|
827
|
+
n += m;
|
|
828
|
+
cnt++;
|
|
829
|
+
chr = code;
|
|
830
|
+
};
|
|
831
|
+
microtex::scanContinuedUnicodes(next, collect);
|
|
832
|
+
auto atom = (cnt == 1 ? getCharAtom(chr) : sptrOf<TextAtom>(_latex.substr(_pos, n), _isMathMode));
|
|
833
|
+
_pos += n - 1;
|
|
834
|
+
return atom;
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
sptr<Atom> Parser::getCharAtom(c32 chr) {
|
|
838
|
+
const c32 code = microtex::convertToRomanNumber(chr);
|
|
839
|
+
if (_isMathMode) {
|
|
840
|
+
const auto it = Formula::_charToSymbol.find(code);
|
|
841
|
+
if (it != Formula::_charToSymbol.end()) {
|
|
842
|
+
return SymbolAtom::get(it->second);
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
return sptrOf<CharAtom>(code, _isMathMode);
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
sptr<Atom> Parser::getSimpleScripts(bool isPrime) {
|
|
849
|
+
int count = 1;
|
|
850
|
+
while (true) {
|
|
851
|
+
++_pos;
|
|
852
|
+
if (_pos >= _len) break;
|
|
853
|
+
const auto chr = _latex[_pos];
|
|
854
|
+
if ((isPrime && chr != PRIME) || (!isPrime && chr != BACKPRIME)) {
|
|
855
|
+
break;
|
|
856
|
+
}
|
|
857
|
+
++count;
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
static const c32 primes[] = {0x02032, 0x02033, 0x02034, 0x02057};
|
|
861
|
+
static const c32 backprimes[] = {0x02035, 0x02036, 0x02037};
|
|
862
|
+
|
|
863
|
+
const auto arr = isPrime ? primes : backprimes;
|
|
864
|
+
const auto cnt = isPrime ? 4 : 3;
|
|
865
|
+
|
|
866
|
+
if (count <= cnt) {
|
|
867
|
+
return sptrOf<CharAtom>(arr[count - 1], _isMathMode);
|
|
868
|
+
}
|
|
869
|
+
const auto row = sptrOf<RowAtom>();
|
|
870
|
+
for (int i = 0; i < count; i++) {
|
|
871
|
+
row->add(sptrOf<CharAtom>(arr[0], _isMathMode));
|
|
872
|
+
}
|
|
873
|
+
return row;
|
|
874
|
+
}
|