summaryrefslogtreecommitdiffstats
path: root/modules/markup/html.go
Commit message (Collapse)AuthorAgeFilesLines
* Support inline rendering of CUSTOM_URL_SCHEMES (#8496)guillep2k2019-10-151-0/+26
| | | | | | | | | | * Support inline rendering of CUSTOM_URL_SCHEMES * Fix lint * Add tests * Fix lint
* Rewrite reference processing code in preparation for opening/closing from ↵guillep2k2019-10-131-60/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | comment references (#8261) * Add a markdown stripper for mentions and xrefs * Improve comments * Small code simplification * Move reference code to modules/references * Fix typo * Make MarkdownStripper return [][]byte * Implement preliminary keywords parsing * Add FIXME comment * Fix comment * make fmt * Fix permissions check * Fix text assumptions * Fix imports * Fix lint, fmt * Fix unused import * Add missing export comment * Bypass revive on implemented interface * Move mdstripper into its own package * Support alphanumeric patterns * Refactor FindAllMentions * Move mentions test to references * Parse mentions from reference package * Refactor code to implement renderizable references * Fix typo * Move patterns and tests to the references package * Fix nil reference * Preliminary rendering attempt of closing keywords * Normalize names, comments, general tidy-up * Add CSS style for action keywords * Fix permission for admin and owner * Fix golangci-lint * Fix golangci-lint
* Make link last commit massages in repository home page and commit tables (#8006)jaqra2019-09-101-13/+60
| | | | | | | | | | | | | | | | | | | | | * Make link last commit massages in repository home page and commit tables * Use RenderCommitMessageLink instead surround with a * deleted __debug_bin file * Exclude email to link from latest commit title * Exclude email processor from commit table Co-Authored-By: mrsdizzie <info@mrsdizzie.com> * Add class parameter to a html element creator functions. Make links underline dashed that are not commit * fix tests * Show dashed underline when also not hovered
* feat: highlight issue references with : (#8101)Rinat2019-09-051-2/+2
| | | | | | | | | | | * feat: highlight issue references with : e.g. #1287: my commit msg e.g. ABC-1234: my commit msg * ref: update model regex to consistent with issueNumericPattern * test: check highlight issue with : in commits messages
* Use gitea forked macaron (#7933)Tamal Saha2019-08-231-1/+1
| | | Signed-off-by: Tamal Saha <tamal@appscode.com>
* Check commit message hashes before making links (#7713)Gary Kim2019-08-141-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Check commit message hashes before making links Previously, when formatting commit messages, anything that looked like SHA1 hashes was turned into a link using regex. This meant that certain phrases or numbers such as `777777` or `deadbeef` could be recognized as a commit even if the repository has no commit with those hashes. This change will make it so that anything that looks like a SHA1 hash using regex will then also be checked to ensure that there is a commit in the repository with that hash before making a link. Signed-off-by: Gary Kim <gary@garykim.dev> * Use gogit to check if commit exists This commit modifies the commit hash check in the render for commit messages to use gogit for better performance. Signed-off-by: Gary Kim <gary@garykim.dev> * Make code cleaner Signed-off-by: Gary Kim <gary@garykim.dev> * Use rev-parse to check if commit exists Signed-off-by: Gary Kim <gary@garykim.dev> * Add and modify tests for checking hashes in html link rendering Signed-off-by: Gary Kim <gary@garykim.dev> * Return error in sha1CurrentPatternProcessor Co-Authored-By: mrsdizzie <info@mrsdizzie.com> * Import Gitea log module Signed-off-by: Gary Kim <gary@garykim.dev> * Revert "Return error in sha1CurrentPatternProcessor" This reverts commit 28f561cac46ef7e51aa26aefcbe9aca4671366a6. Signed-off-by: Gary Kim <gary@garykim.dev> * Add debug logging to sha1CurrentPatternProcessor This will log errors by the git command run in sha1CurrentPatternProcessor if the error is one that was unexpected. Signed-off-by: Gary Kim <gary@garykim.dev>
* Removed unnecessary conversions (#7557)Christian Muehlhaeuser2019-07-231-2/+2
| | | No need to convert to the same type.
* fix hljs unintenionally highlighting commit links (#7244)silverwind2019-06-181-0/+1
| | | | | | * fix hljs unintenionally highlighting commit links * fix unit tests
* Add golangci (#6418)kolaente2019-06-121-33/+1
|
* Fix domain name pattern in email regex (#6739)mrsdizzie2019-04-241-1/+1
| | | Fixes #6735
* Use ctx.metas for SHA hash links (#6645)mrsdizzie2019-04-161-1/+4
| | | | | | | | Since #6273 was merged, we now have access to proper context metas always. Update SHA generated links to use these instead of urlPrefix. Update tests as well. Fixes #4536.
* Improve issue autolinks (#6273)mrsdizzie2019-04-121-8/+26
| | | | | | | | | | | | | | | | | | | | | | | | | * Improve issue autolinks Update autolinks to match what github does here: Issue in same repo: #1 Issue in different repo: org/repo#1 Fixes #6264 * Use setting.AppURL when parsing URL Using setting.AppURL here is a more reliable way of parsing the current URL and what other functions in this file seem to use. * Make ComposeMetas always return a valid context * Add per repository markdown renderers for better context * Update for use of context metas Now that we include the user and repo name inside context metas, update various code and tests for this new logic
* Render SHA1 links as code blocks (#6546)silverwind2019-04-091-14/+31
|
* Use stricter boundaries for auto-link detection (#6522)mrsdizzie2019-04-071-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Use stricter boundaries for auto-link detection Currently autolinks use \W for boundary detection which creates many situations of inserting links into places they don't belong (paths, URLs, UUIDs, etc...) This fixes that by replacing \W and only allowing these matches to touch an open paren or bracket (matching what seems to be Github behavior) in addition to whitespace and start of line. Similar for ending boundary as well. Fixes #6149 (and probably others) * Update test Replace incorrect test with a value that is a valid username, based on: "Username should contain only alphanumeric, dash ('-'), underscore ('_') and dot ('.') characters." * Also allow for period at the end Matching Github behavior * Fix email regex to work properly with specificed boundaries Create a specific capture group for email address and then use FindStringSubmatchIndex to allow for non-matching patterns as boundaries. * Add Tests Add tests for new behavior -- including tests for email addresses which were absent before.
* Improve SHA1 link detection (#6526)silverwind2019-04-061-16/+31
| | | | | | | | This improves the SHA1 link detection to not pick up extraneous non-whitespace characters at the end of the URL. The '.' is a special case handled in code itself because of missing regexp lookahead support. Regex test cases: https://regex101.com/r/xUMlqh/3
* Change order that PostProcess Processors are run (#6445)mrsdizzie2019-03-271-7/+7
| | | | | | | | | | 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 #4813
* Use Go1.11 module (#5743)Mura Li2019-03-271-1/+1
| | | | | | | | | | | | | | | | | | * 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
* Fix reported issue in repo description (#6306)zeripath2019-03-111-0/+48
|
* Replace linkRegex with xurls library (#6261)mrsdizzie2019-03-071-3/+2
| | | | | | | | | | | | | | | | | | | | * 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: #5844 #3095 #3381 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.
* Remove visitLinksForShortLinks features (#6257)mrsdizzie2019-03-071-14/+5
| | | | | | | | | | | | | | | | | | | | | | 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 (#4946). No current tests rely on this behavior either. This removes the feature and also explicitly excludes the current visitNodeForShortLinks from looking in <a> tags.
* Modify linkRegex to require http|https (#6171)mrsdizzie2019-02-281-1/+1
| | | | | 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
* Upgrade images in .drone.yml to more recent versions (#4819)techknowlogick2018-08-291-4/+4
|
* markup: escape short wiki link (#4091)Antoine GIRARD2018-06-151-0/+3
|
* Fix wiki inter-links with cases and add tests for this case (#3560)Chaz Reid2018-03-051-1/+5
|
* Rework special link parsing in the post-processing of markup (#3354)Morgan Bazalgette2018-02-271-392/+502
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
* Populate URL field of API commits (#3546)Ethan Koenig2018-02-201-25/+11
| | | | | | * Populate URL field of API commits * fix orgmode_test
* Allow square brackets in external issue patterns (#3408)Christian Köberl2018-02-031-2/+2
| | | | | | * Allow square brackets in external issue patterns * Added false test cases for checklist elements
* Recognize more characters in crossreferenced repo name (#3413)Lauris BH2018-01-271-1/+1
|
* Fix issue link rendering in commit messages (#2897)Ethan Koenig2017-11-131-17/+67
| | | | | | | | | | * Fix issue link rendering in commit messages * Update page.tmpl * No links for parens * remove comment
* Restructure markup & markdown to prepare for multiple markup language… (#2411)Lunny Xiao2017-09-161-0/+517
* restructure markup & markdown to prepare for multiple markup languages support * adjust some functions between markdown and markup * fix tests * improve the comments