hyhyhy 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +184 -0
- data/Rakefile +2 -0
- data/bin/hyhyhy +59 -0
- data/hyhyhy.gemspec +29 -0
- data/lib/hyhyhy.rb +101 -0
- data/lib/hyhyhy/config.rb +29 -0
- data/lib/hyhyhy/frames.rb +108 -0
- data/lib/hyhyhy/logger.rb +40 -0
- data/lib/hyhyhy/parser.rb +9 -0
- data/lib/hyhyhy/structure/.bowerrc +5 -0
- data/lib/hyhyhy/structure/.hyhyhy +5 -0
- data/lib/hyhyhy/structure/README.md +0 -0
- data/lib/hyhyhy/structure/_assets/javascripts/main.js +395 -0
- data/lib/hyhyhy/structure/_assets/stylesheets/main.css +520 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/.bower.json +47 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/Gruntfile.js +472 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/LICENSE +21 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/README.md +129 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/bower.json +38 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/dist/css/bootstrap-theme.css +470 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/dist/css/bootstrap-theme.css.map +1 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/dist/css/bootstrap-theme.min.css +5 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/dist/css/bootstrap.css +6332 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/dist/css/bootstrap.css.map +1 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/dist/css/bootstrap.min.css +5 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/dist/fonts/glyphicons-halflings-regular.eot +0 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/dist/fonts/glyphicons-halflings-regular.svg +229 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf +0 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/dist/fonts/glyphicons-halflings-regular.woff +0 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/dist/js/bootstrap.js +2320 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/dist/js/bootstrap.min.js +7 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/dist/js/npm.js +13 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/fonts/glyphicons-halflings-regular.eot +0 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/fonts/glyphicons-halflings-regular.svg +229 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/fonts/glyphicons-halflings-regular.ttf +0 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/fonts/glyphicons-halflings-regular.woff +0 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/grunt/.jshintrc +7 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/grunt/bs-commonjs-generator.js +23 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/grunt/bs-lessdoc-parser.js +238 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/grunt/bs-raw-files-generator.js +46 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/grunt/configBridge.json +44 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/grunt/sauce_browsers.yml +82 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/js/.jscsrc +34 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/js/.jshintrc +15 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/js/affix.js +162 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/js/alert.js +94 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/js/button.js +116 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/js/carousel.js +240 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/js/collapse.js +211 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/js/dropdown.js +161 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/js/modal.js +324 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/js/popover.js +119 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/js/scrollspy.js +175 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/js/tab.js +153 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/js/tooltip.js +478 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/js/transition.js +59 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/.csscomb.json +304 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/.csslintrc +19 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/alerts.less +68 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/badges.less +61 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/bootstrap.less +50 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/breadcrumbs.less +26 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/button-groups.less +243 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/buttons.less +160 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/carousel.less +267 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/close.less +33 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/code.less +69 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/component-animations.less +34 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/dropdowns.less +213 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/forms.less +546 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/glyphicons.less +234 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/grid.less +84 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/input-groups.less +166 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/jumbotron.less +49 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/labels.less +64 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/list-group.less +124 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/media.less +47 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/mixins.less +39 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/mixins/alerts.less +14 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/mixins/background-variant.less +8 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/mixins/border-radius.less +18 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/mixins/buttons.less +52 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/mixins/center-block.less +7 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/mixins/clearfix.less +22 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/mixins/forms.less +85 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/mixins/gradients.less +59 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/mixins/grid-framework.less +91 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/mixins/grid.less +122 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/mixins/hide-text.less +21 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/mixins/image.less +33 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/mixins/labels.less +12 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/mixins/list-group.less +29 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/mixins/nav-divider.less +10 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/mixins/nav-vertical-align.less +9 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/mixins/opacity.less +8 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/mixins/pagination.less +23 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/mixins/panels.less +24 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/mixins/progress-bar.less +10 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/mixins/reset-filter.less +8 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/mixins/resize.less +6 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/mixins/responsive-visibility.less +15 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/mixins/size.less +10 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/mixins/tab-focus.less +9 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/mixins/table-row.less +28 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/mixins/text-emphasis.less +8 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/mixins/text-overflow.less +8 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/mixins/vendor-prefixes.less +227 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/modals.less +148 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/navbar.less +660 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/navs.less +244 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/normalize.less +427 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/pager.less +54 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/pagination.less +88 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/panels.less +261 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/popovers.less +135 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/print.less +107 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/progress-bars.less +87 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/responsive-embed.less +35 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/responsive-utilities.less +194 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/scaffolding.less +150 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/tables.less +234 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/theme.less +272 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/thumbnails.less +36 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/tooltip.less +103 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/type.less +302 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/utilities.less +56 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/variables.less +856 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/less/wells.less +29 -0
- data/lib/hyhyhy/structure/_includes/bootstrap/package.json +82 -0
- data/lib/hyhyhy/structure/_includes/bower.json +9 -0
- data/lib/hyhyhy/structure/_includes/d3/.bower.json +37 -0
- data/lib/hyhyhy/structure/_includes/d3/CONTRIBUTING.md +25 -0
- data/lib/hyhyhy/structure/_includes/d3/LICENSE +26 -0
- data/lib/hyhyhy/structure/_includes/d3/README.md +9 -0
- data/lib/hyhyhy/structure/_includes/d3/bower.json +26 -0
- data/lib/hyhyhy/structure/_includes/d3/d3.js +9470 -0
- data/lib/hyhyhy/structure/_includes/d3/d3.min.js +5 -0
- data/lib/hyhyhy/structure/_includes/jquery/.bower.json +38 -0
- data/lib/hyhyhy/structure/_includes/jquery/MIT-LICENSE.txt +21 -0
- data/lib/hyhyhy/structure/_includes/jquery/bower.json +27 -0
- data/lib/hyhyhy/structure/_includes/jquery/dist/jquery.js +9190 -0
- data/lib/hyhyhy/structure/_includes/jquery/dist/jquery.min.js +5 -0
- data/lib/hyhyhy/structure/_includes/jquery/dist/jquery.min.map +1 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/ajax.js +806 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/ajax/jsonp.js +89 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/ajax/load.js +75 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/ajax/parseJSON.js +13 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/ajax/parseXML.js +28 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/ajax/script.js +64 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/ajax/var/nonce.js +5 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/ajax/var/rquery.js +3 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/ajax/xhr.js +135 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/attributes.js +11 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/attributes/attr.js +143 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/attributes/classes.js +158 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/attributes/prop.js +96 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/attributes/support.js +35 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/attributes/val.js +163 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/callbacks.js +205 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/core.js +498 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/core/access.js +60 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/core/init.js +123 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/core/parseHTML.js +39 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/core/ready.js +97 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/core/var/rsingleTag.js +4 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/css.js +451 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/css/addGetHookIf.js +24 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/css/curCSS.js +57 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/css/defaultDisplay.js +70 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/css/hiddenVisibleSelectors.js +15 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/css/support.js +91 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/css/swap.js +28 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/css/var/cssExpand.js +3 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/css/var/getStyles.js +5 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/css/var/isHidden.js +13 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/css/var/rmargin.js +3 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/css/var/rnumnonpx.js +5 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/data.js +179 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/data/Data.js +181 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/data/accepts.js +20 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/data/var/data_priv.js +5 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/data/var/data_user.js +5 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/deferred.js +149 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/deprecated.js +13 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/dimensions.js +50 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/effects.js +649 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/effects/Tween.js +114 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/effects/animatedSelector.js +13 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/event.js +868 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/event/alias.js +39 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/event/support.js +9 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/exports/amd.js +24 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/exports/global.js +32 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/intro.js +44 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/jquery.js +36 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/manipulation.js +582 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/manipulation/_evalUrl.js +18 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/manipulation/support.js +31 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/manipulation/var/rcheckableType.js +3 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/offset.js +204 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/outro.js +1 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/queue.js +142 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/queue/delay.js +22 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/selector-native.js +172 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/selector-sizzle.js +14 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/selector.js +1 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/serialize.js +111 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/sizzle/dist/sizzle.js +2044 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/sizzle/dist/sizzle.min.js +3 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/sizzle/dist/sizzle.min.map +1 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/traversing.js +200 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/traversing/findFilter.js +100 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/traversing/var/rneedsContext.js +6 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/var/arr.js +3 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/var/class2type.js +4 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/var/concat.js +5 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/var/hasOwn.js +5 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/var/indexOf.js +5 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/var/pnum.js +3 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/var/push.js +5 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/var/rnotwhite.js +3 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/var/slice.js +5 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/var/strundefined.js +3 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/var/support.js +4 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/var/toString.js +5 -0
- data/lib/hyhyhy/structure/_includes/jquery/src/wrap.js +78 -0
- data/lib/hyhyhy/structure/_includes/katex/.arcconfig +4 -0
- data/lib/hyhyhy/structure/_includes/katex/.bower.json +14 -0
- data/lib/hyhyhy/structure/_includes/katex/.gitignore +5 -0
- data/lib/hyhyhy/structure/_includes/katex/.hyhyhy +10 -0
- data/lib/hyhyhy/structure/_includes/katex/.jshintrc +67 -0
- data/lib/hyhyhy/structure/_includes/katex/.travis.yml +4 -0
- data/lib/hyhyhy/structure/_includes/katex/CONTRIBUTING.md +112 -0
- data/lib/hyhyhy/structure/_includes/katex/LICENSE.txt +21 -0
- data/lib/hyhyhy/structure/_includes/katex/Makefile +61 -0
- data/lib/hyhyhy/structure/_includes/katex/README.md +50 -0
- data/lib/hyhyhy/structure/_includes/katex/cli.js +15 -0
- data/lib/hyhyhy/structure/_includes/katex/dockers/HuxleyTests/Dockerfile +13 -0
- data/lib/hyhyhy/structure/_includes/katex/dockers/HuxleyTests/README.md +29 -0
- data/lib/hyhyhy/structure/_includes/katex/dockers/MathJaxFonts/Dockerfile +34 -0
- data/lib/hyhyhy/structure/_includes/katex/dockers/MathJaxFonts/README.md +55 -0
- data/lib/hyhyhy/structure/_includes/katex/dockers/MathJaxFonts/copy_fonts.sh +47 -0
- data/lib/hyhyhy/structure/_includes/katex/katex.js +54 -0
- data/lib/hyhyhy/structure/_includes/katex/lint_blacklist.txt +8 -0
- data/lib/hyhyhy/structure/_includes/katex/metrics/README.md +21 -0
- data/lib/hyhyhy/structure/_includes/katex/metrics/extract_tfms.py +94 -0
- data/lib/hyhyhy/structure/_includes/katex/metrics/extract_ttfs.py +75 -0
- data/lib/hyhyhy/structure/_includes/katex/metrics/mapping.pl +997 -0
- data/lib/hyhyhy/structure/_includes/katex/metrics/parse_tfm.py +201 -0
- data/lib/hyhyhy/structure/_includes/katex/metrics/replace_line.py +17 -0
- data/lib/hyhyhy/structure/_includes/katex/package.json +30 -0
- data/lib/hyhyhy/structure/_includes/katex/server.js +77 -0
- data/lib/hyhyhy/structure/_includes/katex/src/Lexer.js +190 -0
- data/lib/hyhyhy/structure/_includes/katex/src/Options.js +85 -0
- data/lib/hyhyhy/structure/_includes/katex/src/ParseError.js +40 -0
- data/lib/hyhyhy/structure/_includes/katex/src/Parser.js +639 -0
- data/lib/hyhyhy/structure/_includes/katex/src/Style.js +126 -0
- data/lib/hyhyhy/structure/_includes/katex/src/buildCommon.js +271 -0
- data/lib/hyhyhy/structure/_includes/katex/src/buildTree.js +1167 -0
- data/lib/hyhyhy/structure/_includes/katex/src/delimiter.js +541 -0
- data/lib/hyhyhy/structure/_includes/katex/src/domTree.js +241 -0
- data/lib/hyhyhy/structure/_includes/katex/src/fontMetrics.js +129 -0
- data/lib/hyhyhy/structure/_includes/katex/src/functions.js +539 -0
- data/lib/hyhyhy/structure/_includes/katex/src/parseTree.js +17 -0
- data/lib/hyhyhy/structure/_includes/katex/src/symbols.js +1006 -0
- data/lib/hyhyhy/structure/_includes/katex/src/utils.js +97 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts.less +73 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_AMS-Regular.eot +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_AMS-Regular.ttf +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_AMS-Regular.woff +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_AMS-Regular.woff2 +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Caligraphic-Bold.eot +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Caligraphic-Regular.eot +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Fraktur-Bold.eot +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Fraktur-Bold.woff +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Fraktur-Regular.eot +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Fraktur-Regular.woff +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Greek-Bold.woff2 +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Greek-BoldItalic.woff2 +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Greek-Italic.woff2 +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Greek-Regular.woff2 +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Main-Bold.eot +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Main-Bold.ttf +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Main-Bold.woff +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Main-Bold.woff2 +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Main-Italic.eot +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Main-Italic.ttf +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Main-Italic.woff +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Main-Italic.woff2 +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Main-Regular.eot +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Main-Regular.ttf +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Main-Regular.woff +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Main-Regular.woff2 +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Math-BoldItalic.eot +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Math-BoldItalic.woff +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Math-Italic.eot +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Math-Italic.ttf +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Math-Italic.woff +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Math-Italic.woff2 +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Math-Regular.eot +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Math-Regular.ttf +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Math-Regular.woff +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Math-Regular.woff2 +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_SansSerif-Bold.eot +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_SansSerif-Bold.woff +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_SansSerif-Italic.eot +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_SansSerif-Italic.woff +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_SansSerif-Regular.eot +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_SansSerif-Regular.woff +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Script-Regular.eot +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Script-Regular.ttf +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Script-Regular.woff +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Script-Regular.woff2 +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Size1-Regular.eot +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Size1-Regular.ttf +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Size1-Regular.woff +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Size1-Regular.woff2 +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Size2-Regular.eot +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Size2-Regular.ttf +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Size2-Regular.woff +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Size2-Regular.woff2 +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Size3-Regular.eot +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Size3-Regular.ttf +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Size3-Regular.woff +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Size3-Regular.woff2 +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Size4-Regular.eot +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Size4-Regular.ttf +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Size4-Regular.woff +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Size4-Regular.woff2 +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Typewriter-Regular.eot +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Typewriter-Regular.woff +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
- data/lib/hyhyhy/structure/_includes/katex/static/index.html +17 -0
- data/lib/hyhyhy/structure/_includes/katex/static/katex.less +430 -0
- data/lib/hyhyhy/structure/_includes/katex/static/main.css +12 -0
- data/lib/hyhyhy/structure/_includes/katex/static/main.js +42 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfile.json +199 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/Accents.hux/firefox-1.png +0 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/Accents.record.json +5 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/Baseline.hux/firefox-1.png +0 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/Baseline.record.json +5 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/BasicTest.hux/firefox-1.png +0 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/BasicTest.record.json +5 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/BinomTest.hux/firefox-1.png +0 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/BinomTest.record.json +5 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/Colors.hux/firefox-1.png +0 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/Colors.record.json +5 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/DeepFontSizing.hux/firefox-1.png +0 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/DeepFontSizing.record.json +5 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/DelimiterSizing.hux/firefox-1.png +0 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/DelimiterSizing.record.json +5 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/DisplayStyle.hux/firefox-1.png +0 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/DisplayStyle.record.json +5 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/Exponents.hux/firefox-1.png +0 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/Exponents.record.json +5 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/FractionTest.hux/firefox-1.png +0 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/FractionTest.record.json +5 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/Functions.hux/firefox-1.png +0 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/Functions.record.json +5 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/GreekLetters.hux/firefox-1.png +0 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/GreekLetters.record.json +5 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/KaTeX.hux/firefox-1.png +0 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/KaTeX.record.json +5 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/Lap.hux/firefox-1.png +0 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/Lap.record.json +5 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/LeftRight.hux/firefox-1.png +0 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/LeftRight.record.json +5 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/LeftRightListStyling.hux/firefox-1.png +0 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/LeftRightListStyling.record.json +5 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/LeftRightStyleSizing.hux/firefox-1.png +0 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/LeftRightStyleSizing.record.json +5 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/NestedFractions.hux/firefox-1.png +0 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/NestedFractions.record.json +5 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/NullDelimiterInteraction.hux/firefox-1.png +0 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/NullDelimiterInteraction.record.json +5 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/OpLimits.hux/firefox-1.png +0 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/OpLimits.record.json +5 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/Overline.hux/firefox-1.png +0 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/Overline.record.json +5 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/PrimeSpacing.hux/firefox-1.png +0 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/PrimeSpacing.record.json +5 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/RlapBug.hux/firefox-1.png +0 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/RlapBug.record.json +5 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/Rule.hux/firefox-1.png +0 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/Rule.record.json +5 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/Sizing.hux/firefox-1.png +0 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/Sizing.record.json +5 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/SizingBaseline.hux/firefox-1.png +0 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/SizingBaseline.record.json +5 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/Spacing.hux/firefox-1.png +0 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/Spacing.record.json +5 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/Sqrt.hux/firefox-1.png +0 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/Sqrt.record.json +5 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/SupSubCharacterBox.hux/firefox-1.png +0 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/SupSubCharacterBox.record.json +5 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/SupSubHorizSpacing.hux/firefox-1.png +0 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/SupSubHorizSpacing.record.json +5 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/SupSubOffsets.hux/firefox-1.png +0 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/SupSubOffsets.record.json +5 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/Text.hux/firefox-1.png +0 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/Text.record.json +5 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/VerticalSpacing.hux/firefox-1.png +0 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/Huxleyfolder/VerticalSpacing.record.json +5 -0
- data/lib/hyhyhy/structure/_includes/katex/test/huxley/test.html +30 -0
- data/lib/hyhyhy/structure/_includes/katex/test/jasmine/MIT.LICENSE +20 -0
- data/lib/hyhyhy/structure/_includes/katex/test/jasmine/boot.js +120 -0
- data/lib/hyhyhy/structure/_includes/katex/test/jasmine/console.js +166 -0
- data/lib/hyhyhy/structure/_includes/katex/test/jasmine/jasmine-html.js +390 -0
- data/lib/hyhyhy/structure/_includes/katex/test/jasmine/jasmine.css +61 -0
- data/lib/hyhyhy/structure/_includes/katex/test/jasmine/jasmine.js +2593 -0
- data/lib/hyhyhy/structure/_includes/katex/test/jasmine/jasmine_favicon.png +0 -0
- data/lib/hyhyhy/structure/_includes/katex/test/katex-spec.js +1179 -0
- data/lib/hyhyhy/structure/_includes/katex/test/test.html +12 -0
- data/lib/hyhyhy/structure/_includes/metrics-graphics/.bower.json +61 -0
- data/lib/hyhyhy/structure/_includes/metrics-graphics/.hyhyhy +17 -0
- data/lib/hyhyhy/structure/_includes/metrics-graphics/LICENSE +362 -0
- data/lib/hyhyhy/structure/_includes/metrics-graphics/README.md +70 -0
- data/lib/hyhyhy/structure/_includes/metrics-graphics/bower.json +50 -0
- data/lib/hyhyhy/structure/_includes/metrics-graphics/css/metricsgraphics-demo-dark.css +640 -0
- data/lib/hyhyhy/structure/_includes/metrics-graphics/css/metricsgraphics-demo.css +176 -0
- data/lib/hyhyhy/structure/_includes/metrics-graphics/css/metricsgraphics.css +344 -0
- data/lib/hyhyhy/structure/_includes/metrics-graphics/images/missing-data-dark.png +0 -0
- data/lib/hyhyhy/structure/_includes/metrics-graphics/images/missing-data.png +0 -0
- data/lib/hyhyhy/structure/_includes/metrics-graphics/js/metricsgraphics.min.js +590 -0
- data/lib/hyhyhy/structure/_includes/metrics-graphics/package.json +35 -0
- data/lib/hyhyhy/structure/_includes/prism/.bower.json +34 -0
- data/lib/hyhyhy/structure/_includes/prism/.hyhyhy +33 -0
- data/lib/hyhyhy/structure/_includes/prism/LICENSE +21 -0
- data/lib/hyhyhy/structure/_includes/prism/README.md +22 -0
- data/lib/hyhyhy/structure/_includes/prism/bower.json +26 -0
- data/lib/hyhyhy/structure/_includes/prism/components.js +233 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-apacheconf.js +46 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-apacheconf.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-aspnet.js +49 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-aspnet.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-autohotkey.js +27 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-autohotkey.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-bash.js +24 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-bash.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-c.js +26 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-c.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-clike.js +32 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-clike.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-coffeescript.js +18 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-coffeescript.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-core.js +424 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-core.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-cpp.js +12 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-cpp.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-csharp.js +6 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-csharp.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-css-extras.js +15 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-css-extras.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-css.js +50 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-css.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-gherkin.js +13 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-gherkin.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-git.js +68 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-git.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-go.js +9 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-go.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-groovy.js +43 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-groovy.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-handlebars.js +92 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-handlebars.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-haskell.js +32 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-haskell.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-http.js +44 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-http.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-ini.js +11 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-ini.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-java.js +8 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-java.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-javascript.js +27 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-javascript.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-latex.js +6 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-latex.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-markup.js +41 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-markup.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-nasm.js +20 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-nasm.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-nsis.js +19 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-nsis.min.js +5 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-objectivec.js +5 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-objectivec.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-perl.js +112 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-perl.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-php-extras.js +11 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-php-extras.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-php.js +99 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-php.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-python.js +14 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-python.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-rip.js +29 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-rip.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-ruby.js +21 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-ruby.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-scala.js +8 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-scala.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-scheme-min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-scheme.js +24 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-scss.js +36 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-scss.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-sql.js +17 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-sql.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-swift.js +8 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-swift.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-twig.js +46 -0
- data/lib/hyhyhy/structure/_includes/prism/components/prism-twig.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/gulpfile.js +48 -0
- data/lib/hyhyhy/structure/_includes/prism/package.json +27 -0
- data/lib/hyhyhy/structure/_includes/prism/plugins/autolinker/prism-autolinker.css +3 -0
- data/lib/hyhyhy/structure/_includes/prism/plugins/autolinker/prism-autolinker.js +66 -0
- data/lib/hyhyhy/structure/_includes/prism/plugins/autolinker/prism-autolinker.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/plugins/file-highlight/prism-file-highlight.js +54 -0
- data/lib/hyhyhy/structure/_includes/prism/plugins/file-highlight/prism-file-highlight.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/plugins/ie8/prism-ie8.css +3 -0
- data/lib/hyhyhy/structure/_includes/prism/plugins/ie8/prism-ie8.js +42 -0
- data/lib/hyhyhy/structure/_includes/prism/plugins/ie8/prism-ie8.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/plugins/line-highlight/prism-line-highlight.css +47 -0
- data/lib/hyhyhy/structure/_includes/prism/plugins/line-highlight/prism-line-highlight.js +109 -0
- data/lib/hyhyhy/structure/_includes/prism/plugins/line-highlight/prism-line-highlight.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/plugins/line-numbers/prism-line-numbers.css +40 -0
- data/lib/hyhyhy/structure/_includes/prism/plugins/line-numbers/prism-line-numbers.js +24 -0
- data/lib/hyhyhy/structure/_includes/prism/plugins/line-numbers/prism-line-numbers.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/plugins/show-invisibles/prism-show-invisibles.css +17 -0
- data/lib/hyhyhy/structure/_includes/prism/plugins/show-invisibles/prism-show-invisibles.js +15 -0
- data/lib/hyhyhy/structure/_includes/prism/plugins/show-invisibles/prism-show-invisibles.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/plugins/show-language/prism-show-language.css +21 -0
- data/lib/hyhyhy/structure/_includes/prism/plugins/show-language/prism-show-language.js +16 -0
- data/lib/hyhyhy/structure/_includes/prism/plugins/show-language/prism-show-language.min.css +1 -0
- data/lib/hyhyhy/structure/_includes/prism/plugins/show-language/prism-show-language.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/plugins/wpd/prism-wpd.css +11 -0
- data/lib/hyhyhy/structure/_includes/prism/plugins/wpd/prism-wpd.js +163 -0
- data/lib/hyhyhy/structure/_includes/prism/plugins/wpd/prism-wpd.min.js +1 -0
- data/lib/hyhyhy/structure/_includes/prism/prism.js +662 -0
- data/lib/hyhyhy/structure/_includes/prism/themes/prism-coy.css +210 -0
- data/lib/hyhyhy/structure/_includes/prism/themes/prism-dark.css +122 -0
- data/lib/hyhyhy/structure/_includes/prism/themes/prism-funky.css +111 -0
- data/lib/hyhyhy/structure/_includes/prism/themes/prism-okaidia.css +114 -0
- data/lib/hyhyhy/structure/_includes/prism/themes/prism-tomorrow.css +115 -0
- data/lib/hyhyhy/structure/_includes/prism/themes/prism-twilight.css +195 -0
- data/lib/hyhyhy/structure/_includes/prism/themes/prism.css +131 -0
- data/lib/hyhyhy/structure/_includes/prism/vendor/promise.js +5 -0
- data/lib/hyhyhy/structure/_layouts/default.erb +41 -0
- data/lib/hyhyhy/structure/_slides/1.introduction.md +36 -0
- data/lib/hyhyhy/structure/_slides/2.packages.md +52 -0
- data/lib/hyhyhy/structure/_slides/3.usage.md +146 -0
- data/lib/hyhyhy/version.rb +5 -0
- metadata +747 -0
@@ -0,0 +1,126 @@
|
|
1
|
+
/**
|
2
|
+
* This file contains information and classes for the various kinds of styles
|
3
|
+
* used in TeX. It provides a generic `Style` class, which holds information
|
4
|
+
* about a specific style. It then provides instances of all the different kinds
|
5
|
+
* of styles possible, and provides functions to move between them and get
|
6
|
+
* information about them.
|
7
|
+
*/
|
8
|
+
|
9
|
+
/**
|
10
|
+
* The main style class. Contains a unique id for the style, a size (which is
|
11
|
+
* the same for cramped and uncramped version of a style), a cramped flag, and a
|
12
|
+
* size multiplier, which gives the size difference between a style and
|
13
|
+
* textstyle.
|
14
|
+
*/
|
15
|
+
function Style(id, size, multiplier, cramped) {
|
16
|
+
this.id = id;
|
17
|
+
this.size = size;
|
18
|
+
this.cramped = cramped;
|
19
|
+
this.sizeMultiplier = multiplier;
|
20
|
+
}
|
21
|
+
|
22
|
+
/**
|
23
|
+
* Get the style of a superscript given a base in the current style.
|
24
|
+
*/
|
25
|
+
Style.prototype.sup = function() {
|
26
|
+
return styles[sup[this.id]];
|
27
|
+
};
|
28
|
+
|
29
|
+
/**
|
30
|
+
* Get the style of a subscript given a base in the current style.
|
31
|
+
*/
|
32
|
+
Style.prototype.sub = function() {
|
33
|
+
return styles[sub[this.id]];
|
34
|
+
};
|
35
|
+
|
36
|
+
/**
|
37
|
+
* Get the style of a fraction numerator given the fraction in the current
|
38
|
+
* style.
|
39
|
+
*/
|
40
|
+
Style.prototype.fracNum = function() {
|
41
|
+
return styles[fracNum[this.id]];
|
42
|
+
};
|
43
|
+
|
44
|
+
/**
|
45
|
+
* Get the style of a fraction denominator given the fraction in the current
|
46
|
+
* style.
|
47
|
+
*/
|
48
|
+
Style.prototype.fracDen = function() {
|
49
|
+
return styles[fracDen[this.id]];
|
50
|
+
};
|
51
|
+
|
52
|
+
/**
|
53
|
+
* Get the cramped version of a style (in particular, cramping a cramped style
|
54
|
+
* doesn't change the style).
|
55
|
+
*/
|
56
|
+
Style.prototype.cramp = function() {
|
57
|
+
return styles[cramp[this.id]];
|
58
|
+
};
|
59
|
+
|
60
|
+
/**
|
61
|
+
* HTML class name, like "displaystyle cramped"
|
62
|
+
*/
|
63
|
+
Style.prototype.cls = function() {
|
64
|
+
return sizeNames[this.size] + (this.cramped ? " cramped" : " uncramped");
|
65
|
+
};
|
66
|
+
|
67
|
+
/**
|
68
|
+
* HTML Reset class name, like "reset-textstyle"
|
69
|
+
*/
|
70
|
+
Style.prototype.reset = function() {
|
71
|
+
return resetNames[this.size];
|
72
|
+
};
|
73
|
+
|
74
|
+
// IDs of the different styles
|
75
|
+
var D = 0;
|
76
|
+
var Dc = 1;
|
77
|
+
var T = 2;
|
78
|
+
var Tc = 3;
|
79
|
+
var S = 4;
|
80
|
+
var Sc = 5;
|
81
|
+
var SS = 6;
|
82
|
+
var SSc = 7;
|
83
|
+
|
84
|
+
// String names for the different sizes
|
85
|
+
var sizeNames = [
|
86
|
+
"displaystyle textstyle",
|
87
|
+
"textstyle",
|
88
|
+
"scriptstyle",
|
89
|
+
"scriptscriptstyle"
|
90
|
+
];
|
91
|
+
|
92
|
+
// Reset names for the different sizes
|
93
|
+
var resetNames = [
|
94
|
+
"reset-textstyle",
|
95
|
+
"reset-textstyle",
|
96
|
+
"reset-scriptstyle",
|
97
|
+
"reset-scriptscriptstyle"
|
98
|
+
];
|
99
|
+
|
100
|
+
// Instances of the different styles
|
101
|
+
var styles = [
|
102
|
+
new Style(D, 0, 1.0, false),
|
103
|
+
new Style(Dc, 0, 1.0, true),
|
104
|
+
new Style(T, 1, 1.0, false),
|
105
|
+
new Style(Tc, 1, 1.0, true),
|
106
|
+
new Style(S, 2, 0.7, false),
|
107
|
+
new Style(Sc, 2, 0.7, true),
|
108
|
+
new Style(SS, 3, 0.5, false),
|
109
|
+
new Style(SSc, 3, 0.5, true)
|
110
|
+
];
|
111
|
+
|
112
|
+
// Lookup tables for switching from one style to another
|
113
|
+
var sup = [S, Sc, S, Sc, SS, SSc, SS, SSc];
|
114
|
+
var sub = [Sc, Sc, Sc, Sc, SSc, SSc, SSc, SSc];
|
115
|
+
var fracNum = [T, Tc, S, Sc, SS, SSc, SS, SSc];
|
116
|
+
var fracDen = [Tc, Tc, Sc, Sc, SSc, SSc, SSc, SSc];
|
117
|
+
var cramp = [Dc, Dc, Tc, Tc, Sc, Sc, SSc, SSc];
|
118
|
+
|
119
|
+
// We only export some of the styles. Also, we don't export the `Style` class so
|
120
|
+
// no more styles can be generated.
|
121
|
+
module.exports = {
|
122
|
+
DISPLAY: styles[D],
|
123
|
+
TEXT: styles[T],
|
124
|
+
SCRIPT: styles[S],
|
125
|
+
SCRIPTSCRIPT: styles[SS]
|
126
|
+
};
|
@@ -0,0 +1,271 @@
|
|
1
|
+
/**
|
2
|
+
* This module contains general functions that can be used for building
|
3
|
+
* different kinds of domTree nodes in a consistent manner.
|
4
|
+
*/
|
5
|
+
|
6
|
+
var domTree = require("./domTree");
|
7
|
+
var fontMetrics = require("./fontMetrics");
|
8
|
+
var symbols = require("./symbols");
|
9
|
+
|
10
|
+
/**
|
11
|
+
* Makes a symbolNode after translation via the list of symbols in symbols.js.
|
12
|
+
* Correctly pulls out metrics for the character, and optionally takes a list of
|
13
|
+
* classes to be attached to the node.
|
14
|
+
*/
|
15
|
+
var makeSymbol = function(value, style, mode, color, classes) {
|
16
|
+
// Replace the value with its replaced value from symbol.js
|
17
|
+
if (symbols[mode][value] && symbols[mode][value].replace) {
|
18
|
+
value = symbols[mode][value].replace;
|
19
|
+
}
|
20
|
+
|
21
|
+
var metrics = fontMetrics.getCharacterMetrics(value, style);
|
22
|
+
|
23
|
+
var symbolNode;
|
24
|
+
if (metrics) {
|
25
|
+
symbolNode = new domTree.symbolNode(
|
26
|
+
value, metrics.height, metrics.depth, metrics.italic, metrics.skew,
|
27
|
+
classes);
|
28
|
+
} else {
|
29
|
+
// TODO(emily): Figure out a good way to only print this in development
|
30
|
+
typeof console !== "undefined" && console.warn(
|
31
|
+
"No character metrics for '" + value + "' in style '" +
|
32
|
+
style + "'");
|
33
|
+
symbolNode = new domTree.symbolNode(value, 0, 0, 0, 0, classes);
|
34
|
+
}
|
35
|
+
|
36
|
+
if (color) {
|
37
|
+
symbolNode.style.color = color;
|
38
|
+
}
|
39
|
+
|
40
|
+
return symbolNode;
|
41
|
+
};
|
42
|
+
|
43
|
+
/**
|
44
|
+
* Makes a symbol in the italic math font.
|
45
|
+
*/
|
46
|
+
var mathit = function(value, mode, color, classes) {
|
47
|
+
return makeSymbol(
|
48
|
+
value, "Math-Italic", mode, color, classes.concat(["mathit"]));
|
49
|
+
};
|
50
|
+
|
51
|
+
/**
|
52
|
+
* Makes a symbol in the upright roman font.
|
53
|
+
*/
|
54
|
+
var mathrm = function(value, mode, color, classes) {
|
55
|
+
// Decide what font to render the symbol in by its entry in the symbols
|
56
|
+
// table.
|
57
|
+
if (symbols[mode][value].font === "main") {
|
58
|
+
return makeSymbol(value, "Main-Regular", mode, color, classes);
|
59
|
+
} else {
|
60
|
+
return makeSymbol(
|
61
|
+
value, "AMS-Regular", mode, color, classes.concat(["amsrm"]));
|
62
|
+
}
|
63
|
+
};
|
64
|
+
|
65
|
+
/**
|
66
|
+
* Calculate the height, depth, and maxFontSize of an element based on its
|
67
|
+
* children.
|
68
|
+
*/
|
69
|
+
var sizeElementFromChildren = function(elem) {
|
70
|
+
var height = 0;
|
71
|
+
var depth = 0;
|
72
|
+
var maxFontSize = 0;
|
73
|
+
|
74
|
+
if (elem.children) {
|
75
|
+
for (var i = 0; i < elem.children.length; i++) {
|
76
|
+
if (elem.children[i].height > height) {
|
77
|
+
height = elem.children[i].height;
|
78
|
+
}
|
79
|
+
if (elem.children[i].depth > depth) {
|
80
|
+
depth = elem.children[i].depth;
|
81
|
+
}
|
82
|
+
if (elem.children[i].maxFontSize > maxFontSize) {
|
83
|
+
maxFontSize = elem.children[i].maxFontSize;
|
84
|
+
}
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
elem.height = height;
|
89
|
+
elem.depth = depth;
|
90
|
+
elem.maxFontSize = maxFontSize;
|
91
|
+
};
|
92
|
+
|
93
|
+
/**
|
94
|
+
* Makes a span with the given list of classes, list of children, and color.
|
95
|
+
*/
|
96
|
+
var makeSpan = function(classes, children, color) {
|
97
|
+
var span = new domTree.span(classes, children);
|
98
|
+
|
99
|
+
sizeElementFromChildren(span);
|
100
|
+
|
101
|
+
if (color) {
|
102
|
+
span.style.color = color;
|
103
|
+
}
|
104
|
+
|
105
|
+
return span;
|
106
|
+
};
|
107
|
+
|
108
|
+
/**
|
109
|
+
* Makes a document fragment with the given list of children.
|
110
|
+
*/
|
111
|
+
var makeFragment = function(children) {
|
112
|
+
var fragment = new domTree.documentFragment(children);
|
113
|
+
|
114
|
+
sizeElementFromChildren(fragment);
|
115
|
+
|
116
|
+
return fragment;
|
117
|
+
};
|
118
|
+
|
119
|
+
/**
|
120
|
+
* Makes an element placed in each of the vlist elements to ensure that each
|
121
|
+
* element has the same max font size. To do this, we create a zero-width space
|
122
|
+
* with the correct font size.
|
123
|
+
*/
|
124
|
+
var makeFontSizer = function(options, fontSize) {
|
125
|
+
var fontSizeInner = makeSpan([], [new domTree.symbolNode("\u200b")]);
|
126
|
+
fontSizeInner.style.fontSize = (fontSize / options.style.sizeMultiplier) + "em";
|
127
|
+
|
128
|
+
var fontSizer = makeSpan(
|
129
|
+
["fontsize-ensurer", "reset-" + options.size, "size5"],
|
130
|
+
[fontSizeInner]);
|
131
|
+
|
132
|
+
return fontSizer;
|
133
|
+
};
|
134
|
+
|
135
|
+
/**
|
136
|
+
* Makes a vertical list by stacking elements and kerns on top of each other.
|
137
|
+
* Allows for many different ways of specifying the positioning method.
|
138
|
+
*
|
139
|
+
* Arguments:
|
140
|
+
* - children: A list of child or kern nodes to be stacked on top of each other
|
141
|
+
* (i.e. the first element will be at the bottom, and the last at
|
142
|
+
* the top). Element nodes are specified as
|
143
|
+
* {type: "elem", elem: node}
|
144
|
+
* while kern nodes are specified as
|
145
|
+
* {type: "kern", size: size}
|
146
|
+
* - positionType: The method by which the vlist should be positioned. Valid
|
147
|
+
* values are:
|
148
|
+
* - "individualShift": The children list only contains elem
|
149
|
+
* nodes, and each node contains an extra
|
150
|
+
* "shift" value of how much it should be
|
151
|
+
* shifted (note that shifting is always
|
152
|
+
* moving downwards). positionData is
|
153
|
+
* ignored.
|
154
|
+
* - "top": The positionData specifies the topmost point of
|
155
|
+
* the vlist (note this is expected to be a height,
|
156
|
+
* so positive values move up)
|
157
|
+
* - "bottom": The positionData specifies the bottommost point
|
158
|
+
* of the vlist (note this is expected to be a
|
159
|
+
* depth, so positive values move down
|
160
|
+
* - "shift": The vlist will be positioned such that its
|
161
|
+
* baseline is positionData away from the baseline
|
162
|
+
* of the first child. Positive values move
|
163
|
+
* downwards.
|
164
|
+
* - "firstBaseline": The vlist will be positioned such that
|
165
|
+
* its baseline is aligned with the
|
166
|
+
* baseline of the first child.
|
167
|
+
* positionData is ignored. (this is
|
168
|
+
* equivalent to "shift" with
|
169
|
+
* positionData=0)
|
170
|
+
* - positionData: Data used in different ways depending on positionType
|
171
|
+
* - options: An Options object
|
172
|
+
*
|
173
|
+
*/
|
174
|
+
var makeVList = function(children, positionType, positionData, options) {
|
175
|
+
var depth;
|
176
|
+
var currPos;
|
177
|
+
var i;
|
178
|
+
if (positionType === "individualShift") {
|
179
|
+
var oldChildren = children;
|
180
|
+
children = [oldChildren[0]];
|
181
|
+
|
182
|
+
// Add in kerns to the list of children to get each element to be
|
183
|
+
// shifted to the correct specified shift
|
184
|
+
depth = -oldChildren[0].shift - oldChildren[0].elem.depth;
|
185
|
+
currPos = depth;
|
186
|
+
for (i = 1; i < oldChildren.length; i++) {
|
187
|
+
var diff = -oldChildren[i].shift - currPos -
|
188
|
+
oldChildren[i].elem.depth;
|
189
|
+
var size = diff -
|
190
|
+
(oldChildren[i - 1].elem.height +
|
191
|
+
oldChildren[i - 1].elem.depth);
|
192
|
+
|
193
|
+
currPos = currPos + diff;
|
194
|
+
|
195
|
+
children.push({type: "kern", size: size});
|
196
|
+
children.push(oldChildren[i]);
|
197
|
+
}
|
198
|
+
} else if (positionType === "top") {
|
199
|
+
// We always start at the bottom, so calculate the bottom by adding up
|
200
|
+
// all the sizes
|
201
|
+
var bottom = positionData;
|
202
|
+
for (i = 0; i < children.length; i++) {
|
203
|
+
if (children[i].type === "kern") {
|
204
|
+
bottom -= children[i].size;
|
205
|
+
} else {
|
206
|
+
bottom -= children[i].elem.height + children[i].elem.depth;
|
207
|
+
}
|
208
|
+
}
|
209
|
+
depth = bottom;
|
210
|
+
} else if (positionType === "bottom") {
|
211
|
+
depth = -positionData;
|
212
|
+
} else if (positionType === "shift") {
|
213
|
+
depth = -children[0].elem.depth - positionData;
|
214
|
+
} else if (positionType === "firstBaseline") {
|
215
|
+
depth = -children[0].elem.depth;
|
216
|
+
} else {
|
217
|
+
depth = 0;
|
218
|
+
}
|
219
|
+
|
220
|
+
// Make the fontSizer
|
221
|
+
var maxFontSize = 0;
|
222
|
+
for (i = 0; i < children.length; i++) {
|
223
|
+
if (children[i].type === "elem") {
|
224
|
+
maxFontSize = Math.max(maxFontSize, children[i].elem.maxFontSize);
|
225
|
+
}
|
226
|
+
}
|
227
|
+
var fontSizer = makeFontSizer(options, maxFontSize);
|
228
|
+
|
229
|
+
// Create a new list of actual children at the correct offsets
|
230
|
+
var realChildren = [];
|
231
|
+
currPos = depth;
|
232
|
+
for (i = 0; i < children.length; i++) {
|
233
|
+
if (children[i].type === "kern") {
|
234
|
+
currPos += children[i].size;
|
235
|
+
} else {
|
236
|
+
var child = children[i].elem;
|
237
|
+
|
238
|
+
var shift = -child.depth - currPos;
|
239
|
+
currPos += child.height + child.depth;
|
240
|
+
|
241
|
+
var childWrap = makeSpan([], [fontSizer, child]);
|
242
|
+
childWrap.height -= shift;
|
243
|
+
childWrap.depth += shift;
|
244
|
+
childWrap.style.top = shift + "em";
|
245
|
+
|
246
|
+
realChildren.push(childWrap);
|
247
|
+
}
|
248
|
+
}
|
249
|
+
|
250
|
+
// Add in an element at the end with no offset to fix the calculation of
|
251
|
+
// baselines in some browsers (namely IE, sometimes safari)
|
252
|
+
var baselineFix = makeSpan(
|
253
|
+
["baseline-fix"], [fontSizer, new domTree.symbolNode("\u200b")]);
|
254
|
+
realChildren.push(baselineFix);
|
255
|
+
|
256
|
+
var vlist = makeSpan(["vlist"], realChildren);
|
257
|
+
// Fix the final height and depth, in case there were kerns at the ends
|
258
|
+
// since the makeSpan calculation won't take that in to account.
|
259
|
+
vlist.height = Math.max(currPos, vlist.height);
|
260
|
+
vlist.depth = Math.max(-depth, vlist.depth);
|
261
|
+
return vlist;
|
262
|
+
};
|
263
|
+
|
264
|
+
module.exports = {
|
265
|
+
makeSymbol: makeSymbol,
|
266
|
+
mathit: mathit,
|
267
|
+
mathrm: mathrm,
|
268
|
+
makeSpan: makeSpan,
|
269
|
+
makeFragment: makeFragment,
|
270
|
+
makeVList: makeVList
|
271
|
+
};
|
@@ -0,0 +1,1167 @@
|
|
1
|
+
/**
|
2
|
+
* This file does the main work of building a domTree structure from a parse
|
3
|
+
* tree. The entry point is the `buildTree` function, which takes a parse tree.
|
4
|
+
* Then, the buildExpression, buildGroup, and various groupTypes functions are
|
5
|
+
* called, to produce a final tree.
|
6
|
+
*/
|
7
|
+
|
8
|
+
var Options = require("./Options");
|
9
|
+
var ParseError = require("./ParseError");
|
10
|
+
var Style = require("./Style");
|
11
|
+
|
12
|
+
var buildCommon = require("./buildCommon");
|
13
|
+
var delimiter = require("./delimiter");
|
14
|
+
var domTree = require("./domTree");
|
15
|
+
var fontMetrics = require("./fontMetrics");
|
16
|
+
var utils = require("./utils");
|
17
|
+
|
18
|
+
var makeSpan = buildCommon.makeSpan;
|
19
|
+
|
20
|
+
/**
|
21
|
+
* Take a list of nodes, build them in order, and return a list of the built
|
22
|
+
* nodes. This function handles the `prev` node correctly, and passes the
|
23
|
+
* previous element from the list as the prev of the next element.
|
24
|
+
*/
|
25
|
+
var buildExpression = function(expression, options, prev) {
|
26
|
+
var groups = [];
|
27
|
+
for (var i = 0; i < expression.length; i++) {
|
28
|
+
var group = expression[i];
|
29
|
+
groups.push(buildGroup(group, options, prev));
|
30
|
+
prev = group;
|
31
|
+
}
|
32
|
+
return groups;
|
33
|
+
};
|
34
|
+
|
35
|
+
// List of types used by getTypeOfGroup
|
36
|
+
var groupToType = {
|
37
|
+
mathord: "mord",
|
38
|
+
textord: "mord",
|
39
|
+
bin: "mbin",
|
40
|
+
rel: "mrel",
|
41
|
+
text: "mord",
|
42
|
+
open: "mopen",
|
43
|
+
close: "mclose",
|
44
|
+
inner: "minner",
|
45
|
+
frac: "minner",
|
46
|
+
spacing: "mord",
|
47
|
+
punct: "mpunct",
|
48
|
+
ordgroup: "mord",
|
49
|
+
op: "mop",
|
50
|
+
katex: "mord",
|
51
|
+
overline: "mord",
|
52
|
+
rule: "mord",
|
53
|
+
leftright: "minner",
|
54
|
+
sqrt: "mord",
|
55
|
+
accent: "mord"
|
56
|
+
};
|
57
|
+
|
58
|
+
/**
|
59
|
+
* Gets the final math type of an expression, given its group type. This type is
|
60
|
+
* used to determine spacing between elements, and affects bin elements by
|
61
|
+
* causing them to change depending on what types are around them. This type
|
62
|
+
* must be attached to the outermost node of an element as a CSS class so that
|
63
|
+
* spacing with its surrounding elements works correctly.
|
64
|
+
*
|
65
|
+
* Some elements can be mapped one-to-one from group type to math type, and
|
66
|
+
* those are listed in the `groupToType` table.
|
67
|
+
*
|
68
|
+
* Others (usually elements that wrap around other elements) often have
|
69
|
+
* recursive definitions, and thus call `getTypeOfGroup` on their inner
|
70
|
+
* elements.
|
71
|
+
*/
|
72
|
+
var getTypeOfGroup = function(group) {
|
73
|
+
if (group == null) {
|
74
|
+
// Like when typesetting $^3$
|
75
|
+
return groupToType.mathord;
|
76
|
+
} else if (group.type === "supsub") {
|
77
|
+
return getTypeOfGroup(group.value.base);
|
78
|
+
} else if (group.type === "llap" || group.type === "rlap") {
|
79
|
+
return getTypeOfGroup(group.value);
|
80
|
+
} else if (group.type === "color") {
|
81
|
+
return getTypeOfGroup(group.value.value);
|
82
|
+
} else if (group.type === "sizing") {
|
83
|
+
return getTypeOfGroup(group.value.value);
|
84
|
+
} else if (group.type === "styling") {
|
85
|
+
return getTypeOfGroup(group.value.value);
|
86
|
+
} else if (group.type === "delimsizing") {
|
87
|
+
return groupToType[group.value.delimType];
|
88
|
+
} else {
|
89
|
+
return groupToType[group.type];
|
90
|
+
}
|
91
|
+
};
|
92
|
+
|
93
|
+
/**
|
94
|
+
* Sometimes, groups perform special rules when they have superscripts or
|
95
|
+
* subscripts attached to them. This function lets the `supsub` group know that
|
96
|
+
* its inner element should handle the superscripts and subscripts instead of
|
97
|
+
* handling them itself.
|
98
|
+
*/
|
99
|
+
var shouldHandleSupSub = function(group, options) {
|
100
|
+
if (!group) {
|
101
|
+
return false;
|
102
|
+
} else if (group.type === "op") {
|
103
|
+
// Operators handle supsubs differently when they have limits
|
104
|
+
// (e.g. `\displaystyle\sum_2^3`)
|
105
|
+
return group.value.limits && options.style.size === Style.DISPLAY.size;
|
106
|
+
} else if (group.type === "accent") {
|
107
|
+
return isCharacterBox(group.value.base);
|
108
|
+
} else {
|
109
|
+
return null;
|
110
|
+
}
|
111
|
+
};
|
112
|
+
|
113
|
+
/**
|
114
|
+
* Sometimes we want to pull out the innermost element of a group. In most
|
115
|
+
* cases, this will just be the group itself, but when ordgroups and colors have
|
116
|
+
* a single element, we want to pull that out.
|
117
|
+
*/
|
118
|
+
var getBaseElem = function(group) {
|
119
|
+
if (!group) {
|
120
|
+
return false;
|
121
|
+
} else if (group.type === "ordgroup") {
|
122
|
+
if (group.value.length === 1) {
|
123
|
+
return getBaseElem(group.value[0]);
|
124
|
+
} else {
|
125
|
+
return group;
|
126
|
+
}
|
127
|
+
} else if (group.type === "color") {
|
128
|
+
if (group.value.value.length === 1) {
|
129
|
+
return getBaseElem(group.value.value[0]);
|
130
|
+
} else {
|
131
|
+
return group;
|
132
|
+
}
|
133
|
+
} else {
|
134
|
+
return group;
|
135
|
+
}
|
136
|
+
};
|
137
|
+
|
138
|
+
/**
|
139
|
+
* TeXbook algorithms often reference "character boxes", which are simply groups
|
140
|
+
* with a single character in them. To decide if something is a character box,
|
141
|
+
* we find its innermost group, and see if it is a single character.
|
142
|
+
*/
|
143
|
+
var isCharacterBox = function(group) {
|
144
|
+
var baseElem = getBaseElem(group);
|
145
|
+
|
146
|
+
// These are all they types of groups which hold single characters
|
147
|
+
return baseElem.type === "mathord" ||
|
148
|
+
baseElem.type === "textord" ||
|
149
|
+
baseElem.type === "bin" ||
|
150
|
+
baseElem.type === "rel" ||
|
151
|
+
baseElem.type === "inner" ||
|
152
|
+
baseElem.type === "open" ||
|
153
|
+
baseElem.type === "close" ||
|
154
|
+
baseElem.type === "punct";
|
155
|
+
};
|
156
|
+
|
157
|
+
/**
|
158
|
+
* This is a map of group types to the function used to handle that type.
|
159
|
+
* Simpler types come at the beginning, while complicated types come afterwards.
|
160
|
+
*/
|
161
|
+
var groupTypes = {
|
162
|
+
mathord: function(group, options, prev) {
|
163
|
+
return buildCommon.mathit(
|
164
|
+
group.value, group.mode, options.getColor(), ["mord"]);
|
165
|
+
},
|
166
|
+
|
167
|
+
textord: function(group, options, prev) {
|
168
|
+
return buildCommon.mathrm(
|
169
|
+
group.value, group.mode, options.getColor(), ["mord"]);
|
170
|
+
},
|
171
|
+
|
172
|
+
bin: function(group, options, prev) {
|
173
|
+
var className = "mbin";
|
174
|
+
// Pull out the most recent element. Do some special handling to find
|
175
|
+
// things at the end of a \color group. Note that we don't use the same
|
176
|
+
// logic for ordgroups (which count as ords).
|
177
|
+
var prevAtom = prev;
|
178
|
+
while (prevAtom && prevAtom.type == "color") {
|
179
|
+
var atoms = prevAtom.value.value;
|
180
|
+
prevAtom = atoms[atoms.length - 1];
|
181
|
+
}
|
182
|
+
// See TeXbook pg. 442-446, Rules 5 and 6, and the text before Rule 19.
|
183
|
+
// Here, we determine whether the bin should turn into an ord. We
|
184
|
+
// currently only apply Rule 5.
|
185
|
+
if (!prev || utils.contains(["mbin", "mopen", "mrel", "mop", "mpunct"],
|
186
|
+
getTypeOfGroup(prevAtom))) {
|
187
|
+
group.type = "textord";
|
188
|
+
className = "mord";
|
189
|
+
}
|
190
|
+
|
191
|
+
return buildCommon.mathrm(
|
192
|
+
group.value, group.mode, options.getColor(), [className]);
|
193
|
+
},
|
194
|
+
|
195
|
+
rel: function(group, options, prev) {
|
196
|
+
return buildCommon.mathrm(
|
197
|
+
group.value, group.mode, options.getColor(), ["mrel"]);
|
198
|
+
},
|
199
|
+
|
200
|
+
open: function(group, options, prev) {
|
201
|
+
return buildCommon.mathrm(
|
202
|
+
group.value, group.mode, options.getColor(), ["mopen"]);
|
203
|
+
},
|
204
|
+
|
205
|
+
close: function(group, options, prev) {
|
206
|
+
return buildCommon.mathrm(
|
207
|
+
group.value, group.mode, options.getColor(), ["mclose"]);
|
208
|
+
},
|
209
|
+
|
210
|
+
inner: function(group, options, prev) {
|
211
|
+
return buildCommon.mathrm(
|
212
|
+
group.value, group.mode, options.getColor(), ["minner"]);
|
213
|
+
},
|
214
|
+
|
215
|
+
punct: function(group, options, prev) {
|
216
|
+
return buildCommon.mathrm(
|
217
|
+
group.value, group.mode, options.getColor(), ["mpunct"]);
|
218
|
+
},
|
219
|
+
|
220
|
+
ordgroup: function(group, options, prev) {
|
221
|
+
return makeSpan(
|
222
|
+
["mord", options.style.cls()],
|
223
|
+
buildExpression(group.value, options.reset())
|
224
|
+
);
|
225
|
+
},
|
226
|
+
|
227
|
+
text: function(group, options, prev) {
|
228
|
+
return makeSpan(["text", "mord", options.style.cls()],
|
229
|
+
buildExpression(group.value.body, options.reset()));
|
230
|
+
},
|
231
|
+
|
232
|
+
color: function(group, options, prev) {
|
233
|
+
var elements = buildExpression(
|
234
|
+
group.value.value,
|
235
|
+
options.withColor(group.value.color),
|
236
|
+
prev
|
237
|
+
);
|
238
|
+
|
239
|
+
// \color isn't supposed to affect the type of the elements it contains.
|
240
|
+
// To accomplish this, we wrap the results in a fragment, so the inner
|
241
|
+
// elements will be able to directly interact with their neighbors. For
|
242
|
+
// example, `\color{red}{2 +} 3` has the same spacing as `2 + 3`
|
243
|
+
return new buildCommon.makeFragment(elements);
|
244
|
+
},
|
245
|
+
|
246
|
+
supsub: function(group, options, prev) {
|
247
|
+
// Superscript and subscripts are handled in the TeXbook on page
|
248
|
+
// 445-446, rules 18(a-f).
|
249
|
+
|
250
|
+
// Here is where we defer to the inner group if it should handle
|
251
|
+
// superscripts and subscripts itself.
|
252
|
+
if (shouldHandleSupSub(group.value.base, options)) {
|
253
|
+
return groupTypes[group.value.base.type](group, options, prev);
|
254
|
+
}
|
255
|
+
|
256
|
+
var base = buildGroup(group.value.base, options.reset());
|
257
|
+
var supmid, submid, sup, sub;
|
258
|
+
|
259
|
+
if (group.value.sup) {
|
260
|
+
sup = buildGroup(group.value.sup,
|
261
|
+
options.withStyle(options.style.sup()));
|
262
|
+
supmid = makeSpan(
|
263
|
+
[options.style.reset(), options.style.sup().cls()], [sup]);
|
264
|
+
}
|
265
|
+
|
266
|
+
if (group.value.sub) {
|
267
|
+
sub = buildGroup(group.value.sub,
|
268
|
+
options.withStyle(options.style.sub()));
|
269
|
+
submid = makeSpan(
|
270
|
+
[options.style.reset(), options.style.sub().cls()], [sub]);
|
271
|
+
}
|
272
|
+
|
273
|
+
// Rule 18a
|
274
|
+
var supShift, subShift;
|
275
|
+
if (isCharacterBox(group.value.base)) {
|
276
|
+
supShift = 0;
|
277
|
+
subShift = 0;
|
278
|
+
} else {
|
279
|
+
supShift = base.height - fontMetrics.metrics.supDrop;
|
280
|
+
subShift = base.depth + fontMetrics.metrics.subDrop;
|
281
|
+
}
|
282
|
+
|
283
|
+
// Rule 18c
|
284
|
+
var minSupShift;
|
285
|
+
if (options.style === Style.DISPLAY) {
|
286
|
+
minSupShift = fontMetrics.metrics.sup1;
|
287
|
+
} else if (options.style.cramped) {
|
288
|
+
minSupShift = fontMetrics.metrics.sup3;
|
289
|
+
} else {
|
290
|
+
minSupShift = fontMetrics.metrics.sup2;
|
291
|
+
}
|
292
|
+
|
293
|
+
// scriptspace is a font-size-independent size, so scale it
|
294
|
+
// appropriately
|
295
|
+
var multiplier = Style.TEXT.sizeMultiplier *
|
296
|
+
options.style.sizeMultiplier;
|
297
|
+
var scriptspace =
|
298
|
+
(0.5 / fontMetrics.metrics.ptPerEm) / multiplier + "em";
|
299
|
+
|
300
|
+
var supsub;
|
301
|
+
if (!group.value.sup) {
|
302
|
+
// Rule 18b
|
303
|
+
subShift = Math.max(
|
304
|
+
subShift, fontMetrics.metrics.sub1,
|
305
|
+
sub.height - 0.8 * fontMetrics.metrics.xHeight);
|
306
|
+
|
307
|
+
supsub = buildCommon.makeVList([
|
308
|
+
{type: "elem", elem: submid}
|
309
|
+
], "shift", subShift, options);
|
310
|
+
|
311
|
+
supsub.children[0].style.marginRight = scriptspace;
|
312
|
+
|
313
|
+
// Subscripts shouldn't be shifted by the base's italic correction.
|
314
|
+
// Account for that by shifting the subscript back the appropriate
|
315
|
+
// amount. Note we only do this when the base is a single symbol.
|
316
|
+
if (base instanceof domTree.symbolNode) {
|
317
|
+
supsub.children[0].style.marginLeft = -base.italic + "em";
|
318
|
+
}
|
319
|
+
} else if (!group.value.sub) {
|
320
|
+
// Rule 18c, d
|
321
|
+
supShift = Math.max(supShift, minSupShift,
|
322
|
+
sup.depth + 0.25 * fontMetrics.metrics.xHeight);
|
323
|
+
|
324
|
+
supsub = buildCommon.makeVList([
|
325
|
+
{type: "elem", elem: supmid}
|
326
|
+
], "shift", -supShift, options);
|
327
|
+
|
328
|
+
supsub.children[0].style.marginRight = scriptspace;
|
329
|
+
} else {
|
330
|
+
supShift = Math.max(
|
331
|
+
supShift, minSupShift,
|
332
|
+
sup.depth + 0.25 * fontMetrics.metrics.xHeight);
|
333
|
+
subShift = Math.max(subShift, fontMetrics.metrics.sub2);
|
334
|
+
|
335
|
+
var ruleWidth = fontMetrics.metrics.defaultRuleThickness;
|
336
|
+
|
337
|
+
// Rule 18e
|
338
|
+
if ((supShift - sup.depth) - (sub.height - subShift) <
|
339
|
+
4 * ruleWidth) {
|
340
|
+
subShift = 4 * ruleWidth - (supShift - sup.depth) + sub.height;
|
341
|
+
var psi = 0.8 * fontMetrics.metrics.xHeight -
|
342
|
+
(supShift - sup.depth);
|
343
|
+
if (psi > 0) {
|
344
|
+
supShift += psi;
|
345
|
+
subShift -= psi;
|
346
|
+
}
|
347
|
+
}
|
348
|
+
|
349
|
+
supsub = buildCommon.makeVList([
|
350
|
+
{type: "elem", elem: submid, shift: subShift},
|
351
|
+
{type: "elem", elem: supmid, shift: -supShift}
|
352
|
+
], "individualShift", null, options);
|
353
|
+
|
354
|
+
// See comment above about subscripts not being shifted
|
355
|
+
if (base instanceof domTree.symbolNode) {
|
356
|
+
supsub.children[0].style.marginLeft = -base.italic + "em";
|
357
|
+
}
|
358
|
+
|
359
|
+
supsub.children[0].style.marginRight = scriptspace;
|
360
|
+
supsub.children[1].style.marginRight = scriptspace;
|
361
|
+
}
|
362
|
+
|
363
|
+
return makeSpan([getTypeOfGroup(group.value.base)],
|
364
|
+
[base, supsub]);
|
365
|
+
},
|
366
|
+
|
367
|
+
genfrac: function(group, options, prev) {
|
368
|
+
// Fractions are handled in the TeXbook on pages 444-445, rules 15(a-e).
|
369
|
+
// Figure out what style this fraction should be in based on the
|
370
|
+
// function used
|
371
|
+
var fstyle = options.style;
|
372
|
+
if (group.value.size === "display") {
|
373
|
+
fstyle = Style.DISPLAY;
|
374
|
+
} else if (group.value.size === "text") {
|
375
|
+
fstyle = Style.TEXT;
|
376
|
+
}
|
377
|
+
|
378
|
+
var nstyle = fstyle.fracNum();
|
379
|
+
var dstyle = fstyle.fracDen();
|
380
|
+
|
381
|
+
var numer = buildGroup(group.value.numer, options.withStyle(nstyle));
|
382
|
+
var numerreset = makeSpan([fstyle.reset(), nstyle.cls()], [numer]);
|
383
|
+
|
384
|
+
var denom = buildGroup(group.value.denom, options.withStyle(dstyle));
|
385
|
+
var denomreset = makeSpan([fstyle.reset(), dstyle.cls()], [denom]);
|
386
|
+
|
387
|
+
var ruleWidth;
|
388
|
+
if (group.value.hasBarLine) {
|
389
|
+
ruleWidth = fontMetrics.metrics.defaultRuleThickness /
|
390
|
+
options.style.sizeMultiplier;
|
391
|
+
} else {
|
392
|
+
ruleWidth = 0;
|
393
|
+
}
|
394
|
+
|
395
|
+
// Rule 15b
|
396
|
+
var numShift;
|
397
|
+
var clearance;
|
398
|
+
var denomShift;
|
399
|
+
if (fstyle.size === Style.DISPLAY.size) {
|
400
|
+
numShift = fontMetrics.metrics.num1;
|
401
|
+
if (ruleWidth > 0) {
|
402
|
+
clearance = 3 * ruleWidth;
|
403
|
+
} else {
|
404
|
+
clearance = 7 * fontMetrics.metrics.defaultRuleThickness;
|
405
|
+
}
|
406
|
+
denomShift = fontMetrics.metrics.denom1;
|
407
|
+
} else {
|
408
|
+
if (ruleWidth > 0) {
|
409
|
+
numShift = fontMetrics.metrics.num2;
|
410
|
+
clearance = ruleWidth;
|
411
|
+
} else {
|
412
|
+
numShift = fontMetrics.metrics.num3;
|
413
|
+
clearance = 3 * fontMetrics.metrics.defaultRuleThickness;
|
414
|
+
}
|
415
|
+
denomShift = fontMetrics.metrics.denom2;
|
416
|
+
}
|
417
|
+
|
418
|
+
var frac;
|
419
|
+
if (ruleWidth === 0) {
|
420
|
+
// Rule 15c
|
421
|
+
var candiateClearance =
|
422
|
+
(numShift - numer.depth) - (denom.height - denomShift);
|
423
|
+
if (candiateClearance < clearance) {
|
424
|
+
numShift += 0.5 * (clearance - candiateClearance);
|
425
|
+
denomShift += 0.5 * (clearance - candiateClearance);
|
426
|
+
}
|
427
|
+
|
428
|
+
frac = buildCommon.makeVList([
|
429
|
+
{type: "elem", elem: denomreset, shift: denomShift},
|
430
|
+
{type: "elem", elem: numerreset, shift: -numShift}
|
431
|
+
], "individualShift", null, options);
|
432
|
+
} else {
|
433
|
+
// Rule 15d
|
434
|
+
var axisHeight = fontMetrics.metrics.axisHeight;
|
435
|
+
|
436
|
+
if ((numShift - numer.depth) - (axisHeight + 0.5 * ruleWidth)
|
437
|
+
< clearance) {
|
438
|
+
numShift +=
|
439
|
+
clearance - ((numShift - numer.depth) -
|
440
|
+
(axisHeight + 0.5 * ruleWidth));
|
441
|
+
}
|
442
|
+
|
443
|
+
if ((axisHeight - 0.5 * ruleWidth) - (denom.height - denomShift)
|
444
|
+
< clearance) {
|
445
|
+
denomShift +=
|
446
|
+
clearance - ((axisHeight - 0.5 * ruleWidth) -
|
447
|
+
(denom.height - denomShift));
|
448
|
+
}
|
449
|
+
|
450
|
+
var mid = makeSpan(
|
451
|
+
[options.style.reset(), Style.TEXT.cls(), "frac-line"]);
|
452
|
+
// Manually set the height of the line because its height is
|
453
|
+
// created in CSS
|
454
|
+
mid.height = ruleWidth;
|
455
|
+
|
456
|
+
var midShift = -(axisHeight - 0.5 * ruleWidth);
|
457
|
+
|
458
|
+
frac = buildCommon.makeVList([
|
459
|
+
{type: "elem", elem: denomreset, shift: denomShift},
|
460
|
+
{type: "elem", elem: mid, shift: midShift},
|
461
|
+
{type: "elem", elem: numerreset, shift: -numShift}
|
462
|
+
], "individualShift", null, options);
|
463
|
+
}
|
464
|
+
|
465
|
+
// Since we manually change the style sometimes (with \dfrac or \tfrac),
|
466
|
+
// account for the possible size change here.
|
467
|
+
frac.height *= fstyle.sizeMultiplier / options.style.sizeMultiplier;
|
468
|
+
frac.depth *= fstyle.sizeMultiplier / options.style.sizeMultiplier;
|
469
|
+
|
470
|
+
// Rule 15e
|
471
|
+
var innerChildren = [makeSpan(["mfrac"], [frac])];
|
472
|
+
|
473
|
+
var delimSize;
|
474
|
+
if (fstyle.size === Style.DISPLAY.size) {
|
475
|
+
delimSize = fontMetrics.metrics.delim1;
|
476
|
+
} else {
|
477
|
+
delimSize = fontMetrics.metrics.getDelim2(fstyle);
|
478
|
+
}
|
479
|
+
|
480
|
+
if (group.value.leftDelim != null) {
|
481
|
+
innerChildren.unshift(
|
482
|
+
delimiter.customSizedDelim(
|
483
|
+
group.value.leftDelim, delimSize, true,
|
484
|
+
options.withStyle(fstyle), group.mode)
|
485
|
+
);
|
486
|
+
}
|
487
|
+
if (group.value.rightDelim != null) {
|
488
|
+
innerChildren.push(
|
489
|
+
delimiter.customSizedDelim(
|
490
|
+
group.value.rightDelim, delimSize, true,
|
491
|
+
options.withStyle(fstyle), group.mode)
|
492
|
+
);
|
493
|
+
}
|
494
|
+
|
495
|
+
return makeSpan(
|
496
|
+
["minner", options.style.reset(), fstyle.cls()],
|
497
|
+
innerChildren,
|
498
|
+
options.getColor());
|
499
|
+
},
|
500
|
+
|
501
|
+
spacing: function(group, options, prev) {
|
502
|
+
if (group.value === "\\ " || group.value === "\\space" ||
|
503
|
+
group.value === " " || group.value === "~") {
|
504
|
+
// Spaces are generated by adding an actual space. Each of these
|
505
|
+
// things has an entry in the symbols table, so these will be turned
|
506
|
+
// into appropriate outputs.
|
507
|
+
return makeSpan(
|
508
|
+
["mord", "mspace"],
|
509
|
+
[buildCommon.mathrm(group.value, group.mode)]
|
510
|
+
);
|
511
|
+
} else {
|
512
|
+
// Other kinds of spaces are of arbitrary width. We use CSS to
|
513
|
+
// generate these.
|
514
|
+
var spacingClassMap = {
|
515
|
+
"\\qquad": "qquad",
|
516
|
+
"\\quad": "quad",
|
517
|
+
"\\enspace": "enspace",
|
518
|
+
"\\;": "thickspace",
|
519
|
+
"\\:": "mediumspace",
|
520
|
+
"\\,": "thinspace",
|
521
|
+
"\\!": "negativethinspace"
|
522
|
+
};
|
523
|
+
|
524
|
+
return makeSpan(
|
525
|
+
["mord", "mspace", spacingClassMap[group.value]]);
|
526
|
+
}
|
527
|
+
},
|
528
|
+
|
529
|
+
llap: function(group, options, prev) {
|
530
|
+
var inner = makeSpan(
|
531
|
+
["inner"], [buildGroup(group.value.body, options.reset())]);
|
532
|
+
var fix = makeSpan(["fix"], []);
|
533
|
+
return makeSpan(
|
534
|
+
["llap", options.style.cls()], [inner, fix]);
|
535
|
+
},
|
536
|
+
|
537
|
+
rlap: function(group, options, prev) {
|
538
|
+
var inner = makeSpan(
|
539
|
+
["inner"], [buildGroup(group.value.body, options.reset())]);
|
540
|
+
var fix = makeSpan(["fix"], []);
|
541
|
+
return makeSpan(
|
542
|
+
["rlap", options.style.cls()], [inner, fix]);
|
543
|
+
},
|
544
|
+
|
545
|
+
op: function(group, options, prev) {
|
546
|
+
// Operators are handled in the TeXbook pg. 443-444, rule 13(a).
|
547
|
+
var supGroup;
|
548
|
+
var subGroup;
|
549
|
+
var hasLimits = false;
|
550
|
+
if (group.type === "supsub" ) {
|
551
|
+
// If we have limits, supsub will pass us its group to handle. Pull
|
552
|
+
// out the superscript and subscript and set the group to the op in
|
553
|
+
// its base.
|
554
|
+
supGroup = group.value.sup;
|
555
|
+
subGroup = group.value.sub;
|
556
|
+
group = group.value.base;
|
557
|
+
hasLimits = true;
|
558
|
+
}
|
559
|
+
|
560
|
+
// Most operators have a large successor symbol, but these don't.
|
561
|
+
var noSuccessor = [
|
562
|
+
"\\smallint"
|
563
|
+
];
|
564
|
+
|
565
|
+
var large = false;
|
566
|
+
if (options.style.size === Style.DISPLAY.size &&
|
567
|
+
group.value.symbol &&
|
568
|
+
!utils.contains(noSuccessor, group.value.body)) {
|
569
|
+
|
570
|
+
// Most symbol operators get larger in displaystyle (rule 13)
|
571
|
+
large = true;
|
572
|
+
}
|
573
|
+
|
574
|
+
var base;
|
575
|
+
var baseShift = 0;
|
576
|
+
var slant = 0;
|
577
|
+
if (group.value.symbol) {
|
578
|
+
// If this is a symbol, create the symbol.
|
579
|
+
var style = large ? "Size2-Regular" : "Size1-Regular";
|
580
|
+
base = buildCommon.makeSymbol(
|
581
|
+
group.value.body, style, "math", options.getColor(),
|
582
|
+
["op-symbol", large ? "large-op" : "small-op", "mop"]);
|
583
|
+
|
584
|
+
// Shift the symbol so its center lies on the axis (rule 13). It
|
585
|
+
// appears that our fonts have the centers of the symbols already
|
586
|
+
// almost on the axis, so these numbers are very small. Note we
|
587
|
+
// don't actually apply this here, but instead it is used either in
|
588
|
+
// the vlist creation or separately when there are no limits.
|
589
|
+
baseShift = (base.height - base.depth) / 2 -
|
590
|
+
fontMetrics.metrics.axisHeight *
|
591
|
+
options.style.sizeMultiplier;
|
592
|
+
|
593
|
+
// The slant of the symbol is just its italic correction.
|
594
|
+
slant = base.italic;
|
595
|
+
} else {
|
596
|
+
// Otherwise, this is a text operator. Build the text from the
|
597
|
+
// operator's name.
|
598
|
+
// TODO(emily): Add a space in the middle of some of these
|
599
|
+
// operators, like \limsup
|
600
|
+
var output = [];
|
601
|
+
for (var i = 1; i < group.value.body.length; i++) {
|
602
|
+
output.push(buildCommon.mathrm(group.value.body[i], group.mode));
|
603
|
+
}
|
604
|
+
base = makeSpan(["mop"], output, options.getColor());
|
605
|
+
}
|
606
|
+
|
607
|
+
if (hasLimits) {
|
608
|
+
// IE 8 clips \int if it is in a display: inline-block. We wrap it
|
609
|
+
// in a new span so it is an inline, and works.
|
610
|
+
base = makeSpan([], [base]);
|
611
|
+
|
612
|
+
var supmid, supKern, submid, subKern;
|
613
|
+
// We manually have to handle the superscripts and subscripts. This,
|
614
|
+
// aside from the kern calculations, is copied from supsub.
|
615
|
+
if (supGroup) {
|
616
|
+
var sup = buildGroup(
|
617
|
+
supGroup, options.withStyle(options.style.sup()));
|
618
|
+
supmid = makeSpan(
|
619
|
+
[options.style.reset(), options.style.sup().cls()], [sup]);
|
620
|
+
|
621
|
+
supKern = Math.max(
|
622
|
+
fontMetrics.metrics.bigOpSpacing1,
|
623
|
+
fontMetrics.metrics.bigOpSpacing3 - sup.depth);
|
624
|
+
}
|
625
|
+
|
626
|
+
if (subGroup) {
|
627
|
+
var sub = buildGroup(
|
628
|
+
subGroup, options.withStyle(options.style.sub()));
|
629
|
+
submid = makeSpan(
|
630
|
+
[options.style.reset(), options.style.sub().cls()],
|
631
|
+
[sub]);
|
632
|
+
|
633
|
+
subKern = Math.max(
|
634
|
+
fontMetrics.metrics.bigOpSpacing2,
|
635
|
+
fontMetrics.metrics.bigOpSpacing4 - sub.height);
|
636
|
+
}
|
637
|
+
|
638
|
+
// Build the final group as a vlist of the possible subscript, base,
|
639
|
+
// and possible superscript.
|
640
|
+
var finalGroup, top, bottom;
|
641
|
+
if (!supGroup) {
|
642
|
+
top = base.height - baseShift;
|
643
|
+
|
644
|
+
finalGroup = buildCommon.makeVList([
|
645
|
+
{type: "kern", size: fontMetrics.metrics.bigOpSpacing5},
|
646
|
+
{type: "elem", elem: submid},
|
647
|
+
{type: "kern", size: subKern},
|
648
|
+
{type: "elem", elem: base}
|
649
|
+
], "top", top, options);
|
650
|
+
|
651
|
+
// Here, we shift the limits by the slant of the symbol. Note
|
652
|
+
// that we are supposed to shift the limits by 1/2 of the slant,
|
653
|
+
// but since we are centering the limits adding a full slant of
|
654
|
+
// margin will shift by 1/2 that.
|
655
|
+
finalGroup.children[0].style.marginLeft = -slant + "em";
|
656
|
+
} else if (!subGroup) {
|
657
|
+
bottom = base.depth + baseShift;
|
658
|
+
|
659
|
+
finalGroup = buildCommon.makeVList([
|
660
|
+
{type: "elem", elem: base},
|
661
|
+
{type: "kern", size: supKern},
|
662
|
+
{type: "elem", elem: supmid},
|
663
|
+
{type: "kern", size: fontMetrics.metrics.bigOpSpacing5}
|
664
|
+
], "bottom", bottom, options);
|
665
|
+
|
666
|
+
// See comment above about slants
|
667
|
+
finalGroup.children[1].style.marginLeft = slant + "em";
|
668
|
+
} else if (!supGroup && !subGroup) {
|
669
|
+
// This case probably shouldn't occur (this would mean the
|
670
|
+
// supsub was sending us a group with no superscript or
|
671
|
+
// subscript) but be safe.
|
672
|
+
return base;
|
673
|
+
} else {
|
674
|
+
bottom = fontMetrics.metrics.bigOpSpacing5 +
|
675
|
+
submid.height + submid.depth +
|
676
|
+
subKern +
|
677
|
+
base.depth + baseShift;
|
678
|
+
|
679
|
+
finalGroup = buildCommon.makeVList([
|
680
|
+
{type: "kern", size: fontMetrics.metrics.bigOpSpacing5},
|
681
|
+
{type: "elem", elem: submid},
|
682
|
+
{type: "kern", size: subKern},
|
683
|
+
{type: "elem", elem: base},
|
684
|
+
{type: "kern", size: supKern},
|
685
|
+
{type: "elem", elem: supmid},
|
686
|
+
{type: "kern", size: fontMetrics.metrics.bigOpSpacing5}
|
687
|
+
], "bottom", bottom, options);
|
688
|
+
|
689
|
+
// See comment above about slants
|
690
|
+
finalGroup.children[0].style.marginLeft = -slant + "em";
|
691
|
+
finalGroup.children[2].style.marginLeft = slant + "em";
|
692
|
+
}
|
693
|
+
|
694
|
+
return makeSpan(["mop", "op-limits"], [finalGroup]);
|
695
|
+
} else {
|
696
|
+
if (group.value.symbol) {
|
697
|
+
base.style.top = baseShift + "em";
|
698
|
+
}
|
699
|
+
|
700
|
+
return base;
|
701
|
+
}
|
702
|
+
},
|
703
|
+
|
704
|
+
katex: function(group, options, prev) {
|
705
|
+
// The KaTeX logo. The offsets for the K and a were chosen to look
|
706
|
+
// good, but the offsets for the T, E, and X were taken from the
|
707
|
+
// definition of \TeX in TeX (see TeXbook pg. 356)
|
708
|
+
var k = makeSpan(
|
709
|
+
["k"], [buildCommon.mathrm("K", group.mode)]);
|
710
|
+
var a = makeSpan(
|
711
|
+
["a"], [buildCommon.mathrm("A", group.mode)]);
|
712
|
+
|
713
|
+
a.height = (a.height + 0.2) * 0.75;
|
714
|
+
a.depth = (a.height - 0.2) * 0.75;
|
715
|
+
|
716
|
+
var t = makeSpan(
|
717
|
+
["t"], [buildCommon.mathrm("T", group.mode)]);
|
718
|
+
var e = makeSpan(
|
719
|
+
["e"], [buildCommon.mathrm("E", group.mode)]);
|
720
|
+
|
721
|
+
e.height = (e.height - 0.2155);
|
722
|
+
e.depth = (e.depth + 0.2155);
|
723
|
+
|
724
|
+
var x = makeSpan(
|
725
|
+
["x"], [buildCommon.mathrm("X", group.mode)]);
|
726
|
+
|
727
|
+
return makeSpan(
|
728
|
+
["katex-logo"], [k, a, t, e, x], options.getColor());
|
729
|
+
},
|
730
|
+
|
731
|
+
overline: function(group, options, prev) {
|
732
|
+
// Overlines are handled in the TeXbook pg 443, Rule 9.
|
733
|
+
|
734
|
+
// Build the inner group in the cramped style.
|
735
|
+
var innerGroup = buildGroup(group.value.body,
|
736
|
+
options.withStyle(options.style.cramp()));
|
737
|
+
|
738
|
+
var ruleWidth = fontMetrics.metrics.defaultRuleThickness /
|
739
|
+
options.style.sizeMultiplier;
|
740
|
+
|
741
|
+
// Create the line above the body
|
742
|
+
var line = makeSpan(
|
743
|
+
[options.style.reset(), Style.TEXT.cls(), "overline-line"]);
|
744
|
+
line.height = ruleWidth;
|
745
|
+
line.maxFontSize = 1.0;
|
746
|
+
|
747
|
+
// Generate the vlist, with the appropriate kerns
|
748
|
+
var vlist = buildCommon.makeVList([
|
749
|
+
{type: "elem", elem: innerGroup},
|
750
|
+
{type: "kern", size: 3 * ruleWidth},
|
751
|
+
{type: "elem", elem: line},
|
752
|
+
{type: "kern", size: ruleWidth}
|
753
|
+
], "firstBaseline", null, options);
|
754
|
+
|
755
|
+
return makeSpan(["overline", "mord"], [vlist], options.getColor());
|
756
|
+
},
|
757
|
+
|
758
|
+
sqrt: function(group, options, prev) {
|
759
|
+
// Square roots are handled in the TeXbook pg. 443, Rule 11.
|
760
|
+
|
761
|
+
// First, we do the same steps as in overline to build the inner group
|
762
|
+
// and line
|
763
|
+
var inner = buildGroup(group.value.body,
|
764
|
+
options.withStyle(options.style.cramp()));
|
765
|
+
|
766
|
+
var ruleWidth = fontMetrics.metrics.defaultRuleThickness /
|
767
|
+
options.style.sizeMultiplier;
|
768
|
+
|
769
|
+
var line = makeSpan(
|
770
|
+
[options.style.reset(), Style.TEXT.cls(), "sqrt-line"], [],
|
771
|
+
options.getColor());
|
772
|
+
line.height = ruleWidth;
|
773
|
+
line.maxFontSize = 1.0;
|
774
|
+
|
775
|
+
var phi = ruleWidth;
|
776
|
+
if (options.style.id < Style.TEXT.id) {
|
777
|
+
phi = fontMetrics.metrics.xHeight;
|
778
|
+
}
|
779
|
+
|
780
|
+
// Calculate the clearance between the body and line
|
781
|
+
var lineClearance = ruleWidth + phi / 4;
|
782
|
+
|
783
|
+
var innerHeight =
|
784
|
+
(inner.height + inner.depth) * options.style.sizeMultiplier;
|
785
|
+
var minDelimiterHeight = innerHeight + lineClearance + ruleWidth;
|
786
|
+
|
787
|
+
// Create a \surd delimiter of the required minimum size
|
788
|
+
var delim = makeSpan(["sqrt-sign"], [
|
789
|
+
delimiter.customSizedDelim("\\surd", minDelimiterHeight,
|
790
|
+
false, options, group.mode)],
|
791
|
+
options.getColor());
|
792
|
+
|
793
|
+
var delimDepth = (delim.height + delim.depth) - ruleWidth;
|
794
|
+
|
795
|
+
// Adjust the clearance based on the delimiter size
|
796
|
+
if (delimDepth > inner.height + inner.depth + lineClearance) {
|
797
|
+
lineClearance =
|
798
|
+
(lineClearance + delimDepth - inner.height - inner.depth) / 2;
|
799
|
+
}
|
800
|
+
|
801
|
+
// Shift the delimiter so that its top lines up with the top of the line
|
802
|
+
var delimShift = -(inner.height + lineClearance + ruleWidth) + delim.height;
|
803
|
+
delim.style.top = delimShift + "em";
|
804
|
+
delim.height -= delimShift;
|
805
|
+
delim.depth += delimShift;
|
806
|
+
|
807
|
+
// We add a special case here, because even when `inner` is empty, we
|
808
|
+
// still get a line. So, we use a simple heuristic to decide if we
|
809
|
+
// should omit the body entirely. (note this doesn't work for something
|
810
|
+
// like `\sqrt{\rlap{x}}`, but if someone is doing that they deserve for
|
811
|
+
// it not to work.
|
812
|
+
var body;
|
813
|
+
if (inner.height === 0 && inner.depth === 0) {
|
814
|
+
body = makeSpan();
|
815
|
+
} else {
|
816
|
+
body = buildCommon.makeVList([
|
817
|
+
{type: "elem", elem: inner},
|
818
|
+
{type: "kern", size: lineClearance},
|
819
|
+
{type: "elem", elem: line},
|
820
|
+
{type: "kern", size: ruleWidth}
|
821
|
+
], "firstBaseline", null, options);
|
822
|
+
}
|
823
|
+
|
824
|
+
return makeSpan(["sqrt", "mord"], [delim, body]);
|
825
|
+
},
|
826
|
+
|
827
|
+
sizing: function(group, options, prev) {
|
828
|
+
// Handle sizing operators like \Huge. Real TeX doesn't actually allow
|
829
|
+
// these functions inside of math expressions, so we do some special
|
830
|
+
// handling.
|
831
|
+
var inner = buildExpression(group.value.value,
|
832
|
+
options.withSize(group.value.size), prev);
|
833
|
+
|
834
|
+
var span = makeSpan(["mord"],
|
835
|
+
[makeSpan(["sizing", "reset-" + options.size, group.value.size,
|
836
|
+
options.style.cls()],
|
837
|
+
inner)]);
|
838
|
+
|
839
|
+
// Calculate the correct maxFontSize manually
|
840
|
+
var fontSize = sizingMultiplier[group.value.size];
|
841
|
+
span.maxFontSize = fontSize * options.style.sizeMultiplier;
|
842
|
+
|
843
|
+
return span;
|
844
|
+
},
|
845
|
+
|
846
|
+
styling: function(group, options, prev) {
|
847
|
+
// Style changes are handled in the TeXbook on pg. 442, Rule 3.
|
848
|
+
|
849
|
+
// Figure out what style we're changing to.
|
850
|
+
var style = {
|
851
|
+
"display": Style.DISPLAY,
|
852
|
+
"text": Style.TEXT,
|
853
|
+
"script": Style.SCRIPT,
|
854
|
+
"scriptscript": Style.SCRIPTSCRIPT
|
855
|
+
};
|
856
|
+
|
857
|
+
var newStyle = style[group.value.style];
|
858
|
+
|
859
|
+
// Build the inner expression in the new style.
|
860
|
+
var inner = buildExpression(
|
861
|
+
group.value.value, options.withStyle(newStyle), prev);
|
862
|
+
|
863
|
+
return makeSpan([options.style.reset(), newStyle.cls()], inner);
|
864
|
+
},
|
865
|
+
|
866
|
+
delimsizing: function(group, options, prev) {
|
867
|
+
var delim = group.value.value;
|
868
|
+
|
869
|
+
if (delim === ".") {
|
870
|
+
// Empty delimiters still count as elements, even though they don't
|
871
|
+
// show anything.
|
872
|
+
return makeSpan([groupToType[group.value.delimType]]);
|
873
|
+
}
|
874
|
+
|
875
|
+
// Use delimiter.sizedDelim to generate the delimiter.
|
876
|
+
return makeSpan(
|
877
|
+
[groupToType[group.value.delimType]],
|
878
|
+
[delimiter.sizedDelim(
|
879
|
+
delim, group.value.size, options, group.mode)]);
|
880
|
+
},
|
881
|
+
|
882
|
+
leftright: function(group, options, prev) {
|
883
|
+
// Build the inner expression
|
884
|
+
var inner = buildExpression(group.value.body, options.reset());
|
885
|
+
|
886
|
+
var innerHeight = 0;
|
887
|
+
var innerDepth = 0;
|
888
|
+
|
889
|
+
// Calculate its height and depth
|
890
|
+
for (var i = 0; i < inner.length; i++) {
|
891
|
+
innerHeight = Math.max(inner[i].height, innerHeight);
|
892
|
+
innerDepth = Math.max(inner[i].depth, innerDepth);
|
893
|
+
}
|
894
|
+
|
895
|
+
// The size of delimiters is the same, regardless of what style we are
|
896
|
+
// in. Thus, to correctly calculate the size of delimiter we need around
|
897
|
+
// a group, we scale down the inner size based on the size.
|
898
|
+
innerHeight *= options.style.sizeMultiplier;
|
899
|
+
innerDepth *= options.style.sizeMultiplier;
|
900
|
+
|
901
|
+
var leftDelim;
|
902
|
+
if (group.value.left === ".") {
|
903
|
+
// Empty delimiters in \left and \right make null delimiter spaces.
|
904
|
+
leftDelim = makeSpan(["nulldelimiter"]);
|
905
|
+
} else {
|
906
|
+
// Otherwise, use leftRightDelim to generate the correct sized
|
907
|
+
// delimiter.
|
908
|
+
leftDelim = delimiter.leftRightDelim(
|
909
|
+
group.value.left, innerHeight, innerDepth, options,
|
910
|
+
group.mode);
|
911
|
+
}
|
912
|
+
// Add it to the beginning of the expression
|
913
|
+
inner.unshift(leftDelim);
|
914
|
+
|
915
|
+
var rightDelim;
|
916
|
+
// Same for the right delimiter
|
917
|
+
if (group.value.right === ".") {
|
918
|
+
rightDelim = makeSpan(["nulldelimiter"]);
|
919
|
+
} else {
|
920
|
+
rightDelim = delimiter.leftRightDelim(
|
921
|
+
group.value.right, innerHeight, innerDepth, options,
|
922
|
+
group.mode);
|
923
|
+
}
|
924
|
+
// Add it to the end of the expression.
|
925
|
+
inner.push(rightDelim);
|
926
|
+
|
927
|
+
return makeSpan(
|
928
|
+
["minner", options.style.cls()], inner, options.getColor());
|
929
|
+
},
|
930
|
+
|
931
|
+
rule: function(group, options, prev) {
|
932
|
+
// Make an empty span for the rule
|
933
|
+
var rule = makeSpan(["mord", "rule"], [], options.getColor());
|
934
|
+
|
935
|
+
// Calculate the shift, width, and height of the rule, and account for units
|
936
|
+
var shift = 0;
|
937
|
+
if (group.value.shift) {
|
938
|
+
shift = group.value.shift.number;
|
939
|
+
if (group.value.shift.unit === "ex") {
|
940
|
+
shift *= fontMetrics.metrics.xHeight;
|
941
|
+
}
|
942
|
+
}
|
943
|
+
|
944
|
+
var width = group.value.width.number;
|
945
|
+
if (group.value.width.unit === "ex") {
|
946
|
+
width *= fontMetrics.metrics.xHeight;
|
947
|
+
}
|
948
|
+
|
949
|
+
var height = group.value.height.number;
|
950
|
+
if (group.value.height.unit === "ex") {
|
951
|
+
height *= fontMetrics.metrics.xHeight;
|
952
|
+
}
|
953
|
+
|
954
|
+
// The sizes of rules are absolute, so make it larger if we are in a
|
955
|
+
// smaller style.
|
956
|
+
shift /= options.style.sizeMultiplier;
|
957
|
+
width /= options.style.sizeMultiplier;
|
958
|
+
height /= options.style.sizeMultiplier;
|
959
|
+
|
960
|
+
// Style the rule to the right size
|
961
|
+
rule.style.borderRightWidth = width + "em";
|
962
|
+
rule.style.borderTopWidth = height + "em";
|
963
|
+
rule.style.bottom = shift + "em";
|
964
|
+
|
965
|
+
// Record the height and width
|
966
|
+
rule.width = width;
|
967
|
+
rule.height = height + shift;
|
968
|
+
rule.depth = -shift;
|
969
|
+
|
970
|
+
return rule;
|
971
|
+
},
|
972
|
+
|
973
|
+
accent: function(group, options, prev) {
|
974
|
+
// Accents are handled in the TeXbook pg. 443, rule 12.
|
975
|
+
var base = group.value.base;
|
976
|
+
|
977
|
+
var supsubGroup;
|
978
|
+
if (group.type === "supsub") {
|
979
|
+
// If our base is a character box, and we have superscripts and
|
980
|
+
// subscripts, the supsub will defer to us. In particular, we want
|
981
|
+
// to attach the superscripts and subscripts to the inner body (so
|
982
|
+
// that the position of the superscripts and subscripts won't be
|
983
|
+
// affected by the height of the accent). We accomplish this by
|
984
|
+
// sticking the base of the accent into the base of the supsub, and
|
985
|
+
// rendering that, while keeping track of where the accent is.
|
986
|
+
|
987
|
+
// The supsub group is the group that was passed in
|
988
|
+
var supsub = group;
|
989
|
+
// The real accent group is the base of the supsub group
|
990
|
+
group = supsub.value.base;
|
991
|
+
// The character box is the base of the accent group
|
992
|
+
base = group.value.base;
|
993
|
+
// Stick the character box into the base of the supsub group
|
994
|
+
supsub.value.base = base;
|
995
|
+
|
996
|
+
// Rerender the supsub group with its new base, and store that
|
997
|
+
// result.
|
998
|
+
supsubGroup = buildGroup(
|
999
|
+
supsub, options.reset(), prev);
|
1000
|
+
}
|
1001
|
+
|
1002
|
+
// Build the base group
|
1003
|
+
var body = buildGroup(
|
1004
|
+
base, options.withStyle(options.style.cramp()));
|
1005
|
+
|
1006
|
+
// Calculate the skew of the accent. This is based on the line "If the
|
1007
|
+
// nucleus is not a single character, let s = 0; otherwise set s to the
|
1008
|
+
// kern amount for the nucleus followed by the \skewchar of its font."
|
1009
|
+
// Note that our skew metrics are just the kern between each character
|
1010
|
+
// and the skewchar.
|
1011
|
+
var skew;
|
1012
|
+
if (isCharacterBox(base)) {
|
1013
|
+
// If the base is a character box, then we want the skew of the
|
1014
|
+
// innermost character. To do that, we find the innermost character:
|
1015
|
+
var baseChar = getBaseElem(base);
|
1016
|
+
// Then, we render its group to get the symbol inside it
|
1017
|
+
var baseGroup = buildGroup(
|
1018
|
+
baseChar, options.withStyle(options.style.cramp()));
|
1019
|
+
// Finally, we pull the skew off of the symbol.
|
1020
|
+
skew = baseGroup.skew;
|
1021
|
+
// Note that we now throw away baseGroup, because the layers we
|
1022
|
+
// removed with getBaseElem might contain things like \color which
|
1023
|
+
// we can't get rid of.
|
1024
|
+
// TODO(emily): Find a better way to get the skew
|
1025
|
+
} else {
|
1026
|
+
skew = 0;
|
1027
|
+
}
|
1028
|
+
|
1029
|
+
// calculate the amount of space between the body and the accent
|
1030
|
+
var clearance = Math.min(body.height, fontMetrics.metrics.xHeight);
|
1031
|
+
|
1032
|
+
// Build the accent
|
1033
|
+
var accent = buildCommon.makeSymbol(
|
1034
|
+
group.value.accent, "Main-Regular", "math", options.getColor());
|
1035
|
+
// Remove the italic correction of the accent, because it only serves to
|
1036
|
+
// shift the accent over to a place we don't want.
|
1037
|
+
accent.italic = 0;
|
1038
|
+
|
1039
|
+
// The \vec character that the fonts use is a combining character, and
|
1040
|
+
// thus shows up much too far to the left. To account for this, we add a
|
1041
|
+
// specific class which shifts the accent over to where we want it.
|
1042
|
+
// TODO(emily): Fix this in a better way, like by changing the font
|
1043
|
+
var vecClass = group.value.accent === "\\vec" ? "accent-vec" : null;
|
1044
|
+
|
1045
|
+
var accentBody = makeSpan(["accent-body", vecClass], [
|
1046
|
+
makeSpan([], [accent])]);
|
1047
|
+
|
1048
|
+
accentBody = buildCommon.makeVList([
|
1049
|
+
{type: "elem", elem: body},
|
1050
|
+
{type: "kern", size: -clearance},
|
1051
|
+
{type: "elem", elem: accentBody}
|
1052
|
+
], "firstBaseline", null, options);
|
1053
|
+
|
1054
|
+
// Shift the accent over by the skew. Note we shift by twice the skew
|
1055
|
+
// because we are centering the accent, so by adding 2*skew to the left,
|
1056
|
+
// we shift it to the right by 1*skew.
|
1057
|
+
accentBody.children[1].style.marginLeft = 2 * skew + "em";
|
1058
|
+
|
1059
|
+
var accentWrap = makeSpan(["mord", "accent"], [accentBody]);
|
1060
|
+
|
1061
|
+
if (supsubGroup) {
|
1062
|
+
// Here, we replace the "base" child of the supsub with our newly
|
1063
|
+
// generated accent.
|
1064
|
+
supsubGroup.children[0] = accentWrap;
|
1065
|
+
|
1066
|
+
// Since we don't rerun the height calculation after replacing the
|
1067
|
+
// accent, we manually recalculate height.
|
1068
|
+
supsubGroup.height = Math.max(accentWrap.height, supsubGroup.height);
|
1069
|
+
|
1070
|
+
// Accents should always be ords, even when their innards are not.
|
1071
|
+
supsubGroup.classes[0] = "mord";
|
1072
|
+
|
1073
|
+
return supsubGroup;
|
1074
|
+
} else {
|
1075
|
+
return accentWrap;
|
1076
|
+
}
|
1077
|
+
}
|
1078
|
+
};
|
1079
|
+
|
1080
|
+
var sizingMultiplier = {
|
1081
|
+
size1: 0.5,
|
1082
|
+
size2: 0.7,
|
1083
|
+
size3: 0.8,
|
1084
|
+
size4: 0.9,
|
1085
|
+
size5: 1.0,
|
1086
|
+
size6: 1.2,
|
1087
|
+
size7: 1.44,
|
1088
|
+
size8: 1.73,
|
1089
|
+
size9: 2.07,
|
1090
|
+
size10: 2.49
|
1091
|
+
};
|
1092
|
+
|
1093
|
+
/**
|
1094
|
+
* buildGroup is the function that takes a group and calls the correct groupType
|
1095
|
+
* function for it. It also handles the interaction of size and style changes
|
1096
|
+
* between parents and children.
|
1097
|
+
*/
|
1098
|
+
var buildGroup = function(group, options, prev) {
|
1099
|
+
if (!group) {
|
1100
|
+
return makeSpan();
|
1101
|
+
}
|
1102
|
+
|
1103
|
+
if (groupTypes[group.type]) {
|
1104
|
+
// Call the groupTypes function
|
1105
|
+
var groupNode = groupTypes[group.type](group, options, prev);
|
1106
|
+
var multiplier;
|
1107
|
+
|
1108
|
+
// If the style changed between the parent and the current group,
|
1109
|
+
// account for the size difference
|
1110
|
+
if (options.style !== options.parentStyle) {
|
1111
|
+
multiplier = options.style.sizeMultiplier /
|
1112
|
+
options.parentStyle.sizeMultiplier;
|
1113
|
+
|
1114
|
+
groupNode.height *= multiplier;
|
1115
|
+
groupNode.depth *= multiplier;
|
1116
|
+
}
|
1117
|
+
|
1118
|
+
// If the size changed between the parent and the current group, account
|
1119
|
+
// for that size difference.
|
1120
|
+
if (options.size !== options.parentSize) {
|
1121
|
+
multiplier = sizingMultiplier[options.size] /
|
1122
|
+
sizingMultiplier[options.parentSize];
|
1123
|
+
|
1124
|
+
groupNode.height *= multiplier;
|
1125
|
+
groupNode.depth *= multiplier;
|
1126
|
+
}
|
1127
|
+
|
1128
|
+
return groupNode;
|
1129
|
+
} else {
|
1130
|
+
throw new ParseError(
|
1131
|
+
"Got group of unknown type: '" + group.type + "'");
|
1132
|
+
}
|
1133
|
+
};
|
1134
|
+
|
1135
|
+
/**
|
1136
|
+
* Take an entire parse tree, and build it into an appropriate set of nodes.
|
1137
|
+
*/
|
1138
|
+
var buildTree = function(tree) {
|
1139
|
+
// Setup the default options
|
1140
|
+
var options = new Options(Style.TEXT, "size5", "");
|
1141
|
+
|
1142
|
+
// Build the expression contained in the tree
|
1143
|
+
var expression = buildExpression(tree, options);
|
1144
|
+
var body = makeSpan(["base", options.style.cls()], expression);
|
1145
|
+
|
1146
|
+
// Add struts, which ensure that the top of the HTML element falls at the
|
1147
|
+
// height of the expression, and the bottom of the HTML element falls at the
|
1148
|
+
// depth of the expression.
|
1149
|
+
var topStrut = makeSpan(["strut"]);
|
1150
|
+
var bottomStrut = makeSpan(["strut", "bottom"]);
|
1151
|
+
|
1152
|
+
topStrut.style.height = body.height + "em";
|
1153
|
+
bottomStrut.style.height = (body.height + body.depth) + "em";
|
1154
|
+
// We'd like to use `vertical-align: top` but in IE 9 this lowers the
|
1155
|
+
// baseline of the box to the bottom of this strut (instead staying in the
|
1156
|
+
// normal place) so we use an absolute value for vertical-align instead
|
1157
|
+
bottomStrut.style.verticalAlign = -body.depth + "em";
|
1158
|
+
|
1159
|
+
// Wrap the struts and body together
|
1160
|
+
var katexNode = makeSpan(["katex"], [
|
1161
|
+
makeSpan(["katex-inner"], [topStrut, bottomStrut, body])
|
1162
|
+
]);
|
1163
|
+
|
1164
|
+
return katexNode;
|
1165
|
+
};
|
1166
|
+
|
1167
|
+
module.exports = buildTree;
|