mirror of
https://github.com/go-gitea/gitea
synced 2024-12-21 04:24:06 +01:00
af7ffaa279
* Server-side syntax hilighting for all code This PR does a few things: * Remove all traces of highlight.js * Use chroma library to provide fast syntax hilighting directly on the server * Provide syntax hilighting for diffs * Re-style both unified and split diffs views * Add custom syntax hilighting styling for both regular and arc-green Fixes #7729 Fixes #10157 Fixes #11825 Fixes #7728 Fixes #3872 Fixes #3682 And perhaps gets closer to #9553 * fix line marker * fix repo search * Fix single line select * properly load settings * npm uninstall highlight.js * review suggestion * code review * forgot to call function * fix test * Apply suggestions from code review suggestions from @silverwind thanks Co-authored-by: silverwind <me@silverwind.io> * code review * copy/paste error * Use const for highlight size limit * Update web_src/less/_repository.less Co-authored-by: Lauris BH <lauris@nix.lv> * update size limit to 1MB and other styling tweaks * fix highlighting for certain diff sections * fix test * add worker back as suggested Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Lauris BH <lauris@nix.lv>
133 lines
6.8 KiB
Text
Vendored
133 lines
6.8 KiB
Text
Vendored
============
|
|
These pieces of code were ported from dotnet/corefx:
|
|
|
|
syntax/charclass.go (from RegexCharClass.cs): ported to use the built-in Go unicode classes. Canonicalize is
|
|
a direct port, but most of the other code required large changes because the C# implementation
|
|
used a string to represent the CharSet data structure and I cleaned that up in my implementation.
|
|
|
|
syntax/code.go (from RegexCode.cs): ported literally with various cleanups and layout to make it more Go-ish.
|
|
|
|
syntax/escape.go (from RegexParser.cs): ported Escape method and added some optimizations. Unescape is inspired by
|
|
the C# implementation but couldn't be directly ported because of the lack of do-while syntax in Go.
|
|
|
|
syntax/parser.go (from RegexpParser.cs and RegexOptions.cs): ported parser struct and associated methods as
|
|
literally as possible. Several language differences required changes. E.g. lack pre/post-fix increments as
|
|
expressions, lack of do-while loops, lack of overloads, etc.
|
|
|
|
syntax/prefix.go (from RegexFCD.cs and RegexBoyerMoore.cs): ported as literally as possible and added support
|
|
for unicode chars that are longer than the 16-bit char in C# for the 32-bit rune in Go.
|
|
|
|
syntax/replacerdata.go (from RegexReplacement.cs): conceptually ported and re-organized to handle differences
|
|
in charclass implementation, and fix odd code layout between RegexParser.cs, Regex.cs, and RegexReplacement.cs.
|
|
|
|
syntax/tree.go (from RegexTree.cs and RegexNode.cs): ported literally as possible.
|
|
|
|
syntax/writer.go (from RegexWriter.cs): ported literally with minor changes to make it more Go-ish.
|
|
|
|
match.go (from RegexMatch.cs): ported, simplified, and changed to handle Go's lack of inheritence.
|
|
|
|
regexp.go (from Regex.cs and RegexOptions.cs): conceptually serves the same "starting point", but is simplified
|
|
and changed to handle differences in C# strings and Go strings/runes.
|
|
|
|
replace.go (from RegexReplacement.cs): ported closely and then cleaned up to combine the MatchEvaluator and
|
|
simple string replace implementations.
|
|
|
|
runner.go (from RegexRunner.cs): ported literally as possible.
|
|
|
|
regexp_test.go (from CaptureTests.cs and GroupNamesAndNumbers.cs): conceptually ported, but the code was
|
|
manually structured like Go tests.
|
|
|
|
replace_test.go (from RegexReplaceStringTest0.cs): conceptually ported
|
|
|
|
rtl_test.go (from RightToLeft.cs): conceptually ported
|
|
---
|
|
dotnet/corefx was released under this license:
|
|
|
|
The MIT License (MIT)
|
|
|
|
Copyright (c) Microsoft Corporation
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
in the Software without restriction, including without limitation the rights
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
copies or substantial portions of the Software.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
SOFTWARE.
|
|
|
|
============
|
|
These pieces of code are copied from the Go framework:
|
|
|
|
- The overall directory structure of regexp2 was inspired by the Go runtime regexp package.
|
|
- The optimization in the escape method of syntax/escape.go is from the Go runtime QuoteMeta() func in regexp/regexp.go
|
|
- The method signatures in regexp.go are designed to match the Go framework regexp methods closely
|
|
- func regexp2.MustCompile and func quote are almost identifical to the regexp package versions
|
|
- BenchmarkMatch* and TestProgramTooLong* funcs in regexp_performance_test.go were copied from the framework
|
|
regexp/exec_test.go
|
|
---
|
|
The Go framework was released under this license:
|
|
|
|
Copyright (c) 2012 The Go Authors. All rights reserved.
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
modification, are permitted provided that the following conditions are
|
|
met:
|
|
|
|
* Redistributions of source code must retain the above copyright
|
|
notice, this list of conditions and the following disclaimer.
|
|
* Redistributions in binary form must reproduce the above
|
|
copyright notice, this list of conditions and the following disclaimer
|
|
in the documentation and/or other materials provided with the
|
|
distribution.
|
|
* Neither the name of Google Inc. nor the names of its
|
|
contributors may be used to endorse or promote products derived from
|
|
this software without specific prior written permission.
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
============
|
|
Some test data were gathered from the Mono project.
|
|
|
|
regexp_mono_test.go: ported from https://github.com/mono/mono/blob/master/mcs/class/System/Test/System.Text.RegularExpressions/PerlTrials.cs
|
|
---
|
|
Mono tests released under this license:
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
a copy of this software and associated documentation files (the
|
|
"Software"), to deal in the Software without restriction, including
|
|
without limitation the rights to use, copy, modify, merge, publish,
|
|
distribute, sublicense, and/or sell copies of the Software, and to
|
|
permit persons to whom the Software is furnished to do so, subject to
|
|
the following conditions:
|
|
|
|
The above copyright notice and this permission notice shall be
|
|
included in all copies or substantial portions of the Software.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|