jruby-activemq 5.5.1-java
Sign up to get free protection for your applications and to get access to all the features.
- data/History.md +6 -0
- data/LICENSE +619 -0
- data/README.md +15 -0
- data/Rakefile +34 -0
- data/apache-activemq-5.5.1/LICENSE +619 -0
- data/apache-activemq-5.5.1/NOTICE +85 -0
- data/apache-activemq-5.5.1/README.txt +63 -0
- data/apache-activemq-5.5.1/WebConsole-README.txt +42 -0
- data/apache-activemq-5.5.1/activemq-all-5.5.1.jar +0 -0
- data/apache-activemq-5.5.1/bin/activemq +653 -0
- data/apache-activemq-5.5.1/bin/activemq-admin +155 -0
- data/apache-activemq-5.5.1/bin/linux-x86-32/activemq +543 -0
- data/apache-activemq-5.5.1/bin/linux-x86-32/libwrapper.so +0 -0
- data/apache-activemq-5.5.1/bin/linux-x86-32/wrapper +0 -0
- data/apache-activemq-5.5.1/bin/linux-x86-32/wrapper.conf +139 -0
- data/apache-activemq-5.5.1/bin/linux-x86-64/activemq +543 -0
- data/apache-activemq-5.5.1/bin/linux-x86-64/libwrapper.so +0 -0
- data/apache-activemq-5.5.1/bin/linux-x86-64/wrapper +0 -0
- data/apache-activemq-5.5.1/bin/linux-x86-64/wrapper.conf +139 -0
- data/apache-activemq-5.5.1/bin/macosx/activemq +537 -0
- data/apache-activemq-5.5.1/bin/macosx/libwrapper.jnilib +0 -0
- data/apache-activemq-5.5.1/bin/macosx/wrapper +0 -0
- data/apache-activemq-5.5.1/bin/macosx/wrapper.conf +139 -0
- data/apache-activemq-5.5.1/bin/run.jar +0 -0
- data/apache-activemq-5.5.1/bin/wrapper.jar +0 -0
- data/apache-activemq-5.5.1/conf/activemq-command.xml +52 -0
- data/apache-activemq-5.5.1/conf/activemq-demo.xml +289 -0
- data/apache-activemq-5.5.1/conf/activemq-dynamic-network-broker1.xml +108 -0
- data/apache-activemq-5.5.1/conf/activemq-dynamic-network-broker2.xml +109 -0
- data/apache-activemq-5.5.1/conf/activemq-jdbc.xml +98 -0
- data/apache-activemq-5.5.1/conf/activemq-scalability.xml +77 -0
- data/apache-activemq-5.5.1/conf/activemq-security.xml +132 -0
- data/apache-activemq-5.5.1/conf/activemq-specjms.xml +118 -0
- data/apache-activemq-5.5.1/conf/activemq-static-network-broker1.xml +100 -0
- data/apache-activemq-5.5.1/conf/activemq-static-network-broker2.xml +100 -0
- data/apache-activemq-5.5.1/conf/activemq-stomp.xml +133 -0
- data/apache-activemq-5.5.1/conf/activemq-throughput.xml +82 -0
- data/apache-activemq-5.5.1/conf/activemq.xml +136 -0
- data/apache-activemq-5.5.1/conf/broker-localhost.cert +0 -0
- data/apache-activemq-5.5.1/conf/broker.ks +0 -0
- data/apache-activemq-5.5.1/conf/broker.ts +0 -0
- data/apache-activemq-5.5.1/conf/camel.xml +66 -0
- data/apache-activemq-5.5.1/conf/client.ks +0 -0
- data/apache-activemq-5.5.1/conf/client.ts +0 -0
- data/apache-activemq-5.5.1/conf/credentials-enc.properties +22 -0
- data/apache-activemq-5.5.1/conf/credentials.properties +22 -0
- data/apache-activemq-5.5.1/conf/jetty-realm.properties +20 -0
- data/apache-activemq-5.5.1/conf/jetty.xml +112 -0
- data/apache-activemq-5.5.1/conf/jmx.access +18 -0
- data/apache-activemq-5.5.1/conf/jmx.password +18 -0
- data/apache-activemq-5.5.1/conf/log4j.properties +75 -0
- data/apache-activemq-5.5.1/conf/logging.properties +25 -0
- data/apache-activemq-5.5.1/data/activemq.log +0 -0
- data/apache-activemq-5.5.1/docs/index.html +22 -0
- data/apache-activemq-5.5.1/example/build.xml +317 -0
- data/apache-activemq-5.5.1/example/conf/activemq.xml +41 -0
- data/apache-activemq-5.5.1/example/conf/log4j.properties +39 -0
- data/apache-activemq-5.5.1/example/conf/resin-web.xml +35 -0
- data/apache-activemq-5.5.1/example/conf/web.xml +40 -0
- data/apache-activemq-5.5.1/example/perfharness/perfharness-activemq.sh +49 -0
- data/apache-activemq-5.5.1/example/ruby/README.txt +27 -0
- data/apache-activemq-5.5.1/example/ruby/catstomp.rb +49 -0
- data/apache-activemq-5.5.1/example/ruby/listener.rb +51 -0
- data/apache-activemq-5.5.1/example/ruby/publisher.rb +67 -0
- data/apache-activemq-5.5.1/example/ruby/stompcat.rb +50 -0
- data/apache-activemq-5.5.1/example/src/CommandLineSupport.java +120 -0
- data/apache-activemq-5.5.1/example/src/ConsumerTool.java +353 -0
- data/apache-activemq-5.5.1/example/src/EmbeddedBroker.java +41 -0
- data/apache-activemq-5.5.1/example/src/Log4jJMSAppenderExample.java +70 -0
- data/apache-activemq-5.5.1/example/src/ProducerAndConsumerTool.java +51 -0
- data/apache-activemq-5.5.1/example/src/ProducerTool.java +247 -0
- data/apache-activemq-5.5.1/example/src/RequesterTool.java +257 -0
- data/apache-activemq-5.5.1/example/src/StompExample.java +59 -0
- data/apache-activemq-5.5.1/example/src/TopicListener.java +118 -0
- data/apache-activemq-5.5.1/example/src/TopicPublisher.java +205 -0
- data/apache-activemq-5.5.1/example/src/jndi.properties +17 -0
- data/apache-activemq-5.5.1/example/src/log4j-jms.properties +31 -0
- data/apache-activemq-5.5.1/example/transactions/README.txt +40 -0
- data/apache-activemq-5.5.1/example/transactions/build.xml +113 -0
- data/apache-activemq-5.5.1/example/transactions/src/Retailer.java +107 -0
- data/apache-activemq-5.5.1/example/transactions/src/Supplier.java +135 -0
- data/apache-activemq-5.5.1/example/transactions/src/TransactionsDemo.java +47 -0
- data/apache-activemq-5.5.1/example/transactions/src/Vendor.java +302 -0
- data/apache-activemq-5.5.1/lib/a.sh +3 -0
- data/apache-activemq-5.5.1/lib/activation-1.1.jar +0 -0
- data/apache-activemq-5.5.1/lib/activemq-camel-5.5.1.jar +0 -0
- data/apache-activemq-5.5.1/lib/activemq-console-5.5.1.jar +0 -0
- data/apache-activemq-5.5.1/lib/activemq-core-5.5.1.jar +0 -0
- data/apache-activemq-5.5.1/lib/activemq-jaas-5.5.1.jar +0 -0
- data/apache-activemq-5.5.1/lib/activemq-protobuf-1.1.jar +0 -0
- data/apache-activemq-5.5.1/lib/activemq-rar.txt +20 -0
- data/apache-activemq-5.5.1/lib/activemq-web-5.5.1.jar +0 -0
- data/apache-activemq-5.5.1/lib/camel-core-2.7.0.jar +0 -0
- data/apache-activemq-5.5.1/lib/camel-jetty-2.7.0.jar +0 -0
- data/apache-activemq-5.5.1/lib/camel-jms-2.7.0.jar +0 -0
- data/apache-activemq-5.5.1/lib/camel-spring-2.7.0.jar +0 -0
- data/apache-activemq-5.5.1/lib/geronimo-j2ee-management_1.1_spec-1.0.1.jar +0 -0
- data/apache-activemq-5.5.1/lib/geronimo-jms_1.1_spec-1.1.1.jar +0 -0
- data/apache-activemq-5.5.1/lib/geronimo-jta_1.0.1B_spec-1.0.1.jar +0 -0
- data/apache-activemq-5.5.1/lib/jaxb-api-2.1.jar +0 -0
- data/apache-activemq-5.5.1/lib/jaxb-impl-2.1.6.jar +0 -0
- data/apache-activemq-5.5.1/lib/jcl-over-slf4j-1.5.11.jar +0 -0
- data/apache-activemq-5.5.1/lib/kahadb-5.5.1.jar +0 -0
- data/apache-activemq-5.5.1/lib/optional/activeio-core-3.1.2.jar +0 -0
- data/apache-activemq-5.5.1/lib/optional/activemq-jmdns_1.0-5.5.1.jar +0 -0
- data/apache-activemq-5.5.1/lib/optional/activemq-optional-5.5.1.jar +0 -0
- data/apache-activemq-5.5.1/lib/optional/activemq-pool-5.5.1.jar +0 -0
- data/apache-activemq-5.5.1/lib/optional/activemq-spring-5.5.1.jar +0 -0
- data/apache-activemq-5.5.1/lib/optional/activemq-xmpp-5.5.1.jar +0 -0
- data/apache-activemq-5.5.1/lib/optional/commons-beanutils-1.6.1.jar +0 -0
- data/apache-activemq-5.5.1/lib/optional/commons-codec-1.2.jar +0 -0
- data/apache-activemq-5.5.1/lib/optional/commons-collections-3.2.1.jar +0 -0
- data/apache-activemq-5.5.1/lib/optional/commons-dbcp-1.2.2.jar +0 -0
- data/apache-activemq-5.5.1/lib/optional/commons-httpclient-3.1.jar +0 -0
- data/apache-activemq-5.5.1/lib/optional/commons-lang-2.4.jar +0 -0
- data/apache-activemq-5.5.1/lib/optional/commons-net-2.0.jar +0 -0
- data/apache-activemq-5.5.1/lib/optional/commons-pool-1.5.4.jar +0 -0
- data/apache-activemq-5.5.1/lib/optional/geronimo-j2ee-connector_1.5_spec-2.0.0.jar +0 -0
- data/apache-activemq-5.5.1/lib/optional/jasypt-1.7.jar +0 -0
- data/apache-activemq-5.5.1/lib/optional/jettison-1.2.jar +0 -0
- data/apache-activemq-5.5.1/lib/optional/josql-1.5.jar +0 -0
- data/apache-activemq-5.5.1/lib/optional/log4j-1.2.14.jar +0 -0
- data/apache-activemq-5.5.1/lib/optional/slf4j-log4j12-1.5.11.jar +0 -0
- data/apache-activemq-5.5.1/lib/optional/spring-aop-3.0.3.RELEASE.jar +0 -0
- data/apache-activemq-5.5.1/lib/optional/spring-asm-3.0.3.RELEASE.jar +0 -0
- data/apache-activemq-5.5.1/lib/optional/spring-beans-3.0.3.RELEASE.jar +0 -0
- data/apache-activemq-5.5.1/lib/optional/spring-context-3.0.3.RELEASE.jar +0 -0
- data/apache-activemq-5.5.1/lib/optional/spring-core-3.0.3.RELEASE.jar +0 -0
- data/apache-activemq-5.5.1/lib/optional/spring-expression-3.0.3.RELEASE.jar +0 -0
- data/apache-activemq-5.5.1/lib/optional/spring-jms-3.0.3.RELEASE.jar +0 -0
- data/apache-activemq-5.5.1/lib/optional/spring-oxm-tiger-1.5.8.jar +0 -0
- data/apache-activemq-5.5.1/lib/optional/spring-tx-3.0.3.RELEASE.jar +0 -0
- data/apache-activemq-5.5.1/lib/optional/stax2-api-3.0.1.jar +0 -0
- data/apache-activemq-5.5.1/lib/optional/velocity-1.6.2.jar +0 -0
- data/apache-activemq-5.5.1/lib/optional/woodstox-core-asl-4.0.7.jar +0 -0
- data/apache-activemq-5.5.1/lib/optional/xbean-spring-3.7.jar +0 -0
- data/apache-activemq-5.5.1/lib/optional/xpp3-1.1.4c.jar +0 -0
- data/apache-activemq-5.5.1/lib/optional/xstream-1.3.1.jar +0 -0
- data/apache-activemq-5.5.1/lib/slf4j-api-1.5.11.jar +0 -0
- data/apache-activemq-5.5.1/lib/stax-1.2.0.jar +0 -0
- data/apache-activemq-5.5.1/lib/stax-api-1.0.1.jar +0 -0
- data/apache-activemq-5.5.1/lib/web/commons-management-1.0.jar +0 -0
- data/apache-activemq-5.5.1/lib/web/core-3.1.1.jar +0 -0
- data/apache-activemq-5.5.1/lib/web/geronimo-servlet_2.5_spec-1.2.jar +0 -0
- data/apache-activemq-5.5.1/lib/web/jdom-1.0.jar +0 -0
- data/apache-activemq-5.5.1/lib/web/jetty-all-server-7.1.6.v20100715.jar +0 -0
- data/apache-activemq-5.5.1/lib/web/jetty-websocket-7.1.6.v20100715.jar +0 -0
- data/apache-activemq-5.5.1/lib/web/jsp-2.1-glassfish-2.1.v20100127.jar +0 -0
- data/apache-activemq-5.5.1/lib/web/jsp-api-2.1-glassfish-2.1.v20100127.jar +0 -0
- data/apache-activemq-5.5.1/lib/web/rome-0.8.jar +0 -0
- data/apache-activemq-5.5.1/lib/web/sitemesh-2.2.1.jar +0 -0
- data/apache-activemq-5.5.1/lib/web/spring-web-3.0.3.RELEASE.jar +0 -0
- data/apache-activemq-5.5.1/lib/web/spring-webmvc-3.0.3.RELEASE.jar +0 -0
- data/apache-activemq-5.5.1/user-guide.html +119 -0
- data/apache-activemq-5.5.1/webapps/admin/404.html +137 -0
- data/apache-activemq-5.5.1/webapps/admin/500.html +138 -0
- data/apache-activemq-5.5.1/webapps/admin/META-INF/LICENSE +1026 -0
- data/apache-activemq-5.5.1/webapps/admin/META-INF/NOTICE +107 -0
- data/apache-activemq-5.5.1/webapps/admin/WEB-INF/classes/org/apache/activemq/web/WebConsoleStarter.class +0 -0
- data/apache-activemq-5.5.1/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/CopyMessage.class +0 -0
- data/apache-activemq-5.5.1/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/CreateDestination.class +0 -0
- data/apache-activemq-5.5.1/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/CreateSubscriber.class +0 -0
- data/apache-activemq-5.5.1/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/DeleteDestination.class +0 -0
- data/apache-activemq-5.5.1/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/DeleteJob.class +0 -0
- data/apache-activemq-5.5.1/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/DeleteMessage.class +0 -0
- data/apache-activemq-5.5.1/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/DeleteSubscriber.class +0 -0
- data/apache-activemq-5.5.1/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/MoveMessage.class +0 -0
- data/apache-activemq-5.5.1/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/PurgeDestination.class +0 -0
- data/apache-activemq-5.5.1/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/SendMessage.class +0 -0
- data/apache-activemq-5.5.1/webapps/admin/WEB-INF/classes/org/apache/activemq/web/filter/ApplicationContextFilter$1.class +0 -0
- data/apache-activemq-5.5.1/webapps/admin/WEB-INF/classes/org/apache/activemq/web/filter/ApplicationContextFilter$2.class +0 -0
- data/apache-activemq-5.5.1/webapps/admin/WEB-INF/classes/org/apache/activemq/web/filter/ApplicationContextFilter.class +0 -0
- data/apache-activemq-5.5.1/webapps/admin/WEB-INF/classes/org/apache/activemq/web/handler/BindingBeanNameUrlHandlerMapping.class +0 -0
- data/apache-activemq-5.5.1/webapps/admin/WEB-INF/decorators.xml +30 -0
- data/apache-activemq-5.5.1/webapps/admin/WEB-INF/dispatcher-servlet.xml +62 -0
- data/apache-activemq-5.5.1/webapps/admin/WEB-INF/jspf/headertags.jspf +21 -0
- data/apache-activemq-5.5.1/webapps/admin/WEB-INF/jspf/old.jspf +21 -0
- data/apache-activemq-5.5.1/webapps/admin/WEB-INF/tags/form/checkbox.tag +18 -0
- data/apache-activemq-5.5.1/webapps/admin/WEB-INF/tags/form/forEachMapEntry.tag +29 -0
- data/apache-activemq-5.5.1/webapps/admin/WEB-INF/tags/form/option.tag +20 -0
- data/apache-activemq-5.5.1/webapps/admin/WEB-INF/tags/form/short.tag +29 -0
- data/apache-activemq-5.5.1/webapps/admin/WEB-INF/tags/form/text.tag +30 -0
- data/apache-activemq-5.5.1/webapps/admin/WEB-INF/tags/form/tooltip.tag +29 -0
- data/apache-activemq-5.5.1/webapps/admin/WEB-INF/tags/form/uri.tag +18 -0
- data/apache-activemq-5.5.1/webapps/admin/WEB-INF/tags/jms/forEachConnection.tag +35 -0
- data/apache-activemq-5.5.1/webapps/admin/WEB-INF/tags/jms/forEachMessage.tag +34 -0
- data/apache-activemq-5.5.1/webapps/admin/WEB-INF/tags/jms/formatTimestamp.tag +29 -0
- data/apache-activemq-5.5.1/webapps/admin/WEB-INF/tags/jms/persistent.tag +27 -0
- data/apache-activemq-5.5.1/webapps/admin/WEB-INF/web.xml +187 -0
- data/apache-activemq-5.5.1/webapps/admin/WEB-INF/webconsole-default.xml +26 -0
- data/apache-activemq-5.5.1/webapps/admin/WEB-INF/webconsole-embedded.xml +45 -0
- data/apache-activemq-5.5.1/webapps/admin/WEB-INF/webconsole-invm.xml +41 -0
- data/apache-activemq-5.5.1/webapps/admin/WEB-INF/webconsole-jndi.xml +39 -0
- data/apache-activemq-5.5.1/webapps/admin/WEB-INF/webconsole-properties.xml +39 -0
- data/apache-activemq-5.5.1/webapps/admin/WEB-INF/webconsole-query.xml +25 -0
- data/apache-activemq-5.5.1/webapps/admin/browse.jsp +64 -0
- data/apache-activemq-5.5.1/webapps/admin/connection.jsp +138 -0
- data/apache-activemq-5.5.1/webapps/admin/connections.jsp +85 -0
- data/apache-activemq-5.5.1/webapps/admin/decorators/main.jsp +165 -0
- data/apache-activemq-5.5.1/webapps/admin/decorators/panel.jsp +31 -0
- data/apache-activemq-5.5.1/webapps/admin/decorators/printable.jsp +31 -0
- data/apache-activemq-5.5.1/webapps/admin/graph.jsp +67 -0
- data/apache-activemq-5.5.1/webapps/admin/images/activemq-logo.png +0 -0
- data/apache-activemq-5.5.1/webapps/admin/images/asf-logo.png +0 -0
- data/apache-activemq-5.5.1/webapps/admin/images/big-bullet.png +0 -0
- data/apache-activemq-5.5.1/webapps/admin/images/black-footer-bottom.png +0 -0
- data/apache-activemq-5.5.1/webapps/admin/images/black-footer-left.png +0 -0
- data/apache-activemq-5.5.1/webapps/admin/images/black-footer-right.png +0 -0
- data/apache-activemq-5.5.1/webapps/admin/images/bottom-red-bar.png +0 -0
- data/apache-activemq-5.5.1/webapps/admin/images/checker-bg.png +0 -0
- data/apache-activemq-5.5.1/webapps/admin/images/content-left.png +0 -0
- data/apache-activemq-5.5.1/webapps/admin/images/content-right.png +0 -0
- data/apache-activemq-5.5.1/webapps/admin/images/feed_atom.png +0 -0
- data/apache-activemq-5.5.1/webapps/admin/images/feed_rss.png +0 -0
- data/apache-activemq-5.5.1/webapps/admin/images/left-box-bottom.png +0 -0
- data/apache-activemq-5.5.1/webapps/admin/images/left-box-right.png +0 -0
- data/apache-activemq-5.5.1/webapps/admin/images/left-box-top.png +0 -0
- data/apache-activemq-5.5.1/webapps/admin/images/oval-arrow.png +0 -0
- data/apache-activemq-5.5.1/webapps/admin/images/right-box-bottom.png +0 -0
- data/apache-activemq-5.5.1/webapps/admin/images/right-box-left.png +0 -0
- data/apache-activemq-5.5.1/webapps/admin/images/right-box-top.png +0 -0
- data/apache-activemq-5.5.1/webapps/admin/images/small-bullet-gray.png +0 -0
- data/apache-activemq-5.5.1/webapps/admin/images/small-bullet-red.png +0 -0
- data/apache-activemq-5.5.1/webapps/admin/images/spacer.gif +0 -0
- data/apache-activemq-5.5.1/webapps/admin/images/top-red-bar.png +0 -0
- data/apache-activemq-5.5.1/webapps/admin/images/white-header-left.png +0 -0
- data/apache-activemq-5.5.1/webapps/admin/images/white-header-right.png +0 -0
- data/apache-activemq-5.5.1/webapps/admin/images/white-header-top.png +0 -0
- data/apache-activemq-5.5.1/webapps/admin/index.jsp +65 -0
- data/apache-activemq-5.5.1/webapps/admin/js/common.js +121 -0
- data/apache-activemq-5.5.1/webapps/admin/js/css.js +145 -0
- data/apache-activemq-5.5.1/webapps/admin/js/mochi/MochiKit.js +4804 -0
- data/apache-activemq-5.5.1/webapps/admin/js/mochi/__package__.js +14 -0
- data/apache-activemq-5.5.1/webapps/admin/js/plotkit/Base.js +332 -0
- data/apache-activemq-5.5.1/webapps/admin/js/plotkit/Canvas.js +707 -0
- data/apache-activemq-5.5.1/webapps/admin/js/plotkit/Layout.js +588 -0
- data/apache-activemq-5.5.1/webapps/admin/js/plotkit/SVG.js +677 -0
- data/apache-activemq-5.5.1/webapps/admin/js/plotkit/SweetCanvas.js +281 -0
- data/apache-activemq-5.5.1/webapps/admin/js/plotkit/SweetSVG.js +196 -0
- data/apache-activemq-5.5.1/webapps/admin/js/plotkit/dummy.svg +15 -0
- data/apache-activemq-5.5.1/webapps/admin/js/plotkit/iecanvas.htc +389 -0
- data/apache-activemq-5.5.1/webapps/admin/js/prettify.js +1424 -0
- data/apache-activemq-5.5.1/webapps/admin/js/standardista-table-sorting.js +434 -0
- data/apache-activemq-5.5.1/webapps/admin/message.jsp +185 -0
- data/apache-activemq-5.5.1/webapps/admin/network.jsp +52 -0
- data/apache-activemq-5.5.1/webapps/admin/queueConsumers.jsp +79 -0
- data/apache-activemq-5.5.1/webapps/admin/queueGraph.jsp +68 -0
- data/apache-activemq-5.5.1/webapps/admin/queues.jsp +78 -0
- data/apache-activemq-5.5.1/webapps/admin/scheduled.jsp +67 -0
- data/apache-activemq-5.5.1/webapps/admin/send.jsp +173 -0
- data/apache-activemq-5.5.1/webapps/admin/styles/prettify.css +44 -0
- data/apache-activemq-5.5.1/webapps/admin/styles/site.css +206 -0
- data/apache-activemq-5.5.1/webapps/admin/styles/sorttable.css +70 -0
- data/apache-activemq-5.5.1/webapps/admin/styles/type-settings.css +177 -0
- data/apache-activemq-5.5.1/webapps/admin/subscribers.jsp +158 -0
- data/apache-activemq-5.5.1/webapps/admin/test/dummy.jsp +52 -0
- data/apache-activemq-5.5.1/webapps/admin/test/index.jsp +84 -0
- data/apache-activemq-5.5.1/webapps/admin/test/systemProperties.jsp +53 -0
- data/apache-activemq-5.5.1/webapps/admin/topics.jsp +66 -0
- data/apache-activemq-5.5.1/webapps/admin/xml/queues.jsp +34 -0
- data/apache-activemq-5.5.1/webapps/admin/xml/topics.jsp +29 -0
- data/apache-activemq-5.5.1/webapps/demo/META-INF/LICENSE +494 -0
- data/apache-activemq-5.5.1/webapps/demo/META-INF/NOTICE +82 -0
- data/apache-activemq-5.5.1/webapps/demo/WEB-INF/web.xml +111 -0
- data/apache-activemq-5.5.1/webapps/demo/chat.css +76 -0
- data/apache-activemq-5.5.1/webapps/demo/chat.html +219 -0
- data/apache-activemq-5.5.1/webapps/demo/index.html +181 -0
- data/apache-activemq-5.5.1/webapps/demo/js/amq.js +307 -0
- data/apache-activemq-5.5.1/webapps/demo/js/amq_dojo_adapter.js +84 -0
- data/apache-activemq-5.5.1/webapps/demo/js/amq_jquery_adapter.js +88 -0
- data/apache-activemq-5.5.1/webapps/demo/js/amq_prototype_adapter.js +84 -0
- data/apache-activemq-5.5.1/webapps/demo/js/chat.js +209 -0
- data/apache-activemq-5.5.1/webapps/demo/js/dojo.js +16 -0
- data/apache-activemq-5.5.1/webapps/demo/js/jquery-1.4.2.min.js +154 -0
- data/apache-activemq-5.5.1/webapps/demo/js/prototype.js +4874 -0
- data/apache-activemq-5.5.1/webapps/demo/portfolio/portfolio.html +87 -0
- data/apache-activemq-5.5.1/webapps/demo/portfolio/portfolio.js +91 -0
- data/apache-activemq-5.5.1/webapps/demo/sandbox/index.html +31 -0
- data/apache-activemq-5.5.1/webapps/demo/sandbox/portfolio.html +93 -0
- data/apache-activemq-5.5.1/webapps/demo/sandbox/portfolio.js +49 -0
- data/apache-activemq-5.5.1/webapps/demo/sandbox/util.js +52 -0
- data/apache-activemq-5.5.1/webapps/demo/sandbox/webmq.js +149 -0
- data/apache-activemq-5.5.1/webapps/demo/send.html +51 -0
- data/apache-activemq-5.5.1/webapps/demo/style.css +440 -0
- data/apache-activemq-5.5.1/webapps/demo/test/amq_test.html +311 -0
- data/apache-activemq-5.5.1/webapps/demo/test/assets/README +4 -0
- data/apache-activemq-5.5.1/webapps/demo/test/assets/jsunittest.js +1017 -0
- data/apache-activemq-5.5.1/webapps/demo/test/assets/unittest.css +54 -0
- data/apache-activemq-5.5.1/webapps/favicon.ico +0 -0
- data/apache-activemq-5.5.1/webapps/fileserver/META-INF/LICENSE +203 -0
- data/apache-activemq-5.5.1/webapps/fileserver/META-INF/NOTICE +5 -0
- data/apache-activemq-5.5.1/webapps/fileserver/WEB-INF/classes/org/apache/activemq/util/FilenameGuardFilter$GuardedHttpServletRequest.class +0 -0
- data/apache-activemq-5.5.1/webapps/fileserver/WEB-INF/classes/org/apache/activemq/util/FilenameGuardFilter.class +0 -0
- data/apache-activemq-5.5.1/webapps/fileserver/WEB-INF/classes/org/apache/activemq/util/IOHelper.class +0 -0
- data/apache-activemq-5.5.1/webapps/fileserver/WEB-INF/classes/org/apache/activemq/util/RestFilter.class +0 -0
- data/apache-activemq-5.5.1/webapps/fileserver/WEB-INF/web.xml +56 -0
- data/apache-activemq-5.5.1/webapps/fileserver/index.html +30 -0
- data/apache-activemq-5.5.1/webapps/index.html +145 -0
- data/apache-activemq-5.5.1/webapps/styles/site.css +206 -0
- data/apache-activemq-5.5.1/webapps/styles/type-settings.css +177 -0
- data/lib/activemq.rb +11 -0
- metadata +382 -0
@@ -0,0 +1,15 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
+
<!--
|
3
|
+
Copyright
|
4
|
+
---------
|
5
|
+
Copyright 2005,2006 (c) Alastair Tse <alastair^liquidx.net>
|
6
|
+
For use under the BSD license. <http://www.liquidx.net/plotkit>
|
7
|
+
-->
|
8
|
+
<svg
|
9
|
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
10
|
+
xmlns:cc="http://web.resource.org/cc/"
|
11
|
+
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
12
|
+
xmlns:svg="http://www.w3.org/2000/svg"
|
13
|
+
xmlns="http://www.w3.org/2000/svg"
|
14
|
+
xmlns:xlink="http://www.w3.org/1999/xlink">
|
15
|
+
</svg>
|
@@ -0,0 +1,389 @@
|
|
1
|
+
/*----------------------------------------------------------------------------\
|
2
|
+
| IE Canvas 1.0 |
|
3
|
+
|-----------------------------------------------------------------------------|
|
4
|
+
| Created by Emil A Eklund |
|
5
|
+
| (http://eae.net/contact/emil) |
|
6
|
+
|-----------------------------------------------------------------------------|
|
7
|
+
| Implementation of the canvas API for Internet Explorer. Uses VML. |
|
8
|
+
|-----------------------------------------------------------------------------|
|
9
|
+
| Copyright (c) 2005 Emil A Eklund |
|
10
|
+
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -|
|
11
|
+
| This program is free software; you can redistribute it and/or modify it |
|
12
|
+
| under the terms of the MIT License. |
|
13
|
+
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -|
|
14
|
+
| Permission is hereby granted, free of charge, to any person obtaining a |
|
15
|
+
| copy of this software and associated documentation files (the "Software"), |
|
16
|
+
| to deal in the Software without restriction, including without limitation |
|
17
|
+
| the rights to use, copy, modify, merge, publish, distribute, sublicense, |
|
18
|
+
| and/or sell copies of the Software, and to permit persons to whom the |
|
19
|
+
| Software is furnished to do so, subject to the following conditions: |
|
20
|
+
| The above copyright notice and this permission notice shall be included in |
|
21
|
+
| all copies or substantial portions of the Software. |
|
22
|
+
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -|
|
23
|
+
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
24
|
+
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
25
|
+
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
26
|
+
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
27
|
+
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
28
|
+
| FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
|
29
|
+
| DEALINGS IN THE SOFTWARE. |
|
30
|
+
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -|
|
31
|
+
| http://eae.net/license/mit |
|
32
|
+
|-----------------------------------------------------------------------------|
|
33
|
+
| Dependencies: canvas.js - For initialization of canvas elements |
|
34
|
+
|-----------------------------------------------------------------------------|
|
35
|
+
| 2005-12-27 | Work started. |
|
36
|
+
| 2005-12-29 | First version posted. |
|
37
|
+
| 2006-01-03 | Fixed bug in moveTo and lineTo, arguments where not converted |
|
38
|
+
| | to int which could cause IE to enter an endless loop. Disabled |
|
39
|
+
| | antalias for fillRect to better comply with the Mozilla, Opera |
|
40
|
+
| | and possibly Safari implementations where using fillRect is |
|
41
|
+
| | about the only way to raw non antialiased lines. |
|
42
|
+
|-----------------------------------------------------------------------------|
|
43
|
+
| Created 2005-12-27 | All changes are in the log above. | Updated 2006-01-03 |
|
44
|
+
\----------------------------------------------------------------------------*/
|
45
|
+
|
46
|
+
<public:component>
|
47
|
+
<public:method name="getContext" />
|
48
|
+
<public:attach event="oncontentready" onevent="initCanvas()"/>
|
49
|
+
</public:component>
|
50
|
+
|
51
|
+
<script language="JScript">
|
52
|
+
|
53
|
+
function getContext() {
|
54
|
+
return element.context;
|
55
|
+
}
|
56
|
+
|
57
|
+
function initCanvas() {
|
58
|
+
element.context = new IECanvasContext();
|
59
|
+
element.style.position = 'relative';
|
60
|
+
element.style.display = 'block';
|
61
|
+
element.style.overflow = 'hidden';
|
62
|
+
}
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
function IECanvasContext() {
|
67
|
+
this.fillStyle = 'black';
|
68
|
+
this.globalAlpha = 1.0;
|
69
|
+
this.globalCompositeOperation = '';
|
70
|
+
this.lineCap = '';
|
71
|
+
this.lineJoin = '';
|
72
|
+
this.lineWidth = '0';
|
73
|
+
this.miterLimit = '';
|
74
|
+
this.shadowBlur = '';
|
75
|
+
this.shadowColor = '';
|
76
|
+
this.shadowOffsetX = '';
|
77
|
+
this.shadowOffsetY = '';
|
78
|
+
this.strokeStyle = 'black';
|
79
|
+
this._path = '';
|
80
|
+
this._stateStack = new Array();
|
81
|
+
this._offsetX = 0;
|
82
|
+
this._offsetY = 0;
|
83
|
+
this._rotation = 0;
|
84
|
+
};
|
85
|
+
|
86
|
+
IECanvasContext.prototype.save = function() {
|
87
|
+
var o;
|
88
|
+
|
89
|
+
o = new Object();
|
90
|
+
this._copyState(this, o);
|
91
|
+
this._stateStack.push(o);
|
92
|
+
};
|
93
|
+
|
94
|
+
IECanvasContext.prototype.restore = function() {
|
95
|
+
var o, n;
|
96
|
+
|
97
|
+
n = this._stateStack.length - 1;
|
98
|
+
if (n < 0) { return; }
|
99
|
+
|
100
|
+
o = this._stateStack[n];
|
101
|
+
this._copyState(o, this);
|
102
|
+
this._stateStack.splice(n, 1);
|
103
|
+
};
|
104
|
+
|
105
|
+
IECanvasContext.prototype._copyState = function(oFrom, oTo) {
|
106
|
+
oTo.fillStyle = oFrom.fillStyle;
|
107
|
+
oTo.lineCap = oFrom.lineCap;
|
108
|
+
oTo.lineJoin = oFrom.lineJoin;
|
109
|
+
oTo.lineWidth = oFrom.lineWidth;
|
110
|
+
oTo.miterLimit = oFrom.miterLimit;
|
111
|
+
oTo.shadowBlur = oFrom.shadowBlur;
|
112
|
+
oTo.shadowColor = oFrom.shadowColor;
|
113
|
+
oTo.shadowOffsetX = oFrom.shadowOffsetX;
|
114
|
+
oTo.shadowOffsetY = oFrom.shadowOffsetY;
|
115
|
+
oTo._offsetX = oFrom._offsetX;
|
116
|
+
oTo._offsetY = oFrom._offsetY;
|
117
|
+
oTo._rotation = oFrom._rotation;
|
118
|
+
};
|
119
|
+
|
120
|
+
IECanvasContext.prototype.rotate = function(r) {
|
121
|
+
var MAX = Math.PI * 2;
|
122
|
+
|
123
|
+
this._rotation += r;
|
124
|
+
while (this._rotation > MAX) { this._rotation = MAX - this._rotation; }
|
125
|
+
};
|
126
|
+
|
127
|
+
IECanvasContext.prototype.scale = function() { };
|
128
|
+
|
129
|
+
IECanvasContext.prototype.translate = function(x, y) {
|
130
|
+
this._offsetX += x;
|
131
|
+
this._offsetY += y;
|
132
|
+
};
|
133
|
+
|
134
|
+
IECanvasContext.prototype.bezierCurveTo = function(cp1x, cp1y, cp2x, cp2y, x, y) {
|
135
|
+
if (this._path) { this._path += ' '; }
|
136
|
+
|
137
|
+
this._path += 'qb' + cp1x + ',' + cp1y + ',' + cp2x + ',' + cp2y + ',' + x + ',' + y;
|
138
|
+
};
|
139
|
+
|
140
|
+
|
141
|
+
IECanvasContext.prototype.clip = function() { };
|
142
|
+
|
143
|
+
IECanvasContext.prototype.beginPath = function() {
|
144
|
+
this._path = '';
|
145
|
+
};
|
146
|
+
|
147
|
+
IECanvasContext.prototype.closePath = function() {
|
148
|
+
if (this._path) { this._path += ' '; }
|
149
|
+
this._path += 'x';
|
150
|
+
};
|
151
|
+
|
152
|
+
IECanvasContext.prototype.lineTo = function(x, y) {
|
153
|
+
if (this._path) { this._path += ' '; }
|
154
|
+
this._path += 'l' + parseInt(x) + ',' + parseInt(y);
|
155
|
+
};
|
156
|
+
|
157
|
+
IECanvasContext.prototype.moveTo = function(x, y) {
|
158
|
+
if (this._path) { this._path += ' '; }
|
159
|
+
this._path += 'm' + parseInt(x) + ',' + parseInt(y);
|
160
|
+
};
|
161
|
+
|
162
|
+
IECanvasContext.prototype.stroke = function() {
|
163
|
+
var o, s, cosa, sina, cx, cy, x, y;
|
164
|
+
|
165
|
+
if (!this._path) { return; }
|
166
|
+
|
167
|
+
this._path += ' e';
|
168
|
+
|
169
|
+
o = element.ownerDocument.createElement('v:shape');
|
170
|
+
o.fillColor = 'none';
|
171
|
+
o.filled = false;
|
172
|
+
o.strokeColor = this.strokeStyle;
|
173
|
+
o.stroked = true;
|
174
|
+
o.weight = this.lineWidth;
|
175
|
+
o.coordsize = element.offsetWidth + ',' + element.offsetHeight;
|
176
|
+
o.style.position = 'absolute';
|
177
|
+
o.style.left = this._offsetX;
|
178
|
+
o.style.top = this._offsetY;
|
179
|
+
o.style.width = element.offsetWidth;
|
180
|
+
o.style.height = element.offsetHeight;
|
181
|
+
o.path = this._path;
|
182
|
+
|
183
|
+
s = element.ownerDocument.createElement('v:stroke');
|
184
|
+
s.opacity = this.globalAlpha;
|
185
|
+
o.appendChild(s);
|
186
|
+
|
187
|
+
if (this._rotation) {
|
188
|
+
r = element.ownerDocument.createElement('v:group');
|
189
|
+
r.style.position = 'absolute';
|
190
|
+
r.style.left = 0;
|
191
|
+
r.style.top = 0;
|
192
|
+
r.style.width = element.offsetWidth;
|
193
|
+
r.style.height = element.offsetHeight;
|
194
|
+
r.coordsize = o.coordsize;
|
195
|
+
r.style.rotation = Math.round((this._rotation * 180) / Math.PI);
|
196
|
+
r.style.rotationCenter = '0,0';
|
197
|
+
r.appendChild(o);
|
198
|
+
element.appendChild(r);
|
199
|
+
|
200
|
+
cosa = Math.cos(this._rotation);
|
201
|
+
sina = Math.sin(this._rotation);
|
202
|
+
cx = element.offsetWidth / 2;
|
203
|
+
cy = element.offsetHeight / 2;
|
204
|
+
|
205
|
+
x = ( cx*(1-cosa) + cy*sina);
|
206
|
+
y = (-cx*sina + cy*(1-cosa));
|
207
|
+
|
208
|
+
r.style.left = x * -1;
|
209
|
+
r.style.top = y * -1;
|
210
|
+
}
|
211
|
+
else { element.appendChild(o); }
|
212
|
+
};
|
213
|
+
|
214
|
+
IECanvasContext.prototype.fill = function() {
|
215
|
+
var o, f, r;
|
216
|
+
|
217
|
+
if (!this._path) { return; }
|
218
|
+
|
219
|
+
this._path += ' e';
|
220
|
+
|
221
|
+
o = element.ownerDocument.createElement('v:shape');
|
222
|
+
o.fillColor = this.fillStyle;
|
223
|
+
o.strokeColor = this.strokeStyle;
|
224
|
+
o.stroked = false;
|
225
|
+
o.weight = this.lineWidth;
|
226
|
+
o.coordsize = element.offsetWidth + ',' + element.offsetHeight;
|
227
|
+
o.style.position = 'absolute';
|
228
|
+
o.style.left = this._offsetX;
|
229
|
+
o.style.top = this._offsetY;
|
230
|
+
o.style.width = element.offsetWidth;
|
231
|
+
o.style.height = element.offsetHeight;
|
232
|
+
o.path = this._path;
|
233
|
+
|
234
|
+
f = element.ownerDocument.createElement('v:fill');
|
235
|
+
f.opacity = this.globalAlpha;
|
236
|
+
o.appendChild(f);
|
237
|
+
|
238
|
+
if (this._rotation) {
|
239
|
+
r = element.ownerDocument.createElement('v:group');
|
240
|
+
r.style.position = 'absolute';
|
241
|
+
r.style.left = 0;
|
242
|
+
r.style.top = 0;
|
243
|
+
r.style.width = element.offsetWidth;
|
244
|
+
r.style.height = element.offsetHeight;
|
245
|
+
r.coordsize = o.coordsize;
|
246
|
+
r.style.rotation = Math.round((this._rotation * 180) / Math.PI);
|
247
|
+
r.style.rotationCenter = '0,0';
|
248
|
+
r.appendChild(o);
|
249
|
+
element.appendChild(r);
|
250
|
+
|
251
|
+
cosa = Math.cos(this._rotation);
|
252
|
+
sina = Math.sin(this._rotation);
|
253
|
+
cx = (element.offsetWidth) / 2;
|
254
|
+
cy = (element.offsetHeight) / 2;
|
255
|
+
x = ( cx*(1-cosa) + cy*sina);
|
256
|
+
y = (-cx*sina + cy*(1-cosa));
|
257
|
+
|
258
|
+
r.style.left = x * -1;
|
259
|
+
r.style.top = y * -1;
|
260
|
+
}
|
261
|
+
else { element.appendChild(o); }
|
262
|
+
};
|
263
|
+
|
264
|
+
IECanvasContext.prototype.arcTo = function(x1, y1, x2, y2, radius) {
|
265
|
+
// not implemented in gecko, not implemented here
|
266
|
+
};
|
267
|
+
|
268
|
+
IECanvasContext.prototype.quadraticCurveTo = function(cpx, cpy, x, y) {
|
269
|
+
if (this._path) { this._path += ' '; }
|
270
|
+
|
271
|
+
this._path += 'qb' + cpx + ',' + cpy + ',' + x + ',' + y;
|
272
|
+
};
|
273
|
+
|
274
|
+
IECanvasContext.prototype.arc = function(x, y, radius, startAngle, endAngle, clockwise) {
|
275
|
+
var xi, yi, x1, y1, x2, y2, x3, y3, x4, y4;
|
276
|
+
|
277
|
+
if (this._path) { this._path += ' '; }
|
278
|
+
|
279
|
+
xi = parseFloat(x);
|
280
|
+
yi = parseFloat(y);
|
281
|
+
|
282
|
+
x1 = xi - radius;
|
283
|
+
y1 = yi - radius;
|
284
|
+
|
285
|
+
x2 = xi + radius;
|
286
|
+
y2 = yi + radius;
|
287
|
+
|
288
|
+
if (clockwise) {
|
289
|
+
x3 = xi + (Math.cos(startAngle) * radius);
|
290
|
+
y3 = yi + (Math.sin(startAngle) * radius);
|
291
|
+
|
292
|
+
x4 = xi + (Math.cos(endAngle) * radius);
|
293
|
+
y4 = yi + (Math.sin(endAngle) * radius);
|
294
|
+
}
|
295
|
+
else {
|
296
|
+
x3 = xi + (Math.cos(endAngle) * radius);
|
297
|
+
y3 = yi + (Math.sin(endAngle) * radius);
|
298
|
+
|
299
|
+
x4 = xi + (Math.cos(startAngle) * radius);
|
300
|
+
y4 = yi + (Math.sin(startAngle) * radius);
|
301
|
+
}
|
302
|
+
|
303
|
+
x3 = Math.round(x3);
|
304
|
+
y3 = Math.round(y3);
|
305
|
+
x4 = Math.round(x4);
|
306
|
+
y4 = Math.round(y4);
|
307
|
+
|
308
|
+
this._path += 'ar' + x1 + ',' + y1 + ',' + x2 + ',' + y2 + ',' + x3 + ',' + y3 + ',' + x4 + ',' + y4;
|
309
|
+
};
|
310
|
+
|
311
|
+
|
312
|
+
IECanvasContext.prototype.rect = function(x, y, w, h) {
|
313
|
+
var x1, y1, x2, y2;
|
314
|
+
|
315
|
+
x2 = x + w;
|
316
|
+
y2 = y + h;
|
317
|
+
|
318
|
+
x1 = Math.round(x);
|
319
|
+
y1 = Math.round(y);
|
320
|
+
x2 = Math.round(x2);
|
321
|
+
y2 = Math.round(y2);
|
322
|
+
|
323
|
+
this._path += 'm' + x1 + ',' + y1;
|
324
|
+
this._path += ' l' + x2 + ',' + y1;
|
325
|
+
this._path += ' l' + x2 + ',' + y2;
|
326
|
+
this._path += ' l' + x1 + ',' + y2;
|
327
|
+
this._path += ' x'
|
328
|
+
};
|
329
|
+
|
330
|
+
IECanvasContext.prototype.strokeRect = function(x, y, w, h) {
|
331
|
+
var o, s;
|
332
|
+
|
333
|
+
o = element.ownerDocument.createElement('v:rect');
|
334
|
+
o.fillColor = 'none';
|
335
|
+
o.filled = false;
|
336
|
+
o.strokeColor = this.strokeStyle;
|
337
|
+
o.stroked = true;
|
338
|
+
o.weight = this.lineWidth;
|
339
|
+
o.style.position = 'absolute';
|
340
|
+
o.style.left = this._offsetX + x;
|
341
|
+
o.style.top = this._offsetY + y;
|
342
|
+
o.style.width = w;
|
343
|
+
o.style.height = h;
|
344
|
+
|
345
|
+
s = element.ownerDocument.createElement('v:fill');
|
346
|
+
s.opacity = this.globalAlpha;
|
347
|
+
o.appendChild(s);
|
348
|
+
|
349
|
+
element.appendChild(o);
|
350
|
+
};
|
351
|
+
|
352
|
+
IECanvasContext.prototype.clearRect = function(x, y, w, h) { };
|
353
|
+
|
354
|
+
|
355
|
+
IECanvasContext.prototype.fillRect = function(x, y, w, h) {
|
356
|
+
var o, f;
|
357
|
+
|
358
|
+
if ((x == 0) && (y == 0) && (w == element.offsetWidth) && (h == element.offsetHeight) && (this._offsetX == 0) && (this._offsetY == 0) && (this.globalAlpha == 1)) {
|
359
|
+
while (element.firstChild) { element.removeChild(element.lastChild); }
|
360
|
+
}
|
361
|
+
|
362
|
+
o = element.ownerDocument.createElement('v:rect');
|
363
|
+
o.fillColor = this.fillStyle;
|
364
|
+
o.filled = true;
|
365
|
+
o.stroked = false;
|
366
|
+
o.weight = 0;
|
367
|
+
o.style.position = 'absolute';
|
368
|
+
o.style.left = this._offsetX + x;
|
369
|
+
o.style.top = this._offsetY + y;
|
370
|
+
o.style.width = w;
|
371
|
+
o.style.height = h;
|
372
|
+
o.style.antialias = 'false';
|
373
|
+
|
374
|
+
f = element.ownerDocument.createElement('v:fill');
|
375
|
+
f.opacity = this.globalAlpha;
|
376
|
+
o.appendChild(f);
|
377
|
+
|
378
|
+
element.appendChild(o);
|
379
|
+
};
|
380
|
+
|
381
|
+
IECanvasContext.prototype.addColorStop = function() { };
|
382
|
+
IECanvasContext.prototype.createLinearGradient = function() { };
|
383
|
+
IECanvasContext.prototype.createPattern = function() { };
|
384
|
+
IECanvasContext.prototype.createRadialGradient = function() { };
|
385
|
+
|
386
|
+
IECanvasContext.prototype.drawImage = function() { };
|
387
|
+
IECanvasContext.prototype.drawImageFromRect = function() { };
|
388
|
+
|
389
|
+
</script>
|
@@ -0,0 +1,1424 @@
|
|
1
|
+
// Copyright (C) 2006 Google Inc.
|
2
|
+
//
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
// you may not use this file except in compliance with the License.
|
5
|
+
// You may obtain a copy of the License at
|
6
|
+
//
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
//
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
// See the License for the specific language governing permissions and
|
13
|
+
// limitations under the License.
|
14
|
+
|
15
|
+
|
16
|
+
/**
|
17
|
+
* @fileoverview
|
18
|
+
* some functions for browser-side pretty printing of code contained in html.
|
19
|
+
*
|
20
|
+
* The lexer should work on a number of languages including C and friends,
|
21
|
+
* Java, Python, Bash, SQL, HTML, XML, CSS, Javascript, and Makefiles.
|
22
|
+
* It works passably on Ruby, PHP and Awk and a decent subset of Perl, but,
|
23
|
+
* because of commenting conventions, doesn't work on Smalltalk, Lisp-like, or
|
24
|
+
* CAML-like languages.
|
25
|
+
*
|
26
|
+
* If there's a language not mentioned here, then I don't know it, and don't
|
27
|
+
* know whether it works. If it has a C-like, Bash-like, or XML-like syntax
|
28
|
+
* then it should work passably.
|
29
|
+
*
|
30
|
+
* Usage:
|
31
|
+
* 1) include this source file in an html page via
|
32
|
+
* <script type="text/javascript" src="/path/to/prettify.js"></script>
|
33
|
+
* 2) define style rules. See the example page for examples.
|
34
|
+
* 3) mark the <pre> and <code> tags in your source with class=prettyprint.
|
35
|
+
* You can also use the (html deprecated) <xmp> tag, but the pretty printer
|
36
|
+
* needs to do more substantial DOM manipulations to support that, so some
|
37
|
+
* css styles may not be preserved.
|
38
|
+
* That's it. I wanted to keep the API as simple as possible, so there's no
|
39
|
+
* need to specify which language the code is in.
|
40
|
+
*
|
41
|
+
* Change log:
|
42
|
+
* cbeust, 2006/08/22
|
43
|
+
* Java annotations (start with "@") are now captured as literals ("lit")
|
44
|
+
*/
|
45
|
+
|
46
|
+
// JSLint declarations
|
47
|
+
/*global console, document, navigator, setTimeout, window */
|
48
|
+
|
49
|
+
/**
|
50
|
+
* Split {@code prettyPrint} into multiple timeouts so as not to interfere with
|
51
|
+
* UI events.
|
52
|
+
* If set to {@code false}, {@code prettyPrint()} is synchronous.
|
53
|
+
*/
|
54
|
+
window['PR_SHOULD_USE_CONTINUATION'] = true;
|
55
|
+
|
56
|
+
/** the number of characters between tab columns */
|
57
|
+
window['PR_TAB_WIDTH'] = 8;
|
58
|
+
|
59
|
+
/** Walks the DOM returning a properly escaped version of innerHTML.
|
60
|
+
* @param {Node} node
|
61
|
+
* @param {Array.<string>} out output buffer that receives chunks of HTML.
|
62
|
+
*/
|
63
|
+
window['PR_normalizedHtml']
|
64
|
+
|
65
|
+
/** Contains functions for creating and registering new language handlers.
|
66
|
+
* @type {Object}
|
67
|
+
*/
|
68
|
+
= window['PR']
|
69
|
+
|
70
|
+
/** Pretty print a chunk of code.
|
71
|
+
*
|
72
|
+
* @param {string} sourceCodeHtml code as html
|
73
|
+
* @return {string} code as html, but prettier
|
74
|
+
*/
|
75
|
+
= window['prettyPrintOne']
|
76
|
+
/** Find all the {@code <pre>} and {@code <code>} tags in the DOM with
|
77
|
+
* {@code class=prettyprint} and prettify them.
|
78
|
+
* @param {Function?} opt_whenDone if specified, called when the last entry
|
79
|
+
* has been finished.
|
80
|
+
*/
|
81
|
+
= window['prettyPrint'] = void 0;
|
82
|
+
|
83
|
+
/** browser detection. @extern */
|
84
|
+
window['_pr_isIE6'] = function () {
|
85
|
+
var isIE6 = navigator && navigator.userAgent &&
|
86
|
+
/\bMSIE 6\./.test(navigator.userAgent);
|
87
|
+
window['_pr_isIE6'] = function () { return isIE6; };
|
88
|
+
return isIE6;
|
89
|
+
};
|
90
|
+
|
91
|
+
|
92
|
+
(function () {
|
93
|
+
// Keyword lists for various languages.
|
94
|
+
var FLOW_CONTROL_KEYWORDS =
|
95
|
+
"break continue do else for if return while ";
|
96
|
+
var C_KEYWORDS = FLOW_CONTROL_KEYWORDS + "auto case char const default " +
|
97
|
+
"double enum extern float goto int long register short signed sizeof " +
|
98
|
+
"static struct switch typedef union unsigned void volatile ";
|
99
|
+
var COMMON_KEYWORDS = C_KEYWORDS + "catch class delete false import " +
|
100
|
+
"new operator private protected public this throw true try ";
|
101
|
+
var CPP_KEYWORDS = COMMON_KEYWORDS + "alignof align_union asm axiom bool " +
|
102
|
+
"concept concept_map const_cast constexpr decltype " +
|
103
|
+
"dynamic_cast explicit export friend inline late_check " +
|
104
|
+
"mutable namespace nullptr reinterpret_cast static_assert static_cast " +
|
105
|
+
"template typeid typename typeof using virtual wchar_t where ";
|
106
|
+
var JAVA_KEYWORDS = COMMON_KEYWORDS +
|
107
|
+
"boolean byte extends final finally implements import instanceof null " +
|
108
|
+
"native package strictfp super synchronized throws transient ";
|
109
|
+
var CSHARP_KEYWORDS = JAVA_KEYWORDS +
|
110
|
+
"as base by checked decimal delegate descending event " +
|
111
|
+
"fixed foreach from group implicit in interface internal into is lock " +
|
112
|
+
"object out override orderby params partial readonly ref sbyte sealed " +
|
113
|
+
"stackalloc string select uint ulong unchecked unsafe ushort var ";
|
114
|
+
var JSCRIPT_KEYWORDS = COMMON_KEYWORDS +
|
115
|
+
"debugger eval export function get null set undefined var with " +
|
116
|
+
"Infinity NaN ";
|
117
|
+
var PERL_KEYWORDS = "caller delete die do dump elsif eval exit foreach for " +
|
118
|
+
"goto if import last local my next no our print package redo require " +
|
119
|
+
"sub undef unless until use wantarray while BEGIN END ";
|
120
|
+
var PYTHON_KEYWORDS = FLOW_CONTROL_KEYWORDS + "and as assert class def del " +
|
121
|
+
"elif except exec finally from global import in is lambda " +
|
122
|
+
"nonlocal not or pass print raise try with yield " +
|
123
|
+
"False True None ";
|
124
|
+
var RUBY_KEYWORDS = FLOW_CONTROL_KEYWORDS + "alias and begin case class def" +
|
125
|
+
" defined elsif end ensure false in module next nil not or redo rescue " +
|
126
|
+
"retry self super then true undef unless until when yield BEGIN END ";
|
127
|
+
var SH_KEYWORDS = FLOW_CONTROL_KEYWORDS + "case done elif esac eval fi " +
|
128
|
+
"function in local set then until ";
|
129
|
+
var ALL_KEYWORDS = (
|
130
|
+
CPP_KEYWORDS + CSHARP_KEYWORDS + JSCRIPT_KEYWORDS + PERL_KEYWORDS +
|
131
|
+
PYTHON_KEYWORDS + RUBY_KEYWORDS + SH_KEYWORDS);
|
132
|
+
|
133
|
+
// token style names. correspond to css classes
|
134
|
+
/** token style for a string literal */
|
135
|
+
var PR_STRING = 'str';
|
136
|
+
/** token style for a keyword */
|
137
|
+
var PR_KEYWORD = 'kwd';
|
138
|
+
/** token style for a comment */
|
139
|
+
var PR_COMMENT = 'com';
|
140
|
+
/** token style for a type */
|
141
|
+
var PR_TYPE = 'typ';
|
142
|
+
/** token style for a literal value. e.g. 1, null, true. */
|
143
|
+
var PR_LITERAL = 'lit';
|
144
|
+
/** token style for a punctuation string. */
|
145
|
+
var PR_PUNCTUATION = 'pun';
|
146
|
+
/** token style for a punctuation string. */
|
147
|
+
var PR_PLAIN = 'pln';
|
148
|
+
|
149
|
+
/** token style for an sgml tag. */
|
150
|
+
var PR_TAG = 'tag';
|
151
|
+
/** token style for a markup declaration such as a DOCTYPE. */
|
152
|
+
var PR_DECLARATION = 'dec';
|
153
|
+
/** token style for embedded source. */
|
154
|
+
var PR_SOURCE = 'src';
|
155
|
+
/** token style for an sgml attribute name. */
|
156
|
+
var PR_ATTRIB_NAME = 'atn';
|
157
|
+
/** token style for an sgml attribute value. */
|
158
|
+
var PR_ATTRIB_VALUE = 'atv';
|
159
|
+
|
160
|
+
/**
|
161
|
+
* A class that indicates a section of markup that is not code, e.g. to allow
|
162
|
+
* embedding of line numbers within code listings.
|
163
|
+
*/
|
164
|
+
var PR_NOCODE = 'nocode';
|
165
|
+
|
166
|
+
/** A set of tokens that can precede a regular expression literal in
|
167
|
+
* javascript.
|
168
|
+
* http://www.mozilla.org/js/language/js20/rationale/syntax.html has the full
|
169
|
+
* list, but I've removed ones that might be problematic when seen in
|
170
|
+
* languages that don't support regular expression literals.
|
171
|
+
*
|
172
|
+
* <p>Specifically, I've removed any keywords that can't precede a regexp
|
173
|
+
* literal in a syntactically legal javascript program, and I've removed the
|
174
|
+
* "in" keyword since it's not a keyword in many languages, and might be used
|
175
|
+
* as a count of inches.
|
176
|
+
*
|
177
|
+
* <p>The link a above does not accurately describe EcmaScript rules since
|
178
|
+
* it fails to distinguish between (a=++/b/i) and (a++/b/i) but it works
|
179
|
+
* very well in practice.
|
180
|
+
*
|
181
|
+
* @private
|
182
|
+
*/
|
183
|
+
var REGEXP_PRECEDER_PATTERN = function () {
|
184
|
+
var preceders = [
|
185
|
+
"!", "!=", "!==", "#", "%", "%=", "&", "&&", "&&=",
|
186
|
+
"&=", "(", "*", "*=", /* "+", */ "+=", ",", /* "-", */ "-=",
|
187
|
+
"->", /*".", "..", "...", handled below */ "/", "/=", ":", "::", ";",
|
188
|
+
"<", "<<", "<<=", "<=", "=", "==", "===", ">",
|
189
|
+
">=", ">>", ">>=", ">>>", ">>>=", "?", "@", "[",
|
190
|
+
"^", "^=", "^^", "^^=", "{", "|", "|=", "||",
|
191
|
+
"||=", "~" /* handles =~ and !~ */,
|
192
|
+
"break", "case", "continue", "delete",
|
193
|
+
"do", "else", "finally", "instanceof",
|
194
|
+
"return", "throw", "try", "typeof"
|
195
|
+
];
|
196
|
+
var pattern = '(?:^^|[+-]';
|
197
|
+
for (var i = 0; i < preceders.length; ++i) {
|
198
|
+
pattern += '|' + preceders[i].replace(/([^=<>:&a-z])/g, '\\$1');
|
199
|
+
}
|
200
|
+
pattern += ')\\s*'; // matches at end, and matches empty string
|
201
|
+
return pattern;
|
202
|
+
// CAVEAT: this does not properly handle the case where a regular
|
203
|
+
// expression immediately follows another since a regular expression may
|
204
|
+
// have flags for case-sensitivity and the like. Having regexp tokens
|
205
|
+
// adjacent is not valid in any language I'm aware of, so I'm punting.
|
206
|
+
// TODO: maybe style special characters inside a regexp as punctuation.
|
207
|
+
}();
|
208
|
+
|
209
|
+
// Define regexps here so that the interpreter doesn't have to create an
|
210
|
+
// object each time the function containing them is called.
|
211
|
+
// The language spec requires a new object created even if you don't access
|
212
|
+
// the $1 members.
|
213
|
+
var pr_amp = /&/g;
|
214
|
+
var pr_lt = /</g;
|
215
|
+
var pr_gt = />/g;
|
216
|
+
var pr_quot = /\"/g;
|
217
|
+
/** like textToHtml but escapes double quotes to be attribute safe. */
|
218
|
+
function attribToHtml(str) {
|
219
|
+
return str.replace(pr_amp, '&')
|
220
|
+
.replace(pr_lt, '<')
|
221
|
+
.replace(pr_gt, '>')
|
222
|
+
.replace(pr_quot, '"');
|
223
|
+
}
|
224
|
+
|
225
|
+
/** escapest html special characters to html. */
|
226
|
+
function textToHtml(str) {
|
227
|
+
return str.replace(pr_amp, '&')
|
228
|
+
.replace(pr_lt, '<')
|
229
|
+
.replace(pr_gt, '>');
|
230
|
+
}
|
231
|
+
|
232
|
+
|
233
|
+
var pr_ltEnt = /</g;
|
234
|
+
var pr_gtEnt = />/g;
|
235
|
+
var pr_aposEnt = /'/g;
|
236
|
+
var pr_quotEnt = /"/g;
|
237
|
+
var pr_ampEnt = /&/g;
|
238
|
+
var pr_nbspEnt = / /g;
|
239
|
+
/** unescapes html to plain text. */
|
240
|
+
function htmlToText(html) {
|
241
|
+
var pos = html.indexOf('&');
|
242
|
+
if (pos < 0) { return html; }
|
243
|
+
// Handle numeric entities specially. We can't use functional substitution
|
244
|
+
// since that doesn't work in older versions of Safari.
|
245
|
+
// These should be rare since most browsers convert them to normal chars.
|
246
|
+
for (--pos; (pos = html.indexOf('&#', pos + 1)) >= 0;) {
|
247
|
+
var end = html.indexOf(';', pos);
|
248
|
+
if (end >= 0) {
|
249
|
+
var num = html.substring(pos + 3, end);
|
250
|
+
var radix = 10;
|
251
|
+
if (num && num.charAt(0) === 'x') {
|
252
|
+
num = num.substring(1);
|
253
|
+
radix = 16;
|
254
|
+
}
|
255
|
+
var codePoint = parseInt(num, radix);
|
256
|
+
if (!isNaN(codePoint)) {
|
257
|
+
html = (html.substring(0, pos) + String.fromCharCode(codePoint) +
|
258
|
+
html.substring(end + 1));
|
259
|
+
}
|
260
|
+
}
|
261
|
+
}
|
262
|
+
|
263
|
+
return html.replace(pr_ltEnt, '<')
|
264
|
+
.replace(pr_gtEnt, '>')
|
265
|
+
.replace(pr_aposEnt, "'")
|
266
|
+
.replace(pr_quotEnt, '"')
|
267
|
+
.replace(pr_ampEnt, '&')
|
268
|
+
.replace(pr_nbspEnt, ' ');
|
269
|
+
}
|
270
|
+
|
271
|
+
/** is the given node's innerHTML normally unescaped? */
|
272
|
+
function isRawContent(node) {
|
273
|
+
return 'XMP' === node.tagName;
|
274
|
+
}
|
275
|
+
|
276
|
+
function normalizedHtml(node, out) {
|
277
|
+
switch (node.nodeType) {
|
278
|
+
case 1: // an element
|
279
|
+
var name = node.tagName.toLowerCase();
|
280
|
+
out.push('<', name);
|
281
|
+
for (var i = 0; i < node.attributes.length; ++i) {
|
282
|
+
var attr = node.attributes[i];
|
283
|
+
if (!attr.specified) { continue; }
|
284
|
+
out.push(' ');
|
285
|
+
normalizedHtml(attr, out);
|
286
|
+
}
|
287
|
+
out.push('>');
|
288
|
+
for (var child = node.firstChild; child; child = child.nextSibling) {
|
289
|
+
normalizedHtml(child, out);
|
290
|
+
}
|
291
|
+
if (node.firstChild || !/^(?:br|link|img)$/.test(name)) {
|
292
|
+
out.push('<\/', name, '>');
|
293
|
+
}
|
294
|
+
break;
|
295
|
+
case 2: // an attribute
|
296
|
+
out.push(node.name.toLowerCase(), '="', attribToHtml(node.value), '"');
|
297
|
+
break;
|
298
|
+
case 3: case 4: // text
|
299
|
+
out.push(textToHtml(node.nodeValue));
|
300
|
+
break;
|
301
|
+
}
|
302
|
+
}
|
303
|
+
|
304
|
+
/**
|
305
|
+
* Given a group of {@link RegExp}s, returns a {@code RegExp} that globally
|
306
|
+
* matches the union o the sets o strings matched d by the input RegExp.
|
307
|
+
* Since it matches globally, if the input strings have a start-of-input
|
308
|
+
* anchor (/^.../), it is ignored for the purposes of unioning.
|
309
|
+
* @param {Array.<RegExpr>} regexs non multiline, non-global regexs.
|
310
|
+
* @return {RegExp} a global regex.
|
311
|
+
*/
|
312
|
+
function combinePrefixPatterns(regexs) {
|
313
|
+
var capturedGroupIndex = 0;
|
314
|
+
|
315
|
+
var needToFoldCase = false;
|
316
|
+
var ignoreCase = false;
|
317
|
+
for (var i = 0, n = regexs.length; i < n; ++i) {
|
318
|
+
var regex = regexs[i];
|
319
|
+
if (regex.ignoreCase) {
|
320
|
+
ignoreCase = true;
|
321
|
+
} else if (/[a-z]/i.test(regex.source.replace(
|
322
|
+
/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi, ''))) {
|
323
|
+
needToFoldCase = true;
|
324
|
+
ignoreCase = false;
|
325
|
+
break;
|
326
|
+
}
|
327
|
+
}
|
328
|
+
|
329
|
+
function decodeEscape(charsetPart) {
|
330
|
+
if (charsetPart.charAt(0) !== '\\') { return charsetPart.charCodeAt(0); }
|
331
|
+
switch (charsetPart.charAt(1)) {
|
332
|
+
case 'b': return 8;
|
333
|
+
case 't': return 9;
|
334
|
+
case 'n': return 0xa;
|
335
|
+
case 'v': return 0xb;
|
336
|
+
case 'f': return 0xc;
|
337
|
+
case 'r': return 0xd;
|
338
|
+
case 'u': case 'x':
|
339
|
+
return parseInt(charsetPart.substring(2), 16)
|
340
|
+
|| charsetPart.charCodeAt(1);
|
341
|
+
case '0': case '1': case '2': case '3': case '4':
|
342
|
+
case '5': case '6': case '7':
|
343
|
+
return parseInt(charsetPart.substring(1), 8);
|
344
|
+
default: return charsetPart.charCodeAt(1);
|
345
|
+
}
|
346
|
+
}
|
347
|
+
|
348
|
+
function encodeEscape(charCode) {
|
349
|
+
if (charCode < 0x20) {
|
350
|
+
return (charCode < 0x10 ? '\\x0' : '\\x') + charCode.toString(16);
|
351
|
+
}
|
352
|
+
var ch = String.fromCharCode(charCode);
|
353
|
+
if (ch === '\\' || ch === '-' || ch === '[' || ch === ']') {
|
354
|
+
ch = '\\' + ch;
|
355
|
+
}
|
356
|
+
return ch;
|
357
|
+
}
|
358
|
+
|
359
|
+
function caseFoldCharset(charSet) {
|
360
|
+
var charsetParts = charSet.substring(1, charSet.length - 1).match(
|
361
|
+
new RegExp(
|
362
|
+
'\\\\u[0-9A-Fa-f]{4}'
|
363
|
+
+ '|\\\\x[0-9A-Fa-f]{2}'
|
364
|
+
+ '|\\\\[0-3][0-7]{0,2}'
|
365
|
+
+ '|\\\\[0-7]{1,2}'
|
366
|
+
+ '|\\\\[\\s\\S]'
|
367
|
+
+ '|-'
|
368
|
+
+ '|[^-\\\\]',
|
369
|
+
'g'));
|
370
|
+
var groups = [];
|
371
|
+
var ranges = [];
|
372
|
+
var inverse = charsetParts[0] === '^';
|
373
|
+
for (var i = inverse ? 1 : 0, n = charsetParts.length; i < n; ++i) {
|
374
|
+
var p = charsetParts[i];
|
375
|
+
switch (p) {
|
376
|
+
case '\\B': case '\\b':
|
377
|
+
case '\\D': case '\\d':
|
378
|
+
case '\\S': case '\\s':
|
379
|
+
case '\\W': case '\\w':
|
380
|
+
groups.push(p);
|
381
|
+
continue;
|
382
|
+
}
|
383
|
+
var start = decodeEscape(p);
|
384
|
+
var end;
|
385
|
+
if (i + 2 < n && '-' === charsetParts[i + 1]) {
|
386
|
+
end = decodeEscape(charsetParts[i + 2]);
|
387
|
+
i += 2;
|
388
|
+
} else {
|
389
|
+
end = start;
|
390
|
+
}
|
391
|
+
ranges.push([start, end]);
|
392
|
+
// If the range might intersect letters, then expand it.
|
393
|
+
if (!(end < 65 || start > 122)) {
|
394
|
+
if (!(end < 65 || start > 90)) {
|
395
|
+
ranges.push([Math.max(65, start) | 32, Math.min(end, 90) | 32]);
|
396
|
+
}
|
397
|
+
if (!(end < 97 || start > 122)) {
|
398
|
+
ranges.push([Math.max(97, start) & ~32, Math.min(end, 122) & ~32]);
|
399
|
+
}
|
400
|
+
}
|
401
|
+
}
|
402
|
+
|
403
|
+
// [[1, 10], [3, 4], [8, 12], [14, 14], [16, 16], [17, 17]]
|
404
|
+
// -> [[1, 12], [14, 14], [16, 17]]
|
405
|
+
ranges.sort(function (a, b) { return (a[0] - b[0]) || (b[1] - a[1]); });
|
406
|
+
var consolidatedRanges = [];
|
407
|
+
var lastRange = [NaN, NaN];
|
408
|
+
for (var i = 0; i < ranges.length; ++i) {
|
409
|
+
var range = ranges[i];
|
410
|
+
if (range[0] <= lastRange[1] + 1) {
|
411
|
+
lastRange[1] = Math.max(lastRange[1], range[1]);
|
412
|
+
} else {
|
413
|
+
consolidatedRanges.push(lastRange = range);
|
414
|
+
}
|
415
|
+
}
|
416
|
+
|
417
|
+
var out = ['['];
|
418
|
+
if (inverse) { out.push('^'); }
|
419
|
+
out.push.apply(out, groups);
|
420
|
+
for (var i = 0; i < consolidatedRanges.length; ++i) {
|
421
|
+
var range = consolidatedRanges[i];
|
422
|
+
out.push(encodeEscape(range[0]));
|
423
|
+
if (range[1] > range[0]) {
|
424
|
+
if (range[1] + 1 > range[0]) { out.push('-'); }
|
425
|
+
out.push(encodeEscape(range[1]));
|
426
|
+
}
|
427
|
+
}
|
428
|
+
out.push(']');
|
429
|
+
return out.join('');
|
430
|
+
}
|
431
|
+
|
432
|
+
function allowAnywhereFoldCaseAndRenumberGroups(regex) {
|
433
|
+
// Split into character sets, escape sequences, punctuation strings
|
434
|
+
// like ('(', '(?:', ')', '^'), and runs of characters that do not
|
435
|
+
// include any of the above.
|
436
|
+
var parts = regex.source.match(
|
437
|
+
new RegExp(
|
438
|
+
'(?:'
|
439
|
+
+ '\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]' // a character set
|
440
|
+
+ '|\\\\u[A-Fa-f0-9]{4}' // a unicode escape
|
441
|
+
+ '|\\\\x[A-Fa-f0-9]{2}' // a hex escape
|
442
|
+
+ '|\\\\[0-9]+' // a back-reference or octal escape
|
443
|
+
+ '|\\\\[^ux0-9]' // other escape sequence
|
444
|
+
+ '|\\(\\?[:!=]' // start of a non-capturing group
|
445
|
+
+ '|[\\(\\)\\^]' // start/emd of a group, or line start
|
446
|
+
+ '|[^\\x5B\\x5C\\(\\)\\^]+' // run of other characters
|
447
|
+
+ ')',
|
448
|
+
'g'));
|
449
|
+
var n = parts.length;
|
450
|
+
|
451
|
+
// Maps captured group numbers to the number they will occupy in
|
452
|
+
// the output or to -1 if that has not been determined, or to
|
453
|
+
// undefined if they need not be capturing in the output.
|
454
|
+
var capturedGroups = [];
|
455
|
+
|
456
|
+
// Walk over and identify back references to build the capturedGroups
|
457
|
+
// mapping.
|
458
|
+
var groupIndex;
|
459
|
+
for (var i = 0, groupIndex = 0; i < n; ++i) {
|
460
|
+
var p = parts[i];
|
461
|
+
if (p === '(') {
|
462
|
+
// groups are 1-indexed, so max group index is count of '('
|
463
|
+
++groupIndex;
|
464
|
+
} else if ('\\' === p.charAt(0)) {
|
465
|
+
var decimalValue = +p.substring(1);
|
466
|
+
if (decimalValue && decimalValue <= groupIndex) {
|
467
|
+
capturedGroups[decimalValue] = -1;
|
468
|
+
}
|
469
|
+
}
|
470
|
+
}
|
471
|
+
|
472
|
+
// Renumber groups and reduce capturing groups to non-capturing groups
|
473
|
+
// where possible.
|
474
|
+
for (var i = 1; i < capturedGroups.length; ++i) {
|
475
|
+
if (-1 === capturedGroups[i]) {
|
476
|
+
capturedGroups[i] = ++capturedGroupIndex;
|
477
|
+
}
|
478
|
+
}
|
479
|
+
for (var i = 0, groupIndex = 0; i < n; ++i) {
|
480
|
+
var p = parts[i];
|
481
|
+
if (p === '(') {
|
482
|
+
++groupIndex;
|
483
|
+
if (capturedGroups[groupIndex] === undefined) {
|
484
|
+
parts[i] = '(?:';
|
485
|
+
}
|
486
|
+
} else if ('\\' === p.charAt(0)) {
|
487
|
+
var decimalValue = +p.substring(1);
|
488
|
+
if (decimalValue && decimalValue <= groupIndex) {
|
489
|
+
parts[i] = '\\' + capturedGroups[groupIndex];
|
490
|
+
}
|
491
|
+
}
|
492
|
+
}
|
493
|
+
|
494
|
+
// Remove any prefix anchors so that the output will match anywhere.
|
495
|
+
// ^^ really does mean an anchored match though.
|
496
|
+
for (var i = 0, groupIndex = 0; i < n; ++i) {
|
497
|
+
if ('^' === parts[i] && '^' !== parts[i + 1]) { parts[i] = ''; }
|
498
|
+
}
|
499
|
+
|
500
|
+
// Expand letters to groupts to handle mixing of case-sensitive and
|
501
|
+
// case-insensitive patterns if necessary.
|
502
|
+
if (regex.ignoreCase && needToFoldCase) {
|
503
|
+
for (var i = 0; i < n; ++i) {
|
504
|
+
var p = parts[i];
|
505
|
+
var ch0 = p.charAt(0);
|
506
|
+
if (p.length >= 2 && ch0 === '[') {
|
507
|
+
parts[i] = caseFoldCharset(p);
|
508
|
+
} else if (ch0 !== '\\') {
|
509
|
+
// TODO: handle letters in numeric escapes.
|
510
|
+
parts[i] = p.replace(
|
511
|
+
/[a-zA-Z]/g,
|
512
|
+
function (ch) {
|
513
|
+
var cc = ch.charCodeAt(0);
|
514
|
+
return '[' + String.fromCharCode(cc & ~32, cc | 32) + ']';
|
515
|
+
});
|
516
|
+
}
|
517
|
+
}
|
518
|
+
}
|
519
|
+
|
520
|
+
return parts.join('');
|
521
|
+
}
|
522
|
+
|
523
|
+
var rewritten = [];
|
524
|
+
for (var i = 0, n = regexs.length; i < n; ++i) {
|
525
|
+
var regex = regexs[i];
|
526
|
+
if (regex.global || regex.multiline) { throw new Error('' + regex); }
|
527
|
+
rewritten.push(
|
528
|
+
'(?:' + allowAnywhereFoldCaseAndRenumberGroups(regex) + ')');
|
529
|
+
}
|
530
|
+
|
531
|
+
return new RegExp(rewritten.join('|'), ignoreCase ? 'gi' : 'g');
|
532
|
+
}
|
533
|
+
|
534
|
+
var PR_innerHtmlWorks = null;
|
535
|
+
function getInnerHtml(node) {
|
536
|
+
// inner html is hopelessly broken in Safari 2.0.4 when the content is
|
537
|
+
// an html description of well formed XML and the containing tag is a PRE
|
538
|
+
// tag, so we detect that case and emulate innerHTML.
|
539
|
+
if (null === PR_innerHtmlWorks) {
|
540
|
+
var testNode = document.createElement('PRE');
|
541
|
+
testNode.appendChild(
|
542
|
+
document.createTextNode('<!DOCTYPE foo PUBLIC "foo bar">\n<foo />'));
|
543
|
+
PR_innerHtmlWorks = !/</.test(testNode.innerHTML);
|
544
|
+
}
|
545
|
+
|
546
|
+
if (PR_innerHtmlWorks) {
|
547
|
+
var content = node.innerHTML;
|
548
|
+
// XMP tags contain unescaped entities so require special handling.
|
549
|
+
if (isRawContent(node)) {
|
550
|
+
content = textToHtml(content);
|
551
|
+
}
|
552
|
+
return content;
|
553
|
+
}
|
554
|
+
|
555
|
+
var out = [];
|
556
|
+
for (var child = node.firstChild; child; child = child.nextSibling) {
|
557
|
+
normalizedHtml(child, out);
|
558
|
+
}
|
559
|
+
return out.join('');
|
560
|
+
}
|
561
|
+
|
562
|
+
/** returns a function that expand tabs to spaces. This function can be fed
|
563
|
+
* successive chunks of text, and will maintain its own internal state to
|
564
|
+
* keep track of how tabs are expanded.
|
565
|
+
* @return {function (string) : string} a function that takes
|
566
|
+
* plain text and return the text with tabs expanded.
|
567
|
+
* @private
|
568
|
+
*/
|
569
|
+
function makeTabExpander(tabWidth) {
|
570
|
+
var SPACES = ' ';
|
571
|
+
var charInLine = 0;
|
572
|
+
|
573
|
+
return function (plainText) {
|
574
|
+
// walk over each character looking for tabs and newlines.
|
575
|
+
// On tabs, expand them. On newlines, reset charInLine.
|
576
|
+
// Otherwise increment charInLine
|
577
|
+
var out = null;
|
578
|
+
var pos = 0;
|
579
|
+
for (var i = 0, n = plainText.length; i < n; ++i) {
|
580
|
+
var ch = plainText.charAt(i);
|
581
|
+
|
582
|
+
switch (ch) {
|
583
|
+
case '\t':
|
584
|
+
if (!out) { out = []; }
|
585
|
+
out.push(plainText.substring(pos, i));
|
586
|
+
// calculate how much space we need in front of this part
|
587
|
+
// nSpaces is the amount of padding -- the number of spaces needed
|
588
|
+
// to move us to the next column, where columns occur at factors of
|
589
|
+
// tabWidth.
|
590
|
+
var nSpaces = tabWidth - (charInLine % tabWidth);
|
591
|
+
charInLine += nSpaces;
|
592
|
+
for (; nSpaces >= 0; nSpaces -= SPACES.length) {
|
593
|
+
out.push(SPACES.substring(0, nSpaces));
|
594
|
+
}
|
595
|
+
pos = i + 1;
|
596
|
+
break;
|
597
|
+
case '\n':
|
598
|
+
charInLine = 0;
|
599
|
+
break;
|
600
|
+
default:
|
601
|
+
++charInLine;
|
602
|
+
}
|
603
|
+
}
|
604
|
+
if (!out) { return plainText; }
|
605
|
+
out.push(plainText.substring(pos));
|
606
|
+
return out.join('');
|
607
|
+
};
|
608
|
+
}
|
609
|
+
|
610
|
+
var pr_chunkPattern = new RegExp(
|
611
|
+
'[^<]+' // A run of characters other than '<'
|
612
|
+
+ '|<\!--[\\s\\S]*?--\>' // an HTML comment
|
613
|
+
+ '|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>' // a CDATA section
|
614
|
+
+ '|</?[a-zA-Z][^>]*>' // a probable tag that should not be highlighted
|
615
|
+
+ '|<', // A '<' that does not begin a larger chunk
|
616
|
+
'g');
|
617
|
+
var pr_commentPrefix = /^<\!--/;
|
618
|
+
var pr_cdataPrefix = /^<\[CDATA\[/;
|
619
|
+
var pr_brPrefix = /^<br\b/i;
|
620
|
+
var pr_tagNameRe = /^<(\/?)([a-zA-Z]+)/;
|
621
|
+
|
622
|
+
/** split markup into chunks of html tags (style null) and
|
623
|
+
* plain text (style {@link #PR_PLAIN}), converting tags which are
|
624
|
+
* significant for tokenization (<br>) into their textual equivalent.
|
625
|
+
*
|
626
|
+
* @param {string} s html where whitespace is considered significant.
|
627
|
+
* @return {Object} source code and extracted tags.
|
628
|
+
* @private
|
629
|
+
*/
|
630
|
+
function extractTags(s) {
|
631
|
+
// since the pattern has the 'g' modifier and defines no capturing groups,
|
632
|
+
// this will return a list of all chunks which we then classify and wrap as
|
633
|
+
// PR_Tokens
|
634
|
+
var matches = s.match(pr_chunkPattern);
|
635
|
+
var sourceBuf = [];
|
636
|
+
var sourceBufLen = 0;
|
637
|
+
var extractedTags = [];
|
638
|
+
if (matches) {
|
639
|
+
for (var i = 0, n = matches.length; i < n; ++i) {
|
640
|
+
var match = matches[i];
|
641
|
+
if (match.length > 1 && match.charAt(0) === '<') {
|
642
|
+
if (pr_commentPrefix.test(match)) { continue; }
|
643
|
+
if (pr_cdataPrefix.test(match)) {
|
644
|
+
// strip CDATA prefix and suffix. Don't unescape since it's CDATA
|
645
|
+
sourceBuf.push(match.substring(9, match.length - 3));
|
646
|
+
sourceBufLen += match.length - 12;
|
647
|
+
} else if (pr_brPrefix.test(match)) {
|
648
|
+
// <br> tags are lexically significant so convert them to text.
|
649
|
+
// This is undone later.
|
650
|
+
sourceBuf.push('\n');
|
651
|
+
++sourceBufLen;
|
652
|
+
} else {
|
653
|
+
if (match.indexOf(PR_NOCODE) >= 0 && isNoCodeTag(match)) {
|
654
|
+
// A <span class="nocode"> will start a section that should be
|
655
|
+
// ignored. Continue walking the list until we see a matching end
|
656
|
+
// tag.
|
657
|
+
var name = match.match(pr_tagNameRe)[2];
|
658
|
+
var depth = 1;
|
659
|
+
var j;
|
660
|
+
end_tag_loop:
|
661
|
+
for (j = i + 1; j < n; ++j) {
|
662
|
+
var name2 = matches[j].match(pr_tagNameRe);
|
663
|
+
if (name2 && name2[2] === name) {
|
664
|
+
if (name2[1] === '/') {
|
665
|
+
if (--depth === 0) { break end_tag_loop; }
|
666
|
+
} else {
|
667
|
+
++depth;
|
668
|
+
}
|
669
|
+
}
|
670
|
+
}
|
671
|
+
if (j < n) {
|
672
|
+
extractedTags.push(
|
673
|
+
sourceBufLen, matches.slice(i, j + 1).join(''));
|
674
|
+
i = j;
|
675
|
+
} else { // Ignore unclosed sections.
|
676
|
+
extractedTags.push(sourceBufLen, match);
|
677
|
+
}
|
678
|
+
} else {
|
679
|
+
extractedTags.push(sourceBufLen, match);
|
680
|
+
}
|
681
|
+
}
|
682
|
+
} else {
|
683
|
+
var literalText = htmlToText(match);
|
684
|
+
sourceBuf.push(literalText);
|
685
|
+
sourceBufLen += literalText.length;
|
686
|
+
}
|
687
|
+
}
|
688
|
+
}
|
689
|
+
return { source: sourceBuf.join(''), tags: extractedTags };
|
690
|
+
}
|
691
|
+
|
692
|
+
/** True if the given tag contains a class attribute with the nocode class. */
|
693
|
+
function isNoCodeTag(tag) {
|
694
|
+
return !!tag
|
695
|
+
// First canonicalize the representation of attributes
|
696
|
+
.replace(/\s(\w+)\s*=\s*(?:\"([^\"]*)\"|'([^\']*)'|(\S+))/g,
|
697
|
+
' $1="$2$3$4"')
|
698
|
+
// Then look for the attribute we want.
|
699
|
+
.match(/[cC][lL][aA][sS][sS]=\"[^\"]*\bnocode\b/);
|
700
|
+
}
|
701
|
+
|
702
|
+
/**
|
703
|
+
* Apply the given language handler to sourceCode and add the resulting
|
704
|
+
* decorations to out.
|
705
|
+
* @param {number} basePos the index of sourceCode within the chunk of source
|
706
|
+
* whose decorations are already present on out.
|
707
|
+
*/
|
708
|
+
function appendDecorations(basePos, sourceCode, langHandler, out) {
|
709
|
+
if (!sourceCode) { return; }
|
710
|
+
var job = {
|
711
|
+
source: sourceCode,
|
712
|
+
basePos: basePos
|
713
|
+
};
|
714
|
+
langHandler(job);
|
715
|
+
out.push.apply(out, job.decorations);
|
716
|
+
}
|
717
|
+
|
718
|
+
/** Given triples of [style, pattern, context] returns a lexing function,
|
719
|
+
* The lexing function interprets the patterns to find token boundaries and
|
720
|
+
* returns a decoration list of the form
|
721
|
+
* [index_0, style_0, index_1, style_1, ..., index_n, style_n]
|
722
|
+
* where index_n is an index into the sourceCode, and style_n is a style
|
723
|
+
* constant like PR_PLAIN. index_n-1 <= index_n, and style_n-1 applies to
|
724
|
+
* all characters in sourceCode[index_n-1:index_n].
|
725
|
+
*
|
726
|
+
* The stylePatterns is a list whose elements have the form
|
727
|
+
* [style : string, pattern : RegExp, DEPRECATED, shortcut : string].
|
728
|
+
*
|
729
|
+
* Style is a style constant like PR_PLAIN, or can be a string of the
|
730
|
+
* form 'lang-FOO', where FOO is a language extension describing the
|
731
|
+
* language of the portion of the token in $1 after pattern executes.
|
732
|
+
* E.g., if style is 'lang-lisp', and group 1 contains the text
|
733
|
+
* '(hello (world))', then that portion of the token will be passed to the
|
734
|
+
* registered lisp handler for formatting.
|
735
|
+
* The text before and after group 1 will be restyled using this decorator
|
736
|
+
* so decorators should take care that this doesn't result in infinite
|
737
|
+
* recursion. For example, the HTML lexer rule for SCRIPT elements looks
|
738
|
+
* something like ['lang-js', /<[s]cript>(.+?)<\/script>/]. This may match
|
739
|
+
* '<script>foo()<\/script>', which would cause the current decorator to
|
740
|
+
* be called with '<script>' which would not match the same rule since
|
741
|
+
* group 1 must not be empty, so it would be instead styled as PR_TAG by
|
742
|
+
* the generic tag rule. The handler registered for the 'js' extension would
|
743
|
+
* then be called with 'foo()', and finally, the current decorator would
|
744
|
+
* be called with '<\/script>' which would not match the original rule and
|
745
|
+
* so the generic tag rule would identify it as a tag.
|
746
|
+
*
|
747
|
+
* Pattern must only match prefixes, and if it matches a prefix, then that
|
748
|
+
* match is considered a token with the same style.
|
749
|
+
*
|
750
|
+
* Context is applied to the last non-whitespace, non-comment token
|
751
|
+
* recognized.
|
752
|
+
*
|
753
|
+
* Shortcut is an optional string of characters, any of which, if the first
|
754
|
+
* character, gurantee that this pattern and only this pattern matches.
|
755
|
+
*
|
756
|
+
* @param {Array} shortcutStylePatterns patterns that always start with
|
757
|
+
* a known character. Must have a shortcut string.
|
758
|
+
* @param {Array} fallthroughStylePatterns patterns that will be tried in
|
759
|
+
* order if the shortcut ones fail. May have shortcuts.
|
760
|
+
*
|
761
|
+
* @return {function (Object)} a
|
762
|
+
* function that takes source code and returns a list of decorations.
|
763
|
+
*/
|
764
|
+
function createSimpleLexer(shortcutStylePatterns, fallthroughStylePatterns) {
|
765
|
+
var shortcuts = {};
|
766
|
+
var tokenizer;
|
767
|
+
(function () {
|
768
|
+
var allPatterns = shortcutStylePatterns.concat(fallthroughStylePatterns);
|
769
|
+
var allRegexs = [];
|
770
|
+
var regexKeys = {};
|
771
|
+
for (var i = 0, n = allPatterns.length; i < n; ++i) {
|
772
|
+
var patternParts = allPatterns[i];
|
773
|
+
var shortcutChars = patternParts[3];
|
774
|
+
if (shortcutChars) {
|
775
|
+
for (var c = shortcutChars.length; --c >= 0;) {
|
776
|
+
shortcuts[shortcutChars.charAt(c)] = patternParts;
|
777
|
+
}
|
778
|
+
}
|
779
|
+
var regex = patternParts[1];
|
780
|
+
var k = '' + regex;
|
781
|
+
if (!regexKeys.hasOwnProperty(k)) {
|
782
|
+
allRegexs.push(regex);
|
783
|
+
regexKeys[k] = null;
|
784
|
+
}
|
785
|
+
}
|
786
|
+
allRegexs.push(/[\0-\uffff]/);
|
787
|
+
tokenizer = combinePrefixPatterns(allRegexs);
|
788
|
+
})();
|
789
|
+
|
790
|
+
var nPatterns = fallthroughStylePatterns.length;
|
791
|
+
var notWs = /\S/;
|
792
|
+
|
793
|
+
/**
|
794
|
+
* Lexes job.source and produces an output array job.decorations of style
|
795
|
+
* classes preceded by the position at which they start in job.source in
|
796
|
+
* order.
|
797
|
+
*
|
798
|
+
* @param {Object} job an object like {@code
|
799
|
+
* source: {string} sourceText plain text,
|
800
|
+
* basePos: {int} position of job.source in the larger chunk of
|
801
|
+
* sourceCode.
|
802
|
+
* }
|
803
|
+
*/
|
804
|
+
var decorate = function (job) {
|
805
|
+
var sourceCode = job.source, basePos = job.basePos;
|
806
|
+
/** Even entries are positions in source in ascending order. Odd enties
|
807
|
+
* are style markers (e.g., PR_COMMENT) that run from that position until
|
808
|
+
* the end.
|
809
|
+
* @type {Array.<number|string>}
|
810
|
+
*/
|
811
|
+
var decorations = [basePos, PR_PLAIN];
|
812
|
+
var pos = 0; // index into sourceCode
|
813
|
+
var tokens = sourceCode.match(tokenizer) || [];
|
814
|
+
var styleCache = {};
|
815
|
+
|
816
|
+
for (var ti = 0, nTokens = tokens.length; ti < nTokens; ++ti) {
|
817
|
+
var token = tokens[ti];
|
818
|
+
var style = styleCache[token];
|
819
|
+
var match;
|
820
|
+
|
821
|
+
var isEmbedded;
|
822
|
+
if (typeof style === 'string') {
|
823
|
+
isEmbedded = false;
|
824
|
+
} else {
|
825
|
+
var patternParts = shortcuts[token.charAt(0)];
|
826
|
+
if (patternParts) {
|
827
|
+
match = token.match(patternParts[1]);
|
828
|
+
style = patternParts[0];
|
829
|
+
} else {
|
830
|
+
for (var i = 0; i < nPatterns; ++i) {
|
831
|
+
patternParts = fallthroughStylePatterns[i];
|
832
|
+
match = token.match(patternParts[1]);
|
833
|
+
if (match) {
|
834
|
+
style = patternParts[0];
|
835
|
+
break;
|
836
|
+
}
|
837
|
+
}
|
838
|
+
|
839
|
+
if (!match) { // make sure that we make progress
|
840
|
+
style = PR_PLAIN;
|
841
|
+
}
|
842
|
+
}
|
843
|
+
|
844
|
+
isEmbedded = style.length >= 5 && 'lang-' === style.substring(0, 5);
|
845
|
+
if (isEmbedded && !(match && match[1])) {
|
846
|
+
isEmbedded = false;
|
847
|
+
style = PR_SOURCE;
|
848
|
+
}
|
849
|
+
|
850
|
+
if (!isEmbedded) { styleCache[token] = style; }
|
851
|
+
}
|
852
|
+
|
853
|
+
var tokenStart = pos;
|
854
|
+
pos += token.length;
|
855
|
+
|
856
|
+
if (!isEmbedded) {
|
857
|
+
decorations.push(basePos + tokenStart, style);
|
858
|
+
} else { // Treat group 1 as an embedded block of source code.
|
859
|
+
var embeddedSource = match[1];
|
860
|
+
var embeddedSourceStart = token.indexOf(embeddedSource);
|
861
|
+
var embeddedSourceEnd = embeddedSourceStart + embeddedSource.length;
|
862
|
+
var lang = style.substring(5);
|
863
|
+
var size = decorations.length - 10;
|
864
|
+
// Decorate the left of the embedded source
|
865
|
+
appendDecorations(
|
866
|
+
basePos + tokenStart,
|
867
|
+
token.substring(0, embeddedSourceStart),
|
868
|
+
decorate, decorations);
|
869
|
+
// Decorate the embedded source
|
870
|
+
appendDecorations(
|
871
|
+
basePos + tokenStart + embeddedSourceStart,
|
872
|
+
embeddedSource,
|
873
|
+
langHandlerForExtension(lang, embeddedSource),
|
874
|
+
decorations);
|
875
|
+
// Decorate the right of the embedded section
|
876
|
+
appendDecorations(
|
877
|
+
basePos + tokenStart + embeddedSourceEnd,
|
878
|
+
token.substring(embeddedSourceEnd),
|
879
|
+
decorate, decorations);
|
880
|
+
}
|
881
|
+
}
|
882
|
+
job.decorations = decorations;
|
883
|
+
};
|
884
|
+
return decorate;
|
885
|
+
}
|
886
|
+
|
887
|
+
/** returns a function that produces a list of decorations from source text.
|
888
|
+
*
|
889
|
+
* This code treats ", ', and ` as string delimiters, and \ as a string
|
890
|
+
* escape. It does not recognize perl's qq() style strings.
|
891
|
+
* It has no special handling for double delimiter escapes as in basic, or
|
892
|
+
* the tripled delimiters used in python, but should work on those regardless
|
893
|
+
* although in those cases a single string literal may be broken up into
|
894
|
+
* multiple adjacent string literals.
|
895
|
+
*
|
896
|
+
* It recognizes C, C++, and shell style comments.
|
897
|
+
*
|
898
|
+
* @param {Object} options a set of optional parameters.
|
899
|
+
* @return {function (Object)} a function that examines the source code
|
900
|
+
* in the input job and builds the decoration list.
|
901
|
+
*/
|
902
|
+
function sourceDecorator(options) {
|
903
|
+
var shortcutStylePatterns = [], fallthroughStylePatterns = [];
|
904
|
+
if (options['tripleQuotedStrings']) {
|
905
|
+
// '''multi-line-string''', 'single-line-string', and double-quoted
|
906
|
+
shortcutStylePatterns.push(
|
907
|
+
[PR_STRING, /^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,
|
908
|
+
null, '\'"']);
|
909
|
+
} else if (options['multiLineStrings']) {
|
910
|
+
// 'multi-line-string', "multi-line-string"
|
911
|
+
shortcutStylePatterns.push(
|
912
|
+
[PR_STRING, /^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,
|
913
|
+
null, '\'"`']);
|
914
|
+
} else {
|
915
|
+
// 'single-line-string', "single-line-string"
|
916
|
+
shortcutStylePatterns.push(
|
917
|
+
[PR_STRING,
|
918
|
+
/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,
|
919
|
+
null, '"\'']);
|
920
|
+
}
|
921
|
+
if (options['hashComments']) {
|
922
|
+
if (options['cStyleComments']) {
|
923
|
+
// Stop C preprocessor declarations at an unclosed open comment
|
924
|
+
shortcutStylePatterns.push(
|
925
|
+
[PR_COMMENT, /^#(?:[^\r\n\/]|\/(?!\*)|\/\*[^\r\n]*?\*\/)*/,
|
926
|
+
null, '#']);
|
927
|
+
} else {
|
928
|
+
shortcutStylePatterns.push([PR_COMMENT, /^#[^\r\n]*/, null, '#']);
|
929
|
+
}
|
930
|
+
}
|
931
|
+
if (options['cStyleComments']) {
|
932
|
+
fallthroughStylePatterns.push([PR_COMMENT, /^\/\/[^\r\n]*/, null]);
|
933
|
+
fallthroughStylePatterns.push(
|
934
|
+
[PR_COMMENT, /^\/\*[\s\S]*?(?:\*\/|$)/, null]);
|
935
|
+
}
|
936
|
+
if (options['regexLiterals']) {
|
937
|
+
var REGEX_LITERAL = (
|
938
|
+
// A regular expression literal starts with a slash that is
|
939
|
+
// not followed by * or / so that it is not confused with
|
940
|
+
// comments.
|
941
|
+
'/(?=[^/*])'
|
942
|
+
// and then contains any number of raw characters,
|
943
|
+
+ '(?:[^/\\x5B\\x5C]'
|
944
|
+
// escape sequences (\x5C),
|
945
|
+
+ '|\\x5C[\\s\\S]'
|
946
|
+
// or non-nesting character sets (\x5B\x5D);
|
947
|
+
+ '|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+'
|
948
|
+
// finally closed by a /.
|
949
|
+
+ '/');
|
950
|
+
fallthroughStylePatterns.push(
|
951
|
+
['lang-regex',
|
952
|
+
new RegExp('^' + REGEXP_PRECEDER_PATTERN + '(' + REGEX_LITERAL + ')')
|
953
|
+
]);
|
954
|
+
}
|
955
|
+
|
956
|
+
var keywords = options['keywords'].replace(/^\s+|\s+$/g, '');
|
957
|
+
if (keywords.length) {
|
958
|
+
fallthroughStylePatterns.push(
|
959
|
+
[PR_KEYWORD,
|
960
|
+
new RegExp('^(?:' + keywords.replace(/\s+/g, '|') + ')\\b'), null]);
|
961
|
+
}
|
962
|
+
|
963
|
+
shortcutStylePatterns.push([PR_PLAIN, /^\s+/, null, ' \r\n\t\xA0']);
|
964
|
+
fallthroughStylePatterns.push(
|
965
|
+
// TODO(mikesamuel): recognize non-latin letters and numerals in idents
|
966
|
+
[PR_LITERAL, /^@[a-z_$][a-z_$@0-9]*/i, null, '@'],
|
967
|
+
[PR_TYPE, /^@?[A-Z]+[a-z][A-Za-z_$@0-9]*/, null],
|
968
|
+
[PR_PLAIN, /^[a-z_$][a-z_$@0-9]*/i, null],
|
969
|
+
[PR_LITERAL,
|
970
|
+
new RegExp(
|
971
|
+
'^(?:'
|
972
|
+
// A hex number
|
973
|
+
+ '0x[a-f0-9]+'
|
974
|
+
// or an octal or decimal number,
|
975
|
+
+ '|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)'
|
976
|
+
// possibly in scientific notation
|
977
|
+
+ '(?:e[+\\-]?\\d+)?'
|
978
|
+
+ ')'
|
979
|
+
// with an optional modifier like UL for unsigned long
|
980
|
+
+ '[a-z]*', 'i'),
|
981
|
+
null, '0123456789'],
|
982
|
+
[PR_PUNCTUATION, /^.[^\s\w\.$@\'\"\`\/\#]*/, null]);
|
983
|
+
|
984
|
+
return createSimpleLexer(shortcutStylePatterns, fallthroughStylePatterns);
|
985
|
+
}
|
986
|
+
|
987
|
+
var decorateSource = sourceDecorator({
|
988
|
+
'keywords': ALL_KEYWORDS,
|
989
|
+
'hashComments': true,
|
990
|
+
'cStyleComments': true,
|
991
|
+
'multiLineStrings': true,
|
992
|
+
'regexLiterals': true
|
993
|
+
});
|
994
|
+
|
995
|
+
/** Breaks {@code job.source} around style boundaries in
|
996
|
+
* {@code job.decorations} while re-interleaving {@code job.extractedTags},
|
997
|
+
* and leaves the result in {@code job.prettyPrintedHtml}.
|
998
|
+
* @param {Object} job like {
|
999
|
+
* source: {string} source as plain text,
|
1000
|
+
* extractedTags: {Array.<number|string>} extractedTags chunks of raw
|
1001
|
+
* html preceded by their position in {@code job.source}
|
1002
|
+
* in order
|
1003
|
+
* decorations: {Array.<number|string} an array of style classes preceded
|
1004
|
+
* by the position at which they start in job.source in order
|
1005
|
+
* }
|
1006
|
+
* @private
|
1007
|
+
*/
|
1008
|
+
function recombineTagsAndDecorations(job) {
|
1009
|
+
var sourceText = job.source;
|
1010
|
+
var extractedTags = job.extractedTags;
|
1011
|
+
var decorations = job.decorations;
|
1012
|
+
|
1013
|
+
var html = [];
|
1014
|
+
// index past the last char in sourceText written to html
|
1015
|
+
var outputIdx = 0;
|
1016
|
+
|
1017
|
+
var openDecoration = null;
|
1018
|
+
var currentDecoration = null;
|
1019
|
+
var tagPos = 0; // index into extractedTags
|
1020
|
+
var decPos = 0; // index into decorations
|
1021
|
+
var tabExpander = makeTabExpander(window['PR_TAB_WIDTH']);
|
1022
|
+
|
1023
|
+
var adjacentSpaceRe = /([\r\n ]) /g;
|
1024
|
+
var startOrSpaceRe = /(^| ) /gm;
|
1025
|
+
var newlineRe = /\r\n?|\n/g;
|
1026
|
+
var trailingSpaceRe = /[ \r\n]$/;
|
1027
|
+
var lastWasSpace = true; // the last text chunk emitted ended with a space.
|
1028
|
+
|
1029
|
+
// A helper function that is responsible for opening sections of decoration
|
1030
|
+
// and outputing properly escaped chunks of source
|
1031
|
+
function emitTextUpTo(sourceIdx) {
|
1032
|
+
if (sourceIdx > outputIdx) {
|
1033
|
+
if (openDecoration && openDecoration !== currentDecoration) {
|
1034
|
+
// Close the current decoration
|
1035
|
+
html.push('</span>');
|
1036
|
+
openDecoration = null;
|
1037
|
+
}
|
1038
|
+
if (!openDecoration && currentDecoration) {
|
1039
|
+
openDecoration = currentDecoration;
|
1040
|
+
html.push('<span class="', openDecoration, '">');
|
1041
|
+
}
|
1042
|
+
// This interacts badly with some wikis which introduces paragraph tags
|
1043
|
+
// into pre blocks for some strange reason.
|
1044
|
+
// It's necessary for IE though which seems to lose the preformattedness
|
1045
|
+
// of <pre> tags when their innerHTML is assigned.
|
1046
|
+
// http://stud3.tuwien.ac.at/~e0226430/innerHtmlQuirk.html
|
1047
|
+
// and it serves to undo the conversion of <br>s to newlines done in
|
1048
|
+
// chunkify.
|
1049
|
+
var htmlChunk = textToHtml(
|
1050
|
+
tabExpander(sourceText.substring(outputIdx, sourceIdx)))
|
1051
|
+
.replace(lastWasSpace
|
1052
|
+
? startOrSpaceRe
|
1053
|
+
: adjacentSpaceRe, '$1 ');
|
1054
|
+
// Keep track of whether we need to escape space at the beginning of the
|
1055
|
+
// next chunk.
|
1056
|
+
lastWasSpace = trailingSpaceRe.test(htmlChunk);
|
1057
|
+
// IE collapses multiple adjacient <br>s into 1 line break.
|
1058
|
+
// Prefix every <br> with ' ' can prevent such IE's behavior.
|
1059
|
+
var lineBreakHtml = window['_pr_isIE6']() ? ' <br />' : '<br />';
|
1060
|
+
html.push(htmlChunk.replace(newlineRe, lineBreakHtml));
|
1061
|
+
outputIdx = sourceIdx;
|
1062
|
+
}
|
1063
|
+
}
|
1064
|
+
|
1065
|
+
while (true) {
|
1066
|
+
// Determine if we're going to consume a tag this time around. Otherwise
|
1067
|
+
// we consume a decoration or exit.
|
1068
|
+
var outputTag;
|
1069
|
+
if (tagPos < extractedTags.length) {
|
1070
|
+
if (decPos < decorations.length) {
|
1071
|
+
// Pick one giving preference to extractedTags since we shouldn't open
|
1072
|
+
// a new style that we're going to have to immediately close in order
|
1073
|
+
// to output a tag.
|
1074
|
+
outputTag = extractedTags[tagPos] <= decorations[decPos];
|
1075
|
+
} else {
|
1076
|
+
outputTag = true;
|
1077
|
+
}
|
1078
|
+
} else {
|
1079
|
+
outputTag = false;
|
1080
|
+
}
|
1081
|
+
// Consume either a decoration or a tag or exit.
|
1082
|
+
if (outputTag) {
|
1083
|
+
emitTextUpTo(extractedTags[tagPos]);
|
1084
|
+
if (openDecoration) {
|
1085
|
+
// Close the current decoration
|
1086
|
+
html.push('</span>');
|
1087
|
+
openDecoration = null;
|
1088
|
+
}
|
1089
|
+
html.push(extractedTags[tagPos + 1]);
|
1090
|
+
tagPos += 2;
|
1091
|
+
} else if (decPos < decorations.length) {
|
1092
|
+
emitTextUpTo(decorations[decPos]);
|
1093
|
+
currentDecoration = decorations[decPos + 1];
|
1094
|
+
decPos += 2;
|
1095
|
+
} else {
|
1096
|
+
break;
|
1097
|
+
}
|
1098
|
+
}
|
1099
|
+
emitTextUpTo(sourceText.length);
|
1100
|
+
if (openDecoration) {
|
1101
|
+
html.push('</span>');
|
1102
|
+
}
|
1103
|
+
job.prettyPrintedHtml = html.join('');
|
1104
|
+
}
|
1105
|
+
|
1106
|
+
/** Maps language-specific file extensions to handlers. */
|
1107
|
+
var langHandlerRegistry = {};
|
1108
|
+
/** Register a language handler for the given file extensions.
|
1109
|
+
* @param {function (Object)} handler a function from source code to a list
|
1110
|
+
* of decorations. Takes a single argument job which describes the
|
1111
|
+
* state of the computation. The single parameter has the form
|
1112
|
+
* {@code {
|
1113
|
+
* source: {string} as plain text.
|
1114
|
+
* decorations: {Array.<number|string>} an array of style classes
|
1115
|
+
* preceded by the position at which they start in
|
1116
|
+
* job.source in order.
|
1117
|
+
* The language handler should assigned this field.
|
1118
|
+
* basePos: {int} the position of source in the larger source chunk.
|
1119
|
+
* All positions in the output decorations array are relative
|
1120
|
+
* to the larger source chunk.
|
1121
|
+
* } }
|
1122
|
+
* @param {Array.<string>} fileExtensions
|
1123
|
+
*/
|
1124
|
+
function registerLangHandler(handler, fileExtensions) {
|
1125
|
+
for (var i = fileExtensions.length; --i >= 0;) {
|
1126
|
+
var ext = fileExtensions[i];
|
1127
|
+
if (!langHandlerRegistry.hasOwnProperty(ext)) {
|
1128
|
+
langHandlerRegistry[ext] = handler;
|
1129
|
+
} else if ('console' in window) {
|
1130
|
+
console.warn('cannot override language handler %s', ext);
|
1131
|
+
}
|
1132
|
+
}
|
1133
|
+
}
|
1134
|
+
function langHandlerForExtension(extension, source) {
|
1135
|
+
if (!(extension && langHandlerRegistry.hasOwnProperty(extension))) {
|
1136
|
+
// Treat it as markup if the first non whitespace character is a < and
|
1137
|
+
// the last non-whitespace character is a >.
|
1138
|
+
extension = /^\s*</.test(source)
|
1139
|
+
? 'default-markup'
|
1140
|
+
: 'default-code';
|
1141
|
+
}
|
1142
|
+
return langHandlerRegistry[extension];
|
1143
|
+
}
|
1144
|
+
registerLangHandler(decorateSource, ['default-code']);
|
1145
|
+
registerLangHandler(
|
1146
|
+
createSimpleLexer(
|
1147
|
+
[],
|
1148
|
+
[
|
1149
|
+
[PR_PLAIN, /^[^<?]+/],
|
1150
|
+
[PR_DECLARATION, /^<!\w[^>]*(?:>|$)/],
|
1151
|
+
[PR_COMMENT, /^<\!--[\s\S]*?(?:-\->|$)/],
|
1152
|
+
// Unescaped content in an unknown language
|
1153
|
+
['lang-', /^<\?([\s\S]+?)(?:\?>|$)/],
|
1154
|
+
['lang-', /^<%([\s\S]+?)(?:%>|$)/],
|
1155
|
+
[PR_PUNCTUATION, /^(?:<[%?]|[%?]>)/],
|
1156
|
+
['lang-', /^<xmp\b[^>]*>([\s\S]+?)<\/xmp\b[^>]*>/i],
|
1157
|
+
// Unescaped content in javascript. (Or possibly vbscript).
|
1158
|
+
['lang-js', /^<script\b[^>]*>([\s\S]+?)<\/script\b[^>]*>/i],
|
1159
|
+
// Contains unescaped stylesheet content
|
1160
|
+
['lang-css', /^<style\b[^>]*>([\s\S]+?)<\/style\b[^>]*>/i],
|
1161
|
+
['lang-in.tag', /^(<\/?[a-z][^<>]*>)/i]
|
1162
|
+
]),
|
1163
|
+
['default-markup', 'htm', 'html', 'mxml', 'xhtml', 'xml', 'xsl']);
|
1164
|
+
registerLangHandler(
|
1165
|
+
createSimpleLexer(
|
1166
|
+
[
|
1167
|
+
[PR_PLAIN, /^[\s]+/, null, ' \t\r\n'],
|
1168
|
+
[PR_ATTRIB_VALUE, /^(?:\"[^\"]*\"?|\'[^\']*\'?)/, null, '\"\'']
|
1169
|
+
],
|
1170
|
+
[
|
1171
|
+
[PR_TAG, /^^<\/?[a-z](?:[\w:-]*\w)?|\/?>$/],
|
1172
|
+
[PR_ATTRIB_NAME, /^(?!style\b|on)[a-z](?:[\w:-]*\w)?/],
|
1173
|
+
['lang-uq.val', /^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],
|
1174
|
+
[PR_PUNCTUATION, /^[=<>\/]+/],
|
1175
|
+
['lang-js', /^on\w+\s*=\s*\"([^\"]+)\"/i],
|
1176
|
+
['lang-js', /^on\w+\s*=\s*\'([^\']+)\'/i],
|
1177
|
+
['lang-js', /^on\w+\s*=\s*([^\"\'>\s]+)/i],
|
1178
|
+
['lang-css', /^sty\w+\s*=\s*\"([^\"]+)\"/i],
|
1179
|
+
['lang-css', /^sty\w+\s*=\s*\'([^\']+)\'/i],
|
1180
|
+
['lang-css', /^sty\w+\s*=\s*([^\"\'>\s]+)/i]
|
1181
|
+
]),
|
1182
|
+
['in.tag']);
|
1183
|
+
registerLangHandler(
|
1184
|
+
createSimpleLexer([], [[PR_ATTRIB_VALUE, /^[\s\S]+/]]), ['uq.val']);
|
1185
|
+
registerLangHandler(sourceDecorator({
|
1186
|
+
'keywords': CPP_KEYWORDS,
|
1187
|
+
'hashComments': true,
|
1188
|
+
'cStyleComments': true
|
1189
|
+
}), ['c', 'cc', 'cpp', 'cxx', 'cyc', 'm']);
|
1190
|
+
registerLangHandler(sourceDecorator({
|
1191
|
+
'keywords': 'null true false'
|
1192
|
+
}), ['json']);
|
1193
|
+
registerLangHandler(sourceDecorator({
|
1194
|
+
'keywords': CSHARP_KEYWORDS,
|
1195
|
+
'hashComments': true,
|
1196
|
+
'cStyleComments': true
|
1197
|
+
}), ['cs']);
|
1198
|
+
registerLangHandler(sourceDecorator({
|
1199
|
+
'keywords': JAVA_KEYWORDS,
|
1200
|
+
'cStyleComments': true
|
1201
|
+
}), ['java']);
|
1202
|
+
registerLangHandler(sourceDecorator({
|
1203
|
+
'keywords': SH_KEYWORDS,
|
1204
|
+
'hashComments': true,
|
1205
|
+
'multiLineStrings': true
|
1206
|
+
}), ['bsh', 'csh', 'sh']);
|
1207
|
+
registerLangHandler(sourceDecorator({
|
1208
|
+
'keywords': PYTHON_KEYWORDS,
|
1209
|
+
'hashComments': true,
|
1210
|
+
'multiLineStrings': true,
|
1211
|
+
'tripleQuotedStrings': true
|
1212
|
+
}), ['cv', 'py']);
|
1213
|
+
registerLangHandler(sourceDecorator({
|
1214
|
+
'keywords': PERL_KEYWORDS,
|
1215
|
+
'hashComments': true,
|
1216
|
+
'multiLineStrings': true,
|
1217
|
+
'regexLiterals': true
|
1218
|
+
}), ['perl', 'pl', 'pm']);
|
1219
|
+
registerLangHandler(sourceDecorator({
|
1220
|
+
'keywords': RUBY_KEYWORDS,
|
1221
|
+
'hashComments': true,
|
1222
|
+
'multiLineStrings': true,
|
1223
|
+
'regexLiterals': true
|
1224
|
+
}), ['rb']);
|
1225
|
+
registerLangHandler(sourceDecorator({
|
1226
|
+
'keywords': JSCRIPT_KEYWORDS,
|
1227
|
+
'cStyleComments': true,
|
1228
|
+
'regexLiterals': true
|
1229
|
+
}), ['js']);
|
1230
|
+
registerLangHandler(
|
1231
|
+
createSimpleLexer([], [[PR_STRING, /^[\s\S]+/]]), ['regex']);
|
1232
|
+
|
1233
|
+
function applyDecorator(job) {
|
1234
|
+
var sourceCodeHtml = job.sourceCodeHtml;
|
1235
|
+
var opt_langExtension = job.langExtension;
|
1236
|
+
|
1237
|
+
// Prepopulate output in case processing fails with an exception.
|
1238
|
+
job.prettyPrintedHtml = sourceCodeHtml;
|
1239
|
+
|
1240
|
+
try {
|
1241
|
+
// Extract tags, and convert the source code to plain text.
|
1242
|
+
var sourceAndExtractedTags = extractTags(sourceCodeHtml);
|
1243
|
+
/** Plain text. @type {string} */
|
1244
|
+
var source = sourceAndExtractedTags.source;
|
1245
|
+
job.source = source;
|
1246
|
+
job.basePos = 0;
|
1247
|
+
|
1248
|
+
/** Even entries are positions in source in ascending order. Odd entries
|
1249
|
+
* are tags that were extracted at that position.
|
1250
|
+
* @type {Array.<number|string>}
|
1251
|
+
*/
|
1252
|
+
job.extractedTags = sourceAndExtractedTags.tags;
|
1253
|
+
|
1254
|
+
// Apply the appropriate language handler
|
1255
|
+
langHandlerForExtension(opt_langExtension, source)(job);
|
1256
|
+
// Integrate the decorations and tags back into the source code to produce
|
1257
|
+
// a decorated html string which is left in job.prettyPrintedHtml.
|
1258
|
+
recombineTagsAndDecorations(job);
|
1259
|
+
} catch (e) {
|
1260
|
+
if ('console' in window) {
|
1261
|
+
console.log(e);
|
1262
|
+
console.trace();
|
1263
|
+
}
|
1264
|
+
}
|
1265
|
+
}
|
1266
|
+
|
1267
|
+
function prettyPrintOne(sourceCodeHtml, opt_langExtension) {
|
1268
|
+
var job = {
|
1269
|
+
sourceCodeHtml: sourceCodeHtml,
|
1270
|
+
langExtension: opt_langExtension
|
1271
|
+
};
|
1272
|
+
applyDecorator(job);
|
1273
|
+
return job.prettyPrintedHtml;
|
1274
|
+
}
|
1275
|
+
|
1276
|
+
function prettyPrint(opt_whenDone) {
|
1277
|
+
var isIE6 = window['_pr_isIE6']();
|
1278
|
+
|
1279
|
+
// fetch a list of nodes to rewrite
|
1280
|
+
var codeSegments = [
|
1281
|
+
document.getElementsByTagName('pre'),
|
1282
|
+
document.getElementsByTagName('code'),
|
1283
|
+
document.getElementsByTagName('xmp') ];
|
1284
|
+
var elements = [];
|
1285
|
+
for (var i = 0; i < codeSegments.length; ++i) {
|
1286
|
+
for (var j = 0, n = codeSegments[i].length; j < n; ++j) {
|
1287
|
+
elements.push(codeSegments[i][j]);
|
1288
|
+
}
|
1289
|
+
}
|
1290
|
+
codeSegments = null;
|
1291
|
+
|
1292
|
+
var clock = Date;
|
1293
|
+
if (!clock['now']) {
|
1294
|
+
clock = { 'now': function () { return (new Date).getTime(); } };
|
1295
|
+
}
|
1296
|
+
|
1297
|
+
// The loop is broken into a series of continuations to make sure that we
|
1298
|
+
// don't make the browser unresponsive when rewriting a large page.
|
1299
|
+
var k = 0;
|
1300
|
+
var prettyPrintingJob;
|
1301
|
+
|
1302
|
+
function doWork() {
|
1303
|
+
var endTime = (window['PR_SHOULD_USE_CONTINUATION'] ?
|
1304
|
+
clock.now() + 250 /* ms */ :
|
1305
|
+
Infinity);
|
1306
|
+
for (; k < elements.length && clock.now() < endTime; k++) {
|
1307
|
+
var cs = elements[k];
|
1308
|
+
if (cs.className && cs.className.indexOf('prettyprint') >= 0) {
|
1309
|
+
// If the classes includes a language extensions, use it.
|
1310
|
+
// Language extensions can be specified like
|
1311
|
+
// <pre class="prettyprint lang-cpp">
|
1312
|
+
// the language extension "cpp" is used to find a language handler as
|
1313
|
+
// passed to PR_registerLangHandler.
|
1314
|
+
var langExtension = cs.className.match(/\blang-(\w+)\b/);
|
1315
|
+
if (langExtension) { langExtension = langExtension[1]; }
|
1316
|
+
|
1317
|
+
// make sure this is not nested in an already prettified element
|
1318
|
+
var nested = false;
|
1319
|
+
for (var p = cs.parentNode; p; p = p.parentNode) {
|
1320
|
+
if ((p.tagName === 'pre' || p.tagName === 'code' ||
|
1321
|
+
p.tagName === 'xmp') &&
|
1322
|
+
p.className && p.className.indexOf('prettyprint') >= 0) {
|
1323
|
+
nested = true;
|
1324
|
+
break;
|
1325
|
+
}
|
1326
|
+
}
|
1327
|
+
if (!nested) {
|
1328
|
+
// fetch the content as a snippet of properly escaped HTML.
|
1329
|
+
// Firefox adds newlines at the end.
|
1330
|
+
var content = getInnerHtml(cs);
|
1331
|
+
content = content.replace(/(?:\r\n?|\n)$/, '');
|
1332
|
+
|
1333
|
+
// do the pretty printing
|
1334
|
+
prettyPrintingJob = {
|
1335
|
+
sourceCodeHtml: content,
|
1336
|
+
langExtension: langExtension,
|
1337
|
+
sourceNode: cs
|
1338
|
+
};
|
1339
|
+
applyDecorator(prettyPrintingJob);
|
1340
|
+
replaceWithPrettyPrintedHtml();
|
1341
|
+
}
|
1342
|
+
}
|
1343
|
+
}
|
1344
|
+
if (k < elements.length) {
|
1345
|
+
// finish up in a continuation
|
1346
|
+
setTimeout(doWork, 250);
|
1347
|
+
} else if (opt_whenDone) {
|
1348
|
+
opt_whenDone();
|
1349
|
+
}
|
1350
|
+
}
|
1351
|
+
|
1352
|
+
function replaceWithPrettyPrintedHtml() {
|
1353
|
+
var newContent = prettyPrintingJob.prettyPrintedHtml;
|
1354
|
+
if (!newContent) { return; }
|
1355
|
+
var cs = prettyPrintingJob.sourceNode;
|
1356
|
+
|
1357
|
+
// push the prettified html back into the tag.
|
1358
|
+
if (!isRawContent(cs)) {
|
1359
|
+
// just replace the old html with the new
|
1360
|
+
cs.innerHTML = newContent;
|
1361
|
+
} else {
|
1362
|
+
// we need to change the tag to a <pre> since <xmp>s do not allow
|
1363
|
+
// embedded tags such as the span tags used to attach styles to
|
1364
|
+
// sections of source code.
|
1365
|
+
var pre = document.createElement('PRE');
|
1366
|
+
for (var i = 0; i < cs.attributes.length; ++i) {
|
1367
|
+
var a = cs.attributes[i];
|
1368
|
+
if (a.specified) {
|
1369
|
+
var aname = a.name.toLowerCase();
|
1370
|
+
if (aname === 'class') {
|
1371
|
+
pre.className = a.value; // For IE 6
|
1372
|
+
} else {
|
1373
|
+
pre.setAttribute(a.name, a.value);
|
1374
|
+
}
|
1375
|
+
}
|
1376
|
+
}
|
1377
|
+
pre.innerHTML = newContent;
|
1378
|
+
|
1379
|
+
// remove the old
|
1380
|
+
cs.parentNode.replaceChild(pre, cs);
|
1381
|
+
cs = pre;
|
1382
|
+
}
|
1383
|
+
|
1384
|
+
// Replace <br>s with line-feeds so that copying and pasting works
|
1385
|
+
// on IE 6.
|
1386
|
+
// Doing this on other browsers breaks lots of stuff since \r\n is
|
1387
|
+
// treated as two newlines on Firefox, and doing this also slows
|
1388
|
+
// down rendering.
|
1389
|
+
if (isIE6 && cs.tagName === 'PRE') {
|
1390
|
+
var lineBreaks = cs.getElementsByTagName('br');
|
1391
|
+
for (var j = lineBreaks.length; --j >= 0;) {
|
1392
|
+
var lineBreak = lineBreaks[j];
|
1393
|
+
lineBreak.parentNode.replaceChild(
|
1394
|
+
document.createTextNode('\r'), lineBreak);
|
1395
|
+
}
|
1396
|
+
}
|
1397
|
+
}
|
1398
|
+
|
1399
|
+
doWork();
|
1400
|
+
}
|
1401
|
+
|
1402
|
+
window['PR_normalizedHtml'] = normalizedHtml;
|
1403
|
+
window['prettyPrintOne'] = prettyPrintOne;
|
1404
|
+
window['prettyPrint'] = prettyPrint;
|
1405
|
+
window['PR'] = {
|
1406
|
+
'combinePrefixPatterns': combinePrefixPatterns,
|
1407
|
+
'createSimpleLexer': createSimpleLexer,
|
1408
|
+
'registerLangHandler': registerLangHandler,
|
1409
|
+
'sourceDecorator': sourceDecorator,
|
1410
|
+
'PR_ATTRIB_NAME': PR_ATTRIB_NAME,
|
1411
|
+
'PR_ATTRIB_VALUE': PR_ATTRIB_VALUE,
|
1412
|
+
'PR_COMMENT': PR_COMMENT,
|
1413
|
+
'PR_DECLARATION': PR_DECLARATION,
|
1414
|
+
'PR_KEYWORD': PR_KEYWORD,
|
1415
|
+
'PR_LITERAL': PR_LITERAL,
|
1416
|
+
'PR_NOCODE': PR_NOCODE,
|
1417
|
+
'PR_PLAIN': PR_PLAIN,
|
1418
|
+
'PR_PUNCTUATION': PR_PUNCTUATION,
|
1419
|
+
'PR_SOURCE': PR_SOURCE,
|
1420
|
+
'PR_STRING': PR_STRING,
|
1421
|
+
'PR_TAG': PR_TAG,
|
1422
|
+
'PR_TYPE': PR_TYPE
|
1423
|
+
};
|
1424
|
+
})();
|