aboutsummaryrefslogtreecommitdiffstats
path: root/modules/markup
Commit message (Collapse)AuthorAgeFilesLines
* Fixed individual markdown tests. (#15802)KN4CK3R2021-05-091-0/+6
|
* Fix URL of gitea emoji (#15770)silverwind2021-05-072-2/+2
| | | Fixes regression from #15219
* Refactor renders (#15175)Lunny Xiao2021-04-1913-485/+652
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Refactor renders * Some performance optimization * Fix comment * Transform reader * Fix csv test * Fix test * Fix tests * Improve optimaziation * Fix test * Fix test * Detect file encoding with reader * Improve optimaziation * reduce memory usage * improve code * fix build * Fix test * Fix for go1.15 * Fix render * Fix comment * Fix lint * Fix test * Don't use NormalEOF when unnecessary * revert change on util.go * Apply suggestions from code review Co-authored-by: zeripath <art27@cantab.net> * rename function * Take NormalEOF back Co-authored-by: zeripath <art27@cantab.net>
* Add NeedPostProcess for Parser interface to improve performance of csv ↵Lunny Xiao2021-04-135-4/+22
| | | | render (#15153)
* Links in markdown should be absolute to the repository not the server (#15088)zeripath2021-04-112-1/+15
| | | | | | | | | | | | | | | | | * Links in markdown should be absolute to the repository not the server Fix #15075 Signed-off-by: Andrew Thornton <art27@cantab.net> * match github Signed-off-by: Andrew Thornton <art27@cantab.net> * add testcase Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de>
* Upgrade to bluemonday 1.0.7 (#15379)zeripath2021-04-091-1/+1
| | | | | | | | | | | * Upgrade to bluemonday 1.0.7 Fix #15349 Signed-off-by: Andrew Thornton <art27@cantab.net> * resolve unit test Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Code Formats, Nits & Unused Func/Var deletions (#15286)65432021-04-091-3/+1
| | | | | | | | | | | | | | | * _ to unused func options * rm useless brakets * rm trifial non used models functions * rm dead code * rm dead global vars * fix routers/api/v1/repo/issue.go * dont overload import module
* Update to bluemonday-1.0.6 (#15294)zeripath2021-04-052-1/+15
| | | Signed-off-by: Andrew Thornton <art27@cantab.net>
* Add Tabular Diff for CSV files (#14661)KN4CK3R2021-03-293-71/+48
| | | | | | | | | | | | | | | | | | | | | | | Implements request #14320 The rendering of CSV files does match the diff style. * Moved CSV logic into base package. * Added method to create a tabular diff. * Added CSV compare context. * Added CSV diff template. * Use new table style in CSV markup. * Added file size limit for CSV rendering. * Display CSV parser errors in diff. * Lazy read single file. * Lazy read rows for full diff. * Added unit tests for various CSV changes.
* Clusterfuzz found another way (#15160)zeripath2021-03-261-1/+1
| | | | | Clusterfuzz found another way so I found another way to stop it Signed-off-by: Andrew Thornton <art27@cantab.net>
* Fix another clusterfuzz identified issue (#15096)zeripath2021-03-221-1/+1
| | | | | * Fix another clusterfuzz identified issue Signed-off-by: Andrew Thornton <art27@cantab.net>
* another clusterfuzz spotted issue (#15032)zeripath2021-03-181-1/+1
| | | Signed-off-by: Andrew Thornton <art27@cantab.net>
* Remove extraneous logging (#15020)zeripath2021-03-181-5/+0
| | | Signed-off-by: Andrew Thornton <art27@cantab.net>
* Fix several render issues (#14986)zeripath2021-03-164-34/+130
| | | | | | | | | * Fix an issue with panics related to attributes * Wrap goldmark render in a recovery function * Reduce memory use in render emoji * Use a pipe for rendering goldmark - still needs more work and a limiter Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Lauris BH <lauris@nix.lv>
* Make sure sibling images get a link too (#14979)zeripath2021-03-142-1/+43
| | | | | | | | | | | | * Make sure sibling images get a link too Due a problem with the ast.Walker in the our transformer in goldmark an image with a sibling image will not be transformed to gain a parent link. This PR fixes this. Fix #12925 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Clarify the suffices and prefixes of setting.AppSubURL and setting.AppURL ↵zeripath2021-02-191-5/+4
| | | | | | | | (#12999) Also removes some unnecessary uses of fmt.Sprintf and adds documentation strings Signed-off-by: Andrew Thornton <art27@cantab.net>
* Remove NULs byte arrays passed to PostProcess (#14587)zeripath2021-02-181-1/+23
| | | | | | | | | | | | PostProcess is supposed to be parsing and handling HTML fragments, but on fuzzing it appears that there is a weird issue with NUL elements that could cause a memory address error in downstream libraries. The simplest solution is to strip out the weird NULs - they should not be there in any case and would be stripped out anyway. Signed-off-by: Andrew Thornton <art27@cantab.net>
* Prevent panic on fuzzer provided string (#14405)zeripath2021-01-202-10/+53
| | | | | | | | | | | | | | | | | | | * Prevent panic on fuzzer provided string The fuzzer has found that providing a <body> tag with an attribute to PostProcess causes a panic. This PR removes any rendered html or body tags from the output. Signed-off-by: Andrew Thornton <art27@cantab.net> * Placate lint * placate lint again Signed-off-by: Andrew Thornton <art27@cantab.net> * minor cleanup Signed-off-by: Andrew Thornton <art27@cantab.net>
* Render links for commit hashes followed by comma (#14224)Nuno Silva2021-01-032-1/+7
| | | | | Regex test cases: https://regex101.com/r/mVbPxM/2/ fixes #14223
* Fix bug of link query order on markdown render (#14156)Lunny Xiao2020-12-291-1/+1
| | | | | | | * Fix bug of link query order on markdown render * Fix bluemonday bug and fix one wrong test Co-authored-by: 6543 <6543@obermui.de>
* Add mentionable teams to tributeValues and change team mention rules to gh's ↵a10121127962020-12-211-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | style (#13198) * Add mentionable teams to tributeValues Signed-off-by: a1012112796 <1012112796@qq.com> * Apply suggestions from code review Co-authored-by: silverwind <me@silverwind.io> * Change team mention rules to gh's style * use org's avator as team avator in ui Signed-off-by: a1012112796 <1012112796@qq.com> * Update modules/markup/html.go * Update models/issue.go Co-authored-by: Lauris BH <lauris@nix.lv> * Update models/issue.go * fix a small nit and update test code Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: 6543 <6543@obermui.de>
* Markdown task list improvements (#13952)silverwind2020-12-134-10/+10
| | | | | | | | | | | | * Markdown task list improvements - Remove `.ui` class and wrappers to prevent fomantic from messing with it. - Change rendered HTML to match GitHub. - Add custom styling for the checkboxes. * fix unittest Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Fix crash in short link processor (#13839)mrsdizzie2020-12-041-10/+12
| | | Fixes #13819
* Clickable links in pull request (and issue) titles (#13695)Jimmy Praet2020-12-031-0/+19
| | | | | | | | | * clickable links in pull request (and issue) titles #13658 reuses the existing logic to render clickable links in commit messages * dedicated RenderIssueTitle function applied patch from @mrsdizzie
* Update golangci-lint to version 1.31.0 (#13102)kolaente2020-10-112-5/+5
| | | | | | | This PR updates golangci-lint to the latest version 1.31.0. The upgrade introduced a new check for which I've fixed or disabled most cases. Signed-off-by: kolaente <k@knt.li>
* fix: media links in org files not liked to media files (#12997)Pranav Nachnekar2020-10-011-3/+17
| | | | | | | | | | | * fix: media links in org files not liked to media files * fix: write directly to io.Writer r as suggested by code review Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: zeripath <art27@cantab.net>
* Fix markdown meta parsing (#12817)John Olheiser2020-09-122-7/+72
| | | | | | | | | | | | | | | | | | | | | | | * Fix meta parsing and add minimal test Signed-off-by: jolheiser <john.olheiser@gmail.com> * Add license Signed-off-by: jolheiser <john.olheiser@gmail.com> * Require first separator and add more tests Signed-off-by: jolheiser <john.olheiser@gmail.com> * Make fmt Signed-off-by: jolheiser <john.olheiser@gmail.com> * Go lets this work gracefully :pray: Signed-off-by: jolheiser <john.olheiser@gmail.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Don't replace underscores in auto-generated IDs in goldmark (#12805)zeripath2020-09-121-1/+1
| | | | | Fix #12196 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Issue templates directory (#11450)John Olheiser2020-09-111-0/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Issue templates Signed-off-by: jolheiser <john.olheiser@gmail.com> * Add some comments, appease the linter Signed-off-by: jolheiser <john.olheiser@gmail.com> * Add docs and re-use dir candidates Signed-off-by: jolheiser <john.olheiser@gmail.com> * Add default labels to issue templates Signed-off-by: jolheiser <john.olheiser@gmail.com> * Generate swagger Signed-off-by: jolheiser <john.olheiser@gmail.com> * Suggested changes Signed-off-by: jolheiser <john.olheiser@gmail.com> * Update issue.go * Suggestions Signed-off-by: jolheiser <john.olheiser@gmail.com> * Extract metadata from legacy if possible Signed-off-by: jolheiser <john.olheiser@gmail.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Update to go-org 1.3.2 (#12728)zeripath2020-09-051-3/+3
| | | | | | | | | | | | | * Update to go-org 1.3.2 Fix #12727 Signed-off-by: Andrew Thornton <art27@cantab.net> * Fix unit test Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Fix emoji replacements, make emoji images consistent (#12567)silverwind2020-08-232-1/+2
| | | | | | | - Fix emoji not being replaced in issue title change text - Make the image attributes consistent, add alt, remove align Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Re-attempt to delete temporary upload if the file is locked by another ↵zeripath2020-08-111-1/+7
| | | | | | | | | | | process (#12447) Replace all calls to os.Remove/os.RemoveAll by retrying util.Remove/util.RemoveAll and remove circular dependencies from util. Fix #12339 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: silverwind <me@silverwind.io>
* Detect full references to issues and pulls in commit messages (#12399)zeripath2020-08-061-5/+71
| | | | | Fix #10269 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Add loading spinners and mermaid error handling (#12358)silverwind2020-08-042-5/+27
| | | | | - Add loading spinners on editor and mermaid renderers - Add error handling and inline error box for mermaid - Fix Mermaid rendering by using the .init api
* Fix emoji detection in certain cases (#12320)mrsdizzie2020-07-251-0/+4
| | | | | | | | | | | * Fix emoji detection certain cases Previous tests weren't complicated enough so there were some situations where emojis were't detected properly. Find the earliest occurance in addition to checking for the longest combination. Fixes #12312 * ok spell bot Co-authored-by: Lauris BH <lauris@nix.lv>
* Server-side syntax highlighting for all code (#12047)mrsdizzie2020-07-012-4/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* Disable all typographic replacements in markdown renderer (#11871)silverwind2020-06-132-8/+1
| | | | | | | | | | | | | | | | | | | * Disable all typographic replacements in markdown renderer Previously we only disabled some of them. This disables all the default replacements that goldmark's typographer extension offers, matching GitHub's renderer. Ref: https://github.com/yuin/goldmark#typographer-extension Fixes: https://github.com/go-gitea/gitea/issues/11001 * remove typographer extension completely * fix test * really fix test Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Update emoji regex (#11584)mrsdizzie2020-05-292-7/+4
| | | | | When matching emoji, use a regex built from the data we have instead of something generic using unicode ranges. A generic regex can't tell the difference between two separate emoji next to each other or one emoji that is built out of two separate emoji next to each other. This means that emoji that are next to each other without space in between will be now accurately spanned individually with proper title etc...
* Allow different HardBreaks settings for documents and comments (#11515)zeripath2020-05-242-8/+22
| | | | | | | | | | | | | | | | GH has different HardBreaks behaviour for markdown comments and documents. Comments have hard breaks and documents have soft breaks - therefore Gitea's rendering will always be different from GH's if we only provide one setting. Here we split the setting in to two - one for documents and one for comments and other things. Signed-off-by: Andrew Thornton art27@cantab.net Changes to index.js as per @silverwind Co-authored-by: silverwind <me@silverwind.io> Changes to docs as per @guillep2k Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
* Prevent 500 with badly formed task list (#11328)zeripath2020-05-113-21/+27
| | | | | Fix #11317 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Restore checkbox rendering and prevent poor sanitization of spans (#11277)zeripath2020-05-033-2/+20
| | | | | | | | | | | | | | | | | * Add test Signed-off-by: Andrew Thornton <art27@cantab.net> * Restore checkbox rendering and prevent poor sanitization of spans Signed-off-by: Andrew Thornton <art27@cantab.net> * Also fix preview context Signed-off-by: Andrew Thornton <art27@cantab.net> * Also fix preview context Signed-off-by: Andrew Thornton <art27@cantab.net>
* Remove last traces of has-emoji class (#11263)mrsdizzie2020-05-011-0/+2
| | | | | | Now that emojify.js has been removed, get rid of all instances of has-emoji class that was only used for that. Support for rendering shortcodes should remain in all of these places so it should still work the same. Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Lauris BH <lauris@nix.lv>
* Support unicode emojis and remove emojify.js (#11032)mrsdizzie2020-04-283-0/+172
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Support unicode emojis and remove emojify.js This PR replaces all use of emojify.js and adds unicode emoji support to various areas of gitea. This works in a few ways: First it adds emoji parsing support into gitea itself. This allows us to * Render emojis from valid alias (:smile:) * Detect unicode emojis and let us put them in their own class with proper aria-labels and styling * Easily allow for custom "emoji" * Support all emoji rendering and features without javascript * Uses plain unicode and lets the system render in appropriate emoji font * Doesn't leave us relying on external sources for updates/fixes/features That same list of emoji is also used to create a json file which replaces the part of emojify.js that populates the emoji search tribute. This file is about 35KB with GZIP turned on and I've set it to load after the page renders to not hinder page load time (and this removes loading emojify.js also) For custom "emoji" it uses a pretty simple scheme of just looking for /emojis/img/name.png where name is something a user has put in the "allowed reactions" setting we already have. The gitea reaction that was previously hard coded into a forked copy of emojify.js is included and works as a custom reaction under this method. The emoji data sourced here is from https://github.com/github/gemoji which is the gem library Github uses for their emoji rendering (and a data source for other sites). So we should be able to easily render any emoji and :alias: that Github can, removing any errors from migrated content. They also update it as well, so we can sync when there are new unicode emoji lists released. I've included a slimmed down and slightly modified forked copy of https://github.com/knq/emoji to make up our own emoji module. The code is pretty straight forward and again allows us to have a lot of flexibility in what happens. I had seen a few comments about performance in some of the other threads if we render this ourselves, but there doesn't seem to be any issue here. In a test it can parse, convert, and render 1,000 emojis inside of a large markdown table in about 100ms on my laptop (which is many more emojis than will ever be in any normal issue). This also prevents any flickering and other weirdness from using javascript to render some things while using go for others. Not included here are image fall back URLS. I don't really think they are necessary for anything new being written in 2020. However, managing the emoji ourselves would allow us to add these as a feature later on if it seems necessary. Fixes: https://github.com/go-gitea/gitea/issues/9182 Fixes: https://github.com/go-gitea/gitea/issues/8974 Fixes: https://github.com/go-gitea/gitea/issues/8953 Fixes: https://github.com/go-gitea/gitea/issues/6628 Fixes: https://github.com/go-gitea/gitea/issues/5130 * add new shared function emojiHTML * don't increase emoji size in issue title * Update templates/repo/issue/view_content/add_reaction.tmpl Co-Authored-By: 6543 <6543@obermui.de> * Support for emoji rendering in various templates * Render code and review comments as they should be * Better way to handle mail subjects * insert unicode from tribute selection * Add template helper for plain text when needed * Use existing replace function I forgot about * Don't include emoji greater than Unicode Version 12 Only include emoji and aliases in JSON * Update build/generate-emoji.go * Tweak regex slightly to really match everything including random invisible characters. Run tests for every emoji we have * final updates * code review * code review * hard code gitea custom emoji to match previous behavior * Update .eslintrc Co-Authored-By: silverwind <me@silverwind.io> * disable preempt Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
* Prevent panic during wrappedConn close at hammertime (#11219)zeripath2020-04-261-1/+0
| | | | | | | | | | | * Prevent panic during wrappedConn close at hammertime Signed-off-by: Andrew Thornton <art27@cantab.net> * Update modules/graceful/server.go * Fix extraneous debug in goldmark.go Signed-off-by: Andrew Thornton <art27@cantab.net>
* Make TaskCheckBox render correctly (#11214)zeripath2020-04-263-22/+97
| | | | | | | | | | | | | | | * Fix checkbox rendering Signed-off-by: Andrew Thornton <art27@cantab.net> * Normalize checkbox rendering Signed-off-by: Andrew Thornton <art27@cantab.net> * set the checkboxes to readonly instead of disabled Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Lauris BH <lauris@nix.lv>
* Use markdown frontmatter to provide Table of contents, language and ↵zeripath2020-04-247-16/+506
| | | | | | | | | frontmatter rendering (#11047) * Add control for the rendering of the frontmatter * Add control to include a TOC * Add control to set language - allows control of ToC header and CJK glyph choice. Signed-off-by: Andrew Thornton art27@cantab.net
* enable ENABLE_HARD_LINE_BREAK by default (#11162)silverwind2020-04-211-2/+2
| | | | | | | | enable ENABLE_HARD_LINE_BREAK by default This matches GitHub's rendering. Fix #11155
* Handle yaml frontmatter (#11016)zeripath2020-04-091-0/+2
| | | | | | | | Add goldmark-meta to render yaml frontmatter as a table Fix #5377 Signed-off-by: Andrew Thornton <art27@cantab.net>
* upgrade to most recent bluemonday (#11007)techknowlogick2020-04-071-3/+3
| | | | | | | | | | | * upgrade to most recent bluemonday * make vendor * update tests for bluemonday * update tests for bluemonday * update tests for bluemonday
* Fix internal server error on checkboxes (#10845)zeripath2020-03-261-1/+1
| | | | | | | Annoyingly goldmarks SetAttributeString requires that the value of the attribute is still a []byte but does not make it clear in the documentation. Signed-off-by: Andrew Thornton <art27@cantab.net>