8db22c85c4
By executing prettify over the entire file contents, rather than on a single line at a time, we can be certain that multi-line comments and strings are rendered correctly all of the time, even if it starts or ends within a hidden context region. With this change we move prettify to run only on the server, within the Mozilla Rhino JavaScript engine, and send to the client only fully formatted HTML line arrays for the two files. Like before, the server only sends partial arrays, letting the client piece it all together at display time. In a future commit I plan to have the client format the file if we are showing all lines from both sides. This way the RPC response payload is smaller, and the server can offload the parsing and formatting load to some clients. While writing this change I considered using Pygments running inside of Jython, but chose to stick with prettify in Rhino. Pygments ran much slower for the same small file contents, and doesn't leave us with the option to execute formatting on the client side. As part of this change we now use the Mozilla chardet library to detect the character set of the file contents we are about to render as HTML. The chardet library is the same logic used inside of the Mozilla browser family to detect the character set when it isn't specified... so its pretty accurate for a wide range of files. In the future we should also start to honor .gitattributes to get the encoding. Bug: issue 250 Bug: issue 251 Change-Id: I155bb7abc560f01a3597b3be678a76a5aa7f9e68 Signed-off-by: Shawn O. Pearce <sop@google.com>
58 lines
1.7 KiB
XML
58 lines
1.7 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!--
|
|
Copyright (C) 2009 The Android Open Source Project
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
-->
|
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
|
<modelVersion>4.0.0</modelVersion>
|
|
|
|
<parent>
|
|
<groupId>com.google.gerrit</groupId>
|
|
<artifactId>gerrit-parent</artifactId>
|
|
<version>2.1-SNAPSHOT</version>
|
|
</parent>
|
|
|
|
<artifactId>gerrit-prettify</artifactId>
|
|
<name>Gerrit Code Review - Prettify</name>
|
|
|
|
<description>
|
|
Prettify based syntax highlighting
|
|
</description>
|
|
|
|
<dependencies>
|
|
<dependency>
|
|
<groupId>gwtexpui</groupId>
|
|
<artifactId>gwtexpui</artifactId>
|
|
</dependency>
|
|
|
|
<dependency>
|
|
<groupId>com.google.code.guice</groupId>
|
|
<artifactId>guice</artifactId>
|
|
</dependency>
|
|
|
|
<dependency>
|
|
<groupId>rhino</groupId>
|
|
<artifactId>js</artifactId>
|
|
</dependency>
|
|
|
|
<dependency>
|
|
<groupId>com.google.gwt</groupId>
|
|
<artifactId>gwt-user</artifactId>
|
|
<scope>provided</scope>
|
|
</dependency>
|
|
</dependencies>
|
|
</project>
|