aboutsummaryrefslogtreecommitdiffstats
path: root/modules/markup
Commit message (Collapse)AuthorAgeFilesLines
* Valid email address should only start with alphanumeric (#28174)Dejan Kitic12 hours3-10/+43
| | | | | | | | | | | | This fixes issue #27847 where regular expression allowed email address to start with special symbols. Valid email addresses should start with alphanumeric character, and as such will be rendered as email. Added test cases from the bug report to validate, such input will not be rendered anymore as email address. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* markup: improve code block readability and isolate copy button (#34009)D41 hours1-7/+2
| | | | | | | | Fix #33197 Improve the rendering of code blocks in markdown content for better readability and UI stability across screen sizes. Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Uniform all temporary directories and allow customizing temp path (#32352)Lunny Xiao12 days1-9/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This PR uniform all temporary directory usage so that it will be easier to manage. Relate to #31792 - [x] Added a new setting to allow users to configure the global temporary directory. - [x] Move all temporary files and directories to be placed under os.Temp()/gitea. - [x] `setting.Repository.Local.LocalCopyPath` now will be `setting.TempPath/local-repo` and the customized path is removed. ```diff -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;[repository.local] -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; Path for local repository copy. Defaults to TEMP_PATH + `local-repo`, this is deprecated and cannot be changed -;LOCAL_COPY_PATH = local-repo ``` - [x] `setting.Repository.Upload.TempPath` now will be `settting.TempPath/uploads` and the customized path is removed. ```diff ;[repository.upload] -;; -;; Path for uploads. Defaults to TEMP_PATH + `uploads` -;TEMP_PATH = uploads ``` - [x] `setting.Packages.ChunkedUploadPath` now will be `settting.TempPath/package-upload` and the customized path is removed. ```diff ;[packages] -;; -;; Path for chunked uploads. Defaults it's `package-upload` under `TEMP_PATH` unless it's an absolute path. -;CHUNKED_UPLOAD_PATH = package-upload ``` - [x] `setting.SSH.KeyTestPath` now will be `settting.TempPath/ssh_key_test` and the customized path is removed. ```diff [server] -;; -;; Directory to create temporary files in when testing public keys using ssh-keygen, -;; default is the system temporary directory. -;SSH_KEY_TEST_PATH = ``` TODO: - [ ] setting.PprofDataPath haven't been changed because it may need to be kept until somebody read it but temp path may be clean up any time. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Make markdown render match GitHub's behavior (#34129)wxiaoguang2025-04-062-4/+11
| | | For #2246
* Fix markdown render behaviors (#34122)wxiaoguang2025-04-056-46/+109
| | | | | | | * Fix #27645 * Add config options `MATH_CODE_BLOCK_DETECTION`, problematic syntaxes are disabled by default * Fix #33639 * Add config options `RENDER_OPTIONS_*`, old behaviors are kept
* Refactor markup render to fix various path problems (#34114)wxiaoguang2025-04-0419-245/+194
| | | | | | | | | | | * Fix #33972 * Use consistent path resolving for links and medias. * No need to make the markup renders to resolve the paths, instead, the paths are all correctly resolved in the "post process" step. * Fix #33274 * Since 1.23, all paths starting with "/" are relative to current render context (for example: the current repo branch) * Introduce `/:root/path-relative-to-root`, then the path will be rendered as relative to "ROOT_URL"
* Fix markdown frontmatter rendering (#34102)wxiaoguang2025-04-037-106/+124
| | | Fix #34101
* Enable addtional linters (#34085)TheFox0x72025-04-013-7/+6
| | | | | | | | enable mirror, usestdlibbars and perfsprint part of: https://github.com/go-gitea/gitea/issues/34083 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Enable testifylint rules (#34075)TheFox0x72025-03-316-15/+15
| | | | enable testifylint rules disabled in: https://github.com/go-gitea/gitea/pull/34054
* enable staticcheck QFxxxx rules (#34064)TheFox0x72025-03-294-12/+17
|
* Fix markdown render (#33870)wxiaoguang2025-03-134-21/+22
| | | | | Fix #33869, some code block is moved to make it easier to test. Added a new test
* Refactor global init code and add more comments (#33755)wxiaoguang2025-03-031-0/+4
| | | | | | | | | | | | | | | | | | | Follow up #33748 Now there are 3 "global" functions: * registerGlobalSelectorFunc: for all elements matching the selector, eg: `.ui.dropdown` * registerGlobalInitFunc: for `data-global-init="initInputAutoFocusEnd"` * registerGlobalEventFunc: for `data-global-click="onCommentReactionButtonClick"` And introduce `initGlobalInput` to replace old `initAutoFocusEnd` and `attachDirAuto`, use `data-global-init` to replace fragile `.js-autofocus-end` selector. Another benefit is that by the new approach, no matter how many times `registerGlobalInitFunc` is called, we only need to do one "querySelectorAll" in the last step, it could slightly improve the performance.
* Use test context in tests and new loop system in benchmarks (#33648)TheFox0x72025-02-205-9/+6
| | | | | | | | Replace all contexts in tests with go1.24 t.Context() --------- Co-authored-by: Giteabot <teabot@gitea.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* chore: fix some trivial problems and TODOs (#33473)wxiaoguang2025-02-021-1/+1
| | | | | | | | | | | 1. Fix incorrect `MentionCount` (actually it seems to be deadcode, affects nothing) 2. Remove fallback sha1 support for time limit token 3. Use route middleware `reqRepoActionsWriter` for `ArtifactsDeleteView` 4. Use clearer message "Failed to authenticate user" instead of "Verify" when auth fails 5. `tests/integration/benchmarks_test.go` is not quite right, actually it is never used, so delete it. 6. Remove or update TODO comments
* Refactor context repository (#33202)wxiaoguang2025-01-122-3/+3
|
* Refactor older tests to use testify (#33140)TheFox0x72025-01-091-16/+8
| | | | | Refactor checks to use assert/require Use require.Eventually for waiting in elastic and meilisearch tests Use require to exit early instead of assert
* Refactor HTMLFormat, update chroma render, fix js error (#33136)wxiaoguang2025-01-084-5/+7
| | | | | | A small refactor to improve HTMLFormat, to help to prevent low-level mistakes. And fix #33141, fix #33139
* Fix "stop time tracking button" on navbar (#33084)wxiaoguang2025-01-031-1/+1
| | | | | | | | Fix #33083 By the way (something I was working on): 1. relax color/background-color for more markup elements 2. fix a command line sentence error
* Refactor "string truncate" (#32984)wxiaoguang2024-12-262-4/+4
|
* Do not render truncated links in markdown (#32980)wxiaoguang2024-12-262-0/+15
| | | Fixes #31780
* Add sub issue list support (#32940)wxiaoguang2024-12-244-39/+143
| | | Just like GitHub, show issue icon/title when the issue number is in a list
* Update go tool dependencies (#32916)silverwind2024-12-194-4/+4
| | | | | | | | | | | | | | | | | Update all go tool dependencies to latest version. WIP because I think there are new gopls errors, would like to confirm them on CI first. Here is from a local run: ``` modules/markup/markdown/goldmark.go:115:37-53: unnecessary type arguments modules/markup/html.go:45:32-49: unnecessary type arguments modules/markup/internal/renderinternal.go:20:33-49: unnecessary type arguments modules/markup/common/linkify.go:27:32-49: unnecessary type arguments modules/util/time_str.go:28:39-63: unnecessary type arguments routers/web/repo/pull.go:704:19: impossible condition: non-nil == nil modules/util/util_test.go:248:14-23: unused parameter: other ``` ~~Backport because the `gxz` update might have security benefits.~~
* Fix various trivial problems (#32861)wxiaoguang2024-12-171-1/+2
| | | | | | | | | | | | | | 1. add/improve comments to help future readers could understand the problem more easily. 2. add an error log to LDAP with username fallback 3. use `or` instead of `Iif` for "repo/branch_dropdown" (`Iif` was a mistake, but it doesn't really affect the UI) 4. add `tw-font-mono` style to container digest to match dockerhub 5. fix a bug in RepoBranchTagSelector: the form is not updated when there is no click to an item --------- Co-authored-by: delvh <dev.lh@web.de>
* Enable tenv and testifylint rules (#32852)TheFox0x72024-12-151-2/+2
| | | | Enables tenv and testifylint linters closes: https://github.com/go-gitea/gitea/issues/32842
* Refactor markdown math render (#32831)wxiaoguang2024-12-148-140/+125
| | | Add more tests
* Fix various UI bugs (#32821)wxiaoguang2024-12-133-26/+36
|
* Refactor markdown render (#32736)wxiaoguang2024-12-065-31/+100
| | | and add some tests
* Refactor markdown render (#32728)wxiaoguang2024-12-066-166/+268
| | | | Follow up recent render system refactoring PRs (split test code), and fine tune the math render (added some new cases)
* Fix issue title rendering and refactor legacy function names (#32703)wxiaoguang2024-12-043-22/+31
| | | | | | | | Fix #32700, regression of recent markup refactoring And by the way, clarify many legacy problems: 1. Some "RenderXxx" functions do not really "render", they only call "post processors" 2. Merge "RenderEmoji | RenderCodeBlock", they are all for "simple issue title"
* Refactor render system (orgmode) (#32671)wxiaoguang2024-11-292-50/+46
| | | Close #29100
* Refactor markup render system (#32645)wxiaoguang2024-11-266-215/+178
| | | | | | | This PR mainly removes some global variables, moves some code and renames some functions to make code clearer. This PR also removes a testing-only option ForceHardLineBreak during refactoring since the behavior is clear now.
* Refactor markup render system (#32612)wxiaoguang2024-11-2428-929/+312
| | | | | | | | | | This PR removes (almost) all path tricks, and introduces "renderhelper" package. Now we can clearly see the rendering behaviors for comment/file/wiki, more details are in "renderhelper" tests. Fix #31411 , fix #18592, fix #25632 and maybe more problems. (ps: fix #32608 by the way)
* Refactor markup render system (#32589)wxiaoguang2024-11-2221-347/+299
| | | | This PR mainly moves some code and introduces `RenderContext.WithXxx` functions
* Refactor markup render system (#32533)wxiaoguang2024-11-1831-439/+472
| | | | | Remove unmaintainable sanitizer rules. No need to add special "class" regexp rules anymore, use RenderInternal.SafeAttr instead, more details (and examples) are in the tests
* Fix and refactor markdown rendering (#32522)wxiaoguang2024-11-1616-188/+190
|
* Refactor render system (#32492)wxiaoguang2024-11-1415-155/+138
| | | | | | | | | | | | | | | | | | | There were too many patches to the Render system, it's really difficult to make further improvements. This PR clears the legacy problems and fix TODOs. 1. Rename `RenderContext.Type` to `RenderContext.MarkupType` to clarify its usage. 2. Use `ContentMode` to replace `meta["mode"]` and `IsWiki`, to clarify the rendering behaviors. 3. Use "wiki" mode instead of "mode=gfm + wiki=true" 4. Merge `renderByType` and `renderByFile` 5. Add more comments ---- The problem of "mode=document": in many cases it is not set, so many non-comment places use comment's hard line break incorrectly
* Support quote selected comments to reply (#32431)wxiaoguang2024-11-076-16/+32
| | | | | | | | | Many existing tests were quite hacky, these could be improved later. <details> ![image](https://github.com/user-attachments/assets/93aebb4f-9de5-4cb8-910b-50c64cbcd25a) </details>
* Refactor markup package (#32399)wxiaoguang2024-11-0414-1062/+1137
| | | | | | To make the markup package easier to maintain: 1. Split some go files into small files 2. Use a shared util.NopCloser, remove duplicate code 3. Remove unused functions
* Update go dependencies (#32389)wxiaoguang2024-10-314-4/+4
|
* refactor: remove redundant err declarations (#32381)Oleksandr Redko2024-10-301-2/+1
|
* Use camo.Always instead of camo.Allways (#32097)Lunny Xiao2024-09-212-2/+2
| | | | | Fix #31575 https://gitea.com/gitea/docs/pulls/73
* Fix raw wiki links (#31825)Zettat1232024-08-163-22/+16
| | | | | | | | | | | | | | Fix #31395 This regression is introduced by #30273. To find out how GitHub handles this case, I did [some tests](https://github.com/go-gitea/gitea/issues/31395#issuecomment-2278929115). I use redirect in this PR instead of checking if the corresponding `.md` file exists when rendering the link because GitHub also uses redirect. With this PR, there is no need to resolve the raw wiki link when rendering a wiki page. If a wiki link points to a raw file, access will be redirected to the raw link.
* Fix `IsObjectExist` with gogit (#31790)Jason Song2024-08-091-1/+2
| | | | | | | | | | | | | Fix #31271. When gogit is enabled, `IsObjectExist` calls `repo.gogitRepo.ResolveRevision`, which is not correct. It's for checking references not objects, it could work with commit hash since it's both a valid reference and a commit object, but it doesn't work with blob objects. So it causes #31271 because it reports that all blob objects do not exist.
* Fix markdown preview $$ support (#31514)charles2024-06-296-6/+79
| | | | | | | | | | | | | | | | | | | | | | close #31481 currently `$$A + B$$ test` will ignore text after $$ block test text ![圖片](https://github.com/go-gitea/gitea/assets/30816317/39b2974b-c0b6-48a0-87d0-5f4a13615eed) before fix ![圖片](https://github.com/go-gitea/gitea/assets/30816317/15469e4c-474d-4128-b46f-d6cadaafbd68) after fix ![圖片](https://github.com/go-gitea/gitea/assets/30816317/c1025eef-177f-4ade-988f-510e7039f3f9) github display ![圖片](https://github.com/go-gitea/gitea/assets/30816317/97cd1e10-ac94-4899-86d8-8e359ef1d694)
* bump golang deps (#31422)techknowlogick2024-06-241-1/+1
|
* Support relative paths to videos from Wiki pages (#31061)Sergey Sharybin2024-06-213-43/+83
| | | | | | | | | | | | | | | | | | This change fixes cases when a Wiki page refers to a video stored in the Wiki repository using relative path. It follows the similar case which has been already implemented for images. Test plan: - Create repository and Wiki page - Clone the Wiki repository - Add video to it, say `video.mp4` - Modify the markdown file to refer to the video using `<video src="video.mp4">` - Commit the Wiki page - Observe that the video is properly displayed --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix markdown math brackets render problem (#31420)charles2024-06-202-1/+9
| | | | | Close #31371, support `($ ... $)` like GitHub Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix rendered wiki page link (#31398)wxiaoguang2024-06-186-66/+51
| | | Fix #31395
* Refactor markup code (#31399)wxiaoguang2024-06-172-37/+10
| | | | | | 1. use clearer names 2. remove deadcode 3. avoid name shadowing 4. eliminate some lint warnings
* Fix missing images in editor preview due to wrong links (#31299)Brecht Van Lommel2024-06-171-4/+4
| | | | | | | | | | Parse base path and tree path so that media links can be correctly created with /media/. Resolves #31294 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>