Commit graph

30 commits

Author SHA1 Message Date
mrsdizzie
c8650aef0a Change order that PostProcess Processors are run ()
Make sure Processors that work on full links are run first so that
something matching another pattern doesn't alter a link before we get to
it, for example:

 https://stackoverflow.com/questions/2896191/what-is-go-used-fore

Fixes 
2019-03-27 11:37:54 -04:00
Mura Li
d77176912b Use Go1.11 module ()
* Migrate to go modules

* make vendor

* Update mvdan.cc/xurls

* make vendor

* Update code.gitea.io/git

* make fmt-check

* Update github.com/go-sql-driver/mysql

* make vendor
2019-03-27 19:15:23 +08:00
Roland Koebler
57ecf09787 Markdown: enable some more extensions ()
* Markdown: enable some more extensions

Improve Markdown-rendering by enabling some extensions:

- enable definitions lists
- enable footnotes
- enable header-ids and automatically generate header-ids (for linking to README-sections or creating table-of-contents for larger READMEs)

* Markdown: update and exted tests

Update and add tests for additionally enabled Markdown-extensions.
2019-03-21 15:53:06 +02:00
zeripath
b2e9894988 Fix reported issue in repo description () 2019-03-11 22:23:34 -04:00
mrsdizzie
f2de5dc8c8 Replace linkRegex with xurls library ()
* Replace linkRegex with xurls library

Rather than maintaining a complicated regex to match URLs for
autolinking, gitea can use this existing go library that takes care of
the matching with very little code change to gitea itself. After
spending a while trying to find the perfect regex for all cases this library
still works better as it is more flexible than a single regex ever will be.

This will also fix the following issues:   

This passes all our current tests and I've added new ones mentioned in
those issues as well.

* Use xurls.StrictMatchingScheme instead of xurls.Strict

This is much faster and we only care about https? links to preserve
existing behavior.
2019-03-07 15:12:01 -05:00
mrsdizzie
020075e12f Remove visitLinksForShortLinks features ()
The visitLinksForShortLinks feature would look inside of an <a> tag and
run shortLinkProcessorFull on any text, which attempts to create links
out of potential 'short links' like [[test]] [[link|example]] etc...
This makes no sense because you can't have nested links within an <a>
tag. Specifically, the html5 standard says <a> tags can't include
interactive content if they contain the href attribute:

 http://w3c.github.io/html/single-page.html#the-a-element

And also defines an <a> element with a href attribute as interactive:

 http://w3c.github.io/html/single-page.html#interactive-content

Therefore you can't really put a link inside of another link. In
practice none of this works anyways since browsers won't render it, it
would probably be broken if they tried, and it is causing a bug
(). No current tests rely on this behavior either.

This removes the feature and also explicitly excludes the
current visitNodeForShortLinks from looking in <a> tags.
2019-03-07 14:13:44 -05:00
mrsdizzie
4a2e92bcd1 Modify linkRegex to require http|https ()
Modify the current linkRegex to require http|https which appears to be
the intended behavior based on the comments. Right now, it also matches
anything starting with www as well. Also add testing for linkRegex
2019-02-28 20:31:53 +08:00
zeripath
2a03e96bce
Allow markdown files to read from the LFS ()
This PR makes it possible for the markdown renderer to render images and media straight from the LFS.

Fix 

Signed-off-by: Andrew Thornton [art27@cantab.net](mailto:art27@cantab.net)
2019-02-12 15:09:43 +00:00
zeripath
0823791d17 Recover panic in orgmode.Render if bad orgfile () ()
This PR protects against the panic referred to in 
by recovering from the panic and just returning the raw bytes if
there is an error.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2019-01-30 17:17:43 -05:00
Khaled Hamed
bd75965296 Prioritize "readme.md" ()
* prioritize readme.md

* Improve IsReadmeFile

* Add more tests
2019-01-14 14:15:06 -05:00
Lunny Xiao
cef0f12c51 support envs on external render commands () 2018-11-20 17:11:21 -05:00
L.E.R
b686bd0c94 Fix markdown image with link ()
* Fix markdown image with link

* Add gitea copyright notice

* add a test for markdown image with link

* remove svg related variables
2018-10-30 18:26:28 -04:00
Nicolas Lenz
220ee6ae42 Pass link prefixes to external markup parsers ()
* Pass environment variables for URL prefixes to external markup parser

Signed-off-by: Nicolas Lenz <nicolas@eisfunke.com>

* Document external markup link prefix environment variables

Signed-off-by: Nicolas Lenz <nicolas@eisfunke.com>

* Run format on link prefix changes

Signed-off-by: Nicolas Lenz <nicolas@eisfunke.com>
2018-10-30 10:34:12 -04:00
techknowlogick
080428b2bf
Upgrade images in .drone.yml to more recent versions () 2018-08-29 09:43:58 -04:00
Lunny Xiao
0bb1c84208 Add csv file render support defaultly ()
* add csv file render support defaultly

* escaping csv column content
2018-07-21 00:08:15 +03:00
Jonas Franz
2a60e72fcd
Replace src with raw to fix image paths ()
Signed-off-by: Jonas Franz <info@jonasfranz.software>
2018-07-05 22:36:45 +02:00
Antoine GIRARD
23ba5c870f markup: escape short wiki link () 2018-06-15 20:42:49 +08:00
Chaz Reid
69ea5e4385 Fix wiki inter-links with cases and add tests for this case () 2018-03-05 20:39:12 +02:00
Morgan Bazalgette
535445c32e Rework special link parsing in the post-processing of markup ()
* Get rid of autolink

* autolink in markdown

* Replace email addresses with mailto links

* better handling of links

* Remove autolink.js from footer

* Refactor entire html.go

* fix some bugs

* Make tests green, move what we can to html_internal_test, various other changes to processor logic

* Make markdown tests work again

This is just a description to allow me to force push in order to restart
the drone build.

* Fix failing markdown tests in routers/api/v1/misc

* Add license headers, log errors, future-proof <body>

* fix formatting
2018-02-27 09:09:18 +02:00
Ethan Koenig
7b104f0cd0 Populate URL field of API commits ()
* Populate URL field of API commits

* fix orgmode_test
2018-02-20 20:50:42 +08:00
Christian Köberl
e9e2a9cdcc Allow square brackets in external issue patterns ()
* Allow square brackets in external issue patterns

* Added false test cases for checklist elements
2018-02-03 11:51:02 +02:00
Lauris BH
a0c397df08
Recognize more characters in crossreferenced repo name () 2018-01-27 14:33:32 +02:00
Ethan Koenig
5481be0ac5 Fix issue link rendering in commit messages ()
* Fix issue link rendering in commit messages

* Update page.tmpl

* No links for parens

* remove comment
2017-11-13 09:35:55 +08:00
Lunny Xiao
62d0a4d882 Add external markup render support ()
* add external markup render support

* bug fixed

* refacotr codes and fix wrong error log

* fix comments and add check to prevent leaks

* add check for config file and improve the example

* check file close error

* use ioutil.TempFile instead uuid

* correct Render -> Parser

* improve warning when incorrect markup setting

* fix typos
2017-11-07 08:33:06 +02:00
Lunny Xiao
0d80af649a Add init support of orgmode document type on file view and readme ()
* add init support of orgmode document type on file view and readme

* fix imports

* fix imports and readmeExist

* fix imports order

* fix format

* remove unnecessary convert
2017-09-21 13:20:14 +08:00
Lunny Xiao
52e11b24bf Restructure markup & markdown to prepare for multiple markup language… ()
* restructure markup & markdown to prepare for multiple markup languages support

* adjust some functions between markdown and markup

* fix tests

* improve the comments
2017-09-16 20:17:57 +03:00
Ethan Koenig
9e627af9a4 gofmt () 2017-05-12 16:09:53 +08:00
mappu
fd76f090a2 markup: microoptimise for many short filenames in directory ()
* markup: microoptimise for many short filenames in directory

Move strings.ToLower() after the early-return length check. This is a safe operation in all cases and should slightly improve directory listing performance when a directory contains many thousands of files with short filenames.

* markup: expand test cases for IsReadmeFile()
2017-05-09 22:20:22 +08:00
Lunny Xiao
0d1e001b9c fix multiple readme file rendering and fix ()
* fix multiple readme file rendering and fix 

* remove unnecessary loop
2017-05-02 16:57:54 +08:00
Lunny Xiao
52627032bc Add markup package to prepare for org markup format () 2017-04-21 09:01:08 +02:00