summaryrefslogtreecommitdiffstats
path: root/modules/markup
Commit message (Collapse)AuthorAgeFilesLines
* Prevent NPE on partial match of compare URL and allow short SHA1 compare ↵Gusted2022-01-312-1/+21
| | | | | | | | | | | | | URLs (#18472) (#18473) * Don't panic & allow shorter sha1 (#18472) - Backport of #18472 * Improve comment Co-authored-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Andrew Thornton <art27@cantab.net>
* Remove unneeded debug messages to stdout. (#18298)Ben Niemann2022-01-161-4/+0
| | | Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Simplify parameter types (#18006)Gusted2021-12-201-1/+1
| | | Remove repeated type declarations in function definitions.
* Fixed emoji alias not parsed in links (#16221)KN4CK3R2021-12-152-9/+16
| | | | | | | | * Do not skip links. * Restrict text in links to emojis. Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: zeripath <art27@cantab.net>
* Fix markdown URL parsing (#17924)wxiaoguang2021-12-113-75/+127
| | | | Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: zeripath <art27@cantab.net>
* Make Requests Processes and create process hierarchy. Associate ↵zeripath2021-11-301-6/+2
| | | | | | | | | OpenRepository with context. (#17125) This PR registers requests with the process manager and manages hierarchy within the processes. Git repos are then associated with a context, (usually the request's context) - with sub commands using this context as their base context. Signed-off-by: Andrew Thornton <art27@cantab.net>
* Prevent double sanitize (#16386)KN4CK3R2021-11-193-64/+48
| | | | | | | | * Prevent double sanitize. * Use SanitizeReaderToWriter. At the moment `actualRender` uses `SanitizeReader` to sanitize the output. But `SanitizeReader` gets called in `markup.render` too so the output gets sanitized twice. I moved the `SanitizeReader` call into `RenderRaw` because this method does not use `markup.render`. I would like to remove the `RenderRaw`/`RenderRawString` methods too because they are only called from tests, the fuzzer and the `/markup/raw` api endpoint. This endpoint is not in use so I think we could remove them. If we really in the future need a method to render markdown without PostProcessing we could achieve this with a more flexible `renderer.NeedPostProcess` method.
* A better go code formatter, and now `make fmt` can run in Windows (#17684)wxiaoguang2021-11-172-2/+2
| | | | * go build / format tools * re-format imports
* Add copy button to markdown code blocks (#17638)silverwind2021-11-162-13/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add copy button to markdown code blocks Done mostly in JS because I think it's better not to try getting buttons past the markup sanitizer. * add svg module tests * fix sanitizer regexp * remove outdated comment * vertically center button in issue comments as well * add comment to css * fix undefined on view file line copy * combine animation less files * Update modules/markup/markdown/markdown.go Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> * add test for different sizes * add cloneNode and add tests for it * use deep clone * remove useless optional chaining * remove the svg node cache * unify clipboard copy string and i18n * remove unused var * remove unused localization * minor css tweaks to the button * comment tweak * remove useless attribute Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Properly determine CSV delimiter (#17459)Richard Mahn2021-10-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Fixes #16558 CSV delimiter determiner * Fixes #16558 - properly determine CSV delmiiter * Moves quoteString to a new function * Adds big test with lots of commas for tab delimited csv * Adds comments * Shortens the text of the test * Removes single quotes from regexp as only double quotes need to be searched * Fixes spelling * Fixes check of length as it probalby will only be 1e4, not greater * Makes sample size a const, properly removes truncated line * Makes sample size a const, properly removes truncated line * Fixes comment * Fixes comment * tests for FormatError() function * Adds logic to find the limiter before or after a quoted value * Simplifies regex * Error tests * Error tests * Update modules/csv/csv.go Co-authored-by: delvh <dev.lh@web.de> * Update modules/csv/csv.go Co-authored-by: delvh <dev.lh@web.de> * Adds comments * Update modules/csv/csv.go Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: delvh <dev.lh@web.de>
* Fix issue markdown bugs (#17411)wxiaoguang2021-10-232-1/+5
| | | | * Bug fix: render Markdown http://AppURL/org/repo/issues/4?a=1&b=2#comment-123 test to HTML correctly, close #17394 * Bug fix: fix the positions of checkboxes in rendered HTML, close #17395
* Fix some lints (#17337)Lunny Xiao2021-10-171-3/+3
| | | Fix some linting problems.
* Open markdown image links in new window (#17287)wxiaoguang2021-10-112-4/+8
|
* Prevent panic in Org mode HighlightCodeBlock (#17140)zeripath2021-09-242-1/+34
| | | | | | | | | | | When rendering source in org mode there is a mistake in the highlight code that causes a panic. This PR fixes this. Fix #17139 Signed-off-by: Andrew Thornton <art27@cantab.net>
* refactor: move from io/ioutil to io and os package (#17109)Eng Zer Jun2021-09-224-8/+4
| | | | | | | | | The io/ioutil package has been deprecated as of Go 1.16, see https://golang.org/doc/go1.16#ioutil. This commit replaces the existing io/ioutil functions with their new definitions in io and os packages. Signed-off-by: Eng Zer Jun <engzerjun@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Do not show issue context popup on external issues (#17050)zeripath2021-09-153-4/+11
| | | | | | | | | The issues pop-up context cannot work for external issues - therefore do not show these. Fix #17047 Signed-off-by: Andrew Thornton <art27@cantab.net>
* In Render tolerate not being passed a context (#16842)zeripath2021-08-281-1/+7
| | | | | | | | | | | | | | | | | | | * In Render tolerate not being passed a context It is possible for RenderString to be passed to an external renderer if markdown is set to be rendered by an external renderer. No context is currently sent to these meaning that this will error out. Fix #16835 Signed-off-by: Andrew Thornton <art27@cantab.net> * Add Context to Repo calls for RenderString All calls from routers can easily add the context - so add it. Signed-off-by: Andrew Thornton <art27@cantab.net>
* Fix NPE in fuzzer (#16680)zeripath2021-08-132-1/+17
| | | | | | | The fuzzer found an issue with the issue pattern processor where there is a spurious path.Clean which does not need to be there. This PR also sets the default AppURL for the fuzzer too. Signed-off-by: Andrew Thornton <art27@cantab.net>
* Fix table alignment in markdown (#16596)zeripath2021-08-021-1/+3
| | | | | | | | Set the TableOptions in markdown to allow alignment of the tables to work correctly Fix #15959 Signed-off-by: Andrew Thornton <art27@cantab.net>
* modules/markup/markdown: fix dropped test error (#16438)Lars Lehtonen2021-07-181-0/+1
|
* cleanup code `issueFullPattern` in modules/markup (#16419)Josef Fröhle2021-07-152-7/+9
| | | fix #16415
* Fix external renderer (#16401)65432021-07-121-0/+4
| | | | | | | | | * fix external renderer * use GBackground context as fallback * no fallback, return error Co-authored-by: Lauris BH <lauris@nix.lv>
* Update bluemonday to v1.0.15 (#16379)65432021-07-091-3/+3
| | | | | | | * update github.com/microcosm-cc/bluemonday * add exec flag to contrib/update_dependencies.sh * Fix TESTS
* Fix various documentation, user-facing, and source comment typos (#16367)luzpaz2021-07-083-4/+4
| | | | | * Fix various doc, user-facing, and source comment typos Found via `codespell -q 3 -S ./options/locale,./vendor -L ba,pullrequest,pullrequests,readby`
* Fix relative links in postprocessed images (#16334)zeripath2021-07-042-1/+37
| | | | | | | | | | If a pre-post-processed file contains relative img tags these need to be updated and joined correctly with the prefix. Finally, the node attributes need to be updated. Fix #16308 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de>
* Prevent zombie processes (#16314)zeripath2021-06-301-1/+9
| | | | | | | | | Unfortunately go doesn't always ensure that execd processes are completely waited for. On linux this means that zombie processes can occur. This PR ensures that these are waited for by using signal notifier in serv and passing a context elsewhere. Signed-off-by: Andrew Thornton <art27@cantab.net>
* Add custom emoji support (#16004)65432021-06-292-16/+20
|
* Add sanitizer rules per renderer (#16110)KN4CK3R2021-06-237-66/+114
| | | | | | | * Added sanitizer rules per renderer. * Updated documentation. Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Add code block highlight to orgmode back (#14222)Lunny Xiao2021-06-231-0/+44
| | | | | Fix missed orgmode code block hightlight Co-authored-by: zeripath <art27@cantab.net>
* Use html.Parse rather than html.ParseFragment (#16223)zeripath2021-06-221-13/+12
| | | | | | | | * Use html.Parse rather than html.ParseFragment There have been a few issues with html.ParseFragment - just use html.Parse instead. * Skip document node Signed-off-by: Andrew Thornton <art27@cantab.net>
* More efficiently parse shas for shaPostProcessor (#16101)zeripath2021-06-212-10/+64
| | | | | | | | | | | | | | | | * More efficiently parse shas for shaPostProcessor The shaPostProcessor currently repeatedly calls git rev-parse --verify on both backends which is fine if there is only one thing that matches a sha - however if there are multiple things then this becomes wildly inefficient. This PR provides functions for both backends which are much faster to use. Fix #16092 * Add ShaExistCache to RenderContext Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de>
* Run processors on whole of text (#16155)zeripath2021-06-172-318/+411
| | | | | | | | | | | There is an inefficiency in the design of our processors which means that Emoji and other processors run in order n^2 time. This PR forces the processors to process the entirety of text node before passing back up. The fundamental inefficiency remains but it should be significantly ameliorated. Signed-off-by: Andrew Thornton <art27@cantab.net>
* issue-keyword class is being incorrectly stripped off spans (#16163)zeripath2021-06-161-5/+2
| | | | | | Bluemonday sanitizer regexp rules are not additive, so the addition of the icons, emojis and chroma syntax policy has led to this being stripped. Signed-off-by: Andrew Thornton <art27@cantab.net>
* Fix data URI scramble (#16098)KN4CK3R2021-06-074-19/+23
| | | | | | | * Removed unused method. * No prefix for data uris. * Added test to prevent regressions.
* Fixed assert statements. (#16089)KN4CK3R2021-06-071-2/+2
|
* Fix regression of renderer (#16091)Lunny Xiao2021-06-061-24/+34
| | | | | * Fix regression of renderer * Fix render setting load twice bug
* Make tasklist checkboxes clickable (#15791)KN4CK3R2021-05-233-13/+14
| | | | Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Lauris BH <lauris@nix.lv>
* 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>