-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Allows generating a single binary - The code/md/ipynb renderers can share their common dependencies (e.g. Chroma), which reduces the app size - Switches the Markdown converter from Down to Blackfriday, which adds support for more Markdown features and syntax highlighting
- Loading branch information
1 parent
48a193d
commit e6abe12
Showing
17 changed files
with
466 additions
and
96 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,39 +2,66 @@ | |
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica-Bold;\f1\fswiss\fcharset0 Helvetica;} | ||
{\colortbl;\red255\green255\blue255;\red0\green0\blue0;} | ||
{\*\expandedcolortbl;;\cssrgb\c0\c0\c0;} | ||
{\*\listtable{\list\listtemplateid1\listhybrid{\listlevel\levelnfc0\levelnfcn0\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{decimal\}.}{\leveltext\leveltemplateid1\'02\'00.;}{\levelnumbers\'01;}\fi-360\li720\lin720 }{\listname ;}\listid1}} | ||
{\*\listoverridetable{\listoverride\listid1\listoverridecount0\ls1}} | ||
\paperw11900\paperh16840\margl1440\margr1440\vieww28600\viewh16580\viewkind0 | ||
\deftab720 | ||
\pard\pardeftab720\partightenfactor0 | ||
|
||
\f0\b\fs28 \cf2 \expnd0\expndtw0\kerning0 | ||
\outl0\strokewidth0 \strokec2 Acknowledgements | ||
Acknowledgements | ||
\f1\b0\fs24 \ | ||
\ | ||
Portions of this software may utilize the following copyrighted material, the use of which is hereby acknowledged.\ | ||
\ | ||
\ | ||
\pard\pardeftab720\partightenfactor0 | ||
|
||
\f0\b \cf2 \outl0\strokewidth0 Chroma\ | ||
\f0\b \cf2 Blackfriday\ | ||
\pard\pardeftab720\partightenfactor0 | ||
\f1\b0 \cf2 \ | ||
Blackfriday is distributed under the Simplified BSD License:\ | ||
\ | ||
Copyright \'a9 2011 Russ Ross\ | ||
All rights reserved.\ | ||
\ | ||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\ | ||
\ | ||
\pard\tx220\tx720\pardeftab720\li720\fi-720\partightenfactor0 | ||
\ls1\ilvl0\cf2 \kerning1\expnd0\expndtw0 {\listtext 1. }\expnd0\expndtw0\kerning0 | ||
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\ | ||
\ls1\ilvl0\kerning1\expnd0\expndtw0 {\listtext 2. }\expnd0\expndtw0\kerning0 | ||
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.\ | ||
\pard\pardeftab720\partightenfactor0 | ||
\cf2 \ | ||
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 HOLDER 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.\ | ||
\ | ||
\ | ||
\pard\pardeftab720\partightenfactor0 | ||
|
||
\f1\b0 \ | ||
\f0\b \cf2 Chroma\ | ||
\pard\pardeftab720\partightenfactor0 | ||
\f1\b0 \cf2 \ | ||
Copyright (C) 2017 Alec Thomas\ | ||
\ | ||
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.\ | ||
\outl0\strokewidth0 \ | ||
\ | ||
\ | ||
\pard\pardeftab720\partightenfactor0 | ||
|
||
\f0\b \cf2 Down | ||
\f1\b0 \ | ||
\ | ||
The MIT License (MIT)\ | ||
\f0\b \cf2 github-markdown-css\ | ||
\pard\pardeftab720\partightenfactor0 | ||
\f1\b0 \cf2 \ | ||
MIT License\ | ||
\ | ||
Copyright (c) 2016 Rob Phillips.\ | ||
Copyright (c) Sindre Sorhus <[email protected]> (https://sindresorhus.com)\ | ||
\ | ||
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:\ | ||
\ | ||
|
@@ -43,11 +70,13 @@ The above copyright notice and this permission notice shall be included in all c | |
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.\ | ||
\ | ||
\ | ||
\pard\pardeftab720\partightenfactor0 | ||
|
||
\f0\b nbtohtml\ | ||
\f0\b \cf2 nbtohtml\ | ||
\ | ||
\pard\pardeftab720\partightenfactor0 | ||
\f1\b0 MIT License\ | ||
\f1\b0 \cf2 MIT License\ | ||
\ | ||
Copyright (c) 2020 Samuel Meuli\ | ||
\ | ||
|
@@ -58,10 +87,12 @@ The above copyright notice and this permission notice shall be included in all c | |
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.\ | ||
\ | ||
\ | ||
\pard\pardeftab720\partightenfactor0 | ||
|
||
\f0\b SwiftCSV\ | ||
\f0\b \cf2 SwiftCSV\ | ||
\pard\pardeftab720\partightenfactor0 | ||
\f1\b0 \ | ||
\f1\b0 \cf2 \ | ||
The MIT License (MIT)\ | ||
\ | ||
Copyright (c) 2014 Naoto Kaneko\ | ||
|
@@ -73,10 +104,12 @@ The above copyright notice and this permission notice shall be included in all c | |
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.\ | ||
\ | ||
\ | ||
\pard\pardeftab720\partightenfactor0 | ||
|
||
\f0\b SwiftExec\ | ||
\f0\b \cf2 SwiftExec\ | ||
\pard\pardeftab720\partightenfactor0 | ||
\f1\b0 \ | ||
\f1\b0 \cf2 \ | ||
MIT License\ | ||
\ | ||
Copyright (c) 2020 Samuel Meuli\ | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module github.com/samuelmeuli/glance | ||
|
||
go 1.14 | ||
|
||
require ( | ||
github.com/Depado/bfchroma v1.1.1 | ||
github.com/alecthomas/chroma v0.7.2 | ||
github.com/microcosm-cc/bluemonday v1.0.2 | ||
github.com/samuelmeuli/nbtohtml v0.4.0 | ||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd // indirect | ||
gopkg.in/russross/blackfriday.v2 v2.0.1 | ||
) | ||
|
||
replace gopkg.in/russross/blackfriday.v2 v2.0.1 => github.com/russross/blackfriday/v2 v2.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
github.com/Depado/bfchroma v1.1.1 h1:FZz6t8qiPusJA9byayzzs2AWEifd7tYCzyagql/AFEM= | ||
github.com/Depado/bfchroma v1.1.1/go.mod h1:9BTTKr5Oh9gf19WS8X7n8v9DmtaizdQkVlBmPQfNmfk= | ||
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38 h1:smF2tmSOzy2Mm+0dGI2AIUHY+w0BUc+4tn40djz7+6U= | ||
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38/go.mod h1:r7bzyVFMNntcxPZXK3/+KdruV1H5KSlyVY0gc+NgInI= | ||
github.com/alecthomas/chroma v0.4.0/go.mod h1:MmozekIi2rfQSzDcdEZ2BoJ9Pxs/7uc2Y4Boh+hIeZo= | ||
github.com/alecthomas/chroma v0.7.1/go.mod h1:gHw09mkX1Qp80JlYbmN9L3+4R5o6DJJ3GRShh+AICNc= | ||
github.com/alecthomas/chroma v0.7.2 h1:B76NU/zbQYIUhUowbi4fmvREmDUJLsUzKWTZmQd3ABY= | ||
github.com/alecthomas/chroma v0.7.2/go.mod h1:fv5SzZPFJbwp2NXJWpFIX7DZS4HgV1K4ew4Pc2OZD9s= | ||
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721 h1:JHZL0hZKJ1VENNfmXvHbgYlbUOvpzYzvy2aZU5gXVeo= | ||
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721/go.mod h1:QO9JBoKquHd+jz9nshCh40fOfO+JzsoXy8qTHF68zU0= | ||
github.com/alecthomas/kong v0.2.1-0.20190708041108-0548c6b1afae/go.mod h1:+inYUSluD+p4L8KdviBSgzcqEjUQOfC5fQDRFuc36lI= | ||
github.com/alecthomas/kong v0.2.4/go.mod h1:kQOmtJgV+Lb4aj+I2LEn40cbtawdWJ9Y8QLq+lElKxE= | ||
github.com/alecthomas/repr v0.0.0-20180616030925-f49988b46e02/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ= | ||
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897 h1:p9Sln00KOTlrYkxI1zYWl1QLnEqAqEARBEYa8FQnQcY= | ||
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ= | ||
github.com/buildkite/terminal-to-html v3.2.0+incompatible h1:WdXzl7ZmYzCAz4pElZosPaUlRTW+qwVx/SkQSCa1jXs= | ||
github.com/buildkite/terminal-to-html v3.2.0+incompatible/go.mod h1:BFFdFecOxCgjdcarqI+8izs6v85CU/1RA/4Bqh4GR7E= | ||
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 h1:y5HC9v93H5EPKqaS1UYVg1uYah5Xf51mBfIoWehClUQ= | ||
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964/go.mod h1:Xd9hchkHSWYkEqJwUGisez3G1QY8Ryz0sdWrLPMGjLk= | ||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/dlclark/regexp2 v1.1.6 h1:CqB4MjHw0MFCDj+PHHjiESmHX+N7t0tJzKvC6M97BRg= | ||
github.com/dlclark/regexp2 v1.1.6/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= | ||
github.com/dlclark/regexp2 v1.2.0 h1:8sAhBGEM0dRWogWqWyQeIJnxjWO6oIjl8FKqREDsGfk= | ||
github.com/dlclark/regexp2 v1.2.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= | ||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= | ||
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= | ||
github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs= | ||
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= | ||
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= | ||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= | ||
github.com/microcosm-cc/bluemonday v1.0.2 h1:5lPfLTTAvAbtS0VqT+94yOtFnGfUWYyx0+iToC3Os3s= | ||
github.com/microcosm-cc/bluemonday v1.0.2/go.mod h1:iVP4YcDBq+n/5fb23BhYFvIMq/leAFZyRl6bYmGDlGc= | ||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= | ||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= | ||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= | ||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= | ||
github.com/samuelmeuli/nbtohtml v0.4.0 h1:yimO4a52ETUBeGzuv+6TzWAAR8loxeKkmXxo2iQO13U= | ||
github.com/samuelmeuli/nbtohtml v0.4.0/go.mod h1:xqEFWivVanSBktnDCD1r5hbd73S0W9Vg971NAJMRfJc= | ||
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= | ||
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= | ||
github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= | ||
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= | ||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= | ||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||
github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= | ||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= | ||
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= | ||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= | ||
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= | ||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= | ||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= | ||
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= | ||
golang.org/x/net v0.0.0-20200319234117-63522dbf7eec h1:w0SItUiQ4sBiXBAwWNkyu8Fu2Qpn/dtDIcoPkPDqjRw= | ||
golang.org/x/net v0.0.0-20200319234117-63522dbf7eec/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= | ||
golang.org/x/sys v0.0.0-20180715085529-ac767d655b30/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||
golang.org/x/sys v0.0.0-20181128092732-4ed8d59d0b35/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/sys v0.0.0-20200317113312-5766fd39f98d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884= | ||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/russross/blackfriday.v2 v2.0.0/go.mod h1:6sSBNz/GtOm/pJTuh5UmBK2ZHfmnxGbl2NZg1UliSOI= | ||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= | ||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package main | ||
|
||
import ( | ||
"C" | ||
"bytes" | ||
"fmt" | ||
"github.com/Depado/bfchroma" | ||
"github.com/alecthomas/chroma" | ||
htmlFormatter "github.com/alecthomas/chroma/formatters/html" | ||
"github.com/alecthomas/chroma/lexers" | ||
"github.com/alecthomas/chroma/styles" | ||
"github.com/microcosm-cc/bluemonday" | ||
"github.com/samuelmeuli/nbtohtml" | ||
"gopkg.in/russross/blackfriday.v2" | ||
) | ||
|
||
// Convention: Because all functions return C strings, errors are implemented as return values which | ||
// start with "error: ". | ||
|
||
//export convertCodeToHTML | ||
func convertCodeToHTML(source *C.char, lexer *C.char) *C.char { | ||
sourceString := C.GoString(source) | ||
lexerString := C.GoString(lexer) | ||
htmlBuffer := new(bytes.Buffer) | ||
|
||
// Set up lexer for programming language | ||
var l chroma.Lexer | ||
if lexerString != "" { | ||
l = lexers.Get(lexerString) | ||
} | ||
if l == nil { | ||
l = lexers.Analyse(sourceString) | ||
} | ||
if l == nil { | ||
l = lexers.Fallback | ||
} | ||
l = chroma.Coalesce(l) | ||
|
||
// Use classes instead of inline styles | ||
formatter := htmlFormatter.New(htmlFormatter.WithClasses(true)) | ||
|
||
iterator, err := l.Tokenise(nil, sourceString) | ||
if err != nil { | ||
errMessage := fmt.Sprintf("error: Could not render source code (tokenization error): %d", err) | ||
return C.CString(errMessage) | ||
} | ||
|
||
err = formatter.Format(htmlBuffer, styles.GitHub, iterator) | ||
if err != nil { | ||
errMessage := fmt.Sprintf("error: Could not render source code (formatting error): %d", err) | ||
return C.CString(errMessage) | ||
} | ||
|
||
// Chroma escapes tags, so HTML should be safe from code injection | ||
htmlString := htmlBuffer.String() | ||
return C.CString(htmlString) | ||
} | ||
|
||
//export convertMarkdownToHTML | ||
func convertMarkdownToHTML(source *C.char) *C.char { | ||
sourceString := C.GoString(source) | ||
|
||
// Sanitize output but keep classes (required for syntax highlighting) | ||
policy := bluemonday.UGCPolicy() | ||
policy.AllowStyling() | ||
|
||
// Use Chroma for syntax highlighting in code blocks | ||
renderer := bfchroma.NewRenderer( | ||
bfchroma.WithoutAutodetect(), | ||
bfchroma.ChromaOptions(htmlFormatter.WithClasses(true)), | ||
) | ||
|
||
html := blackfriday.Run([]byte(sourceString), blackfriday.WithRenderer(renderer)) | ||
htmlString := string(html) | ||
htmlStringSanitized := policy.Sanitize(htmlString) | ||
return C.CString(htmlStringSanitized) | ||
} | ||
|
||
//export convertNotebookToHTML | ||
func convertNotebookToHTML(source *C.char) *C.char { | ||
sourceString := C.GoString(source) | ||
|
||
html := new(bytes.Buffer) | ||
err := nbtohtml.ConvertString(html, sourceString) | ||
if err != nil { | ||
errMessage := fmt.Sprintf("error: Could not convert Notebook to HTML: %d", err) | ||
return C.CString(errMessage) | ||
} | ||
htmlString := html.String() | ||
return C.CString(htmlString) | ||
} | ||
|
||
// Main function is required for `c-archive` builds. | ||
func main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* Code generated by cmd/cgo; DO NOT EDIT. */ | ||
|
||
/* package github.com/samuelmeuli/glance */ | ||
|
||
|
||
#line 1 "cgo-builtin-export-prolog" | ||
|
||
#include <stddef.h> /* for ptrdiff_t below */ | ||
|
||
#ifndef GO_CGO_EXPORT_PROLOGUE_H | ||
#define GO_CGO_EXPORT_PROLOGUE_H | ||
|
||
#ifndef GO_CGO_GOSTRING_TYPEDEF | ||
typedef struct { const char *p; ptrdiff_t n; } _GoString_; | ||
#endif | ||
|
||
#endif | ||
|
||
/* Start of preamble from import "C" comments. */ | ||
|
||
|
||
|
||
|
||
/* End of preamble from import "C" comments. */ | ||
|
||
|
||
/* Start of boilerplate cgo prologue. */ | ||
#line 1 "cgo-gcc-export-header-prolog" | ||
|
||
#ifndef GO_CGO_PROLOGUE_H | ||
#define GO_CGO_PROLOGUE_H | ||
|
||
typedef signed char GoInt8; | ||
typedef unsigned char GoUint8; | ||
typedef short GoInt16; | ||
typedef unsigned short GoUint16; | ||
typedef int GoInt32; | ||
typedef unsigned int GoUint32; | ||
typedef long long GoInt64; | ||
typedef unsigned long long GoUint64; | ||
typedef GoInt64 GoInt; | ||
typedef GoUint64 GoUint; | ||
typedef __SIZE_TYPE__ GoUintptr; | ||
typedef float GoFloat32; | ||
typedef double GoFloat64; | ||
typedef float _Complex GoComplex64; | ||
typedef double _Complex GoComplex128; | ||
|
||
/* | ||
static assertion to make sure the file is being used on architecture | ||
at least with matching size of GoInt. | ||
*/ | ||
typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1]; | ||
|
||
#ifndef GO_CGO_GOSTRING_TYPEDEF | ||
typedef _GoString_ GoString; | ||
#endif | ||
typedef void *GoMap; | ||
typedef void *GoChan; | ||
typedef struct { void *t; void *v; } GoInterface; | ||
typedef struct { void *data; GoInt len; GoInt cap; } GoSlice; | ||
|
||
#endif | ||
|
||
/* End of boilerplate cgo prologue. */ | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
|
||
extern char* convertCodeToHTML(char* p0, char* p1); | ||
|
||
extern char* convertMarkdownToHTML(char* p0); | ||
|
||
extern char* convertNotebookToHTML(char* p0); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif |
Oops, something went wrong.