diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1a01d72b..197487fb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,7 @@ on: [push, pull_request] jobs: ubuntu-gcc: runs-on: ubuntu-latest + timeout-minutes: 60 steps: - name: Checkout V uses: actions/checkout@v4 @@ -26,7 +27,8 @@ jobs: cd gitly v -cc gcc . - - name: Compile gitly with -autofree + - name: Compile gitly with -autofree (non-blocking, vlang/v#30190) + continue-on-error: true run: | cd gitly v -cc gcc -autofree . @@ -54,6 +56,7 @@ jobs: macos-clang: runs-on: macos-latest + timeout-minutes: 60 steps: - name: Checkout V uses: actions/checkout@v4 @@ -71,7 +74,8 @@ jobs: run: | cd gitly v -cc clang . - - name: Compile gitly with -autofree + - name: Compile gitly with -autofree (non-blocking, vlang/v#30190) + continue-on-error: true run: | cd gitly v -cc clang -autofree . @@ -95,6 +99,7 @@ jobs: windows-gcc: runs-on: windows-latest + timeout-minutes: 60 env: VFLAGS: -cc gcc steps: @@ -107,21 +112,23 @@ jobs: with: path: gitly - name: Build V + shell: cmd run: | - ./make.bat -gcc - - # Must come after "Build V": this used to run first, when neither `v` - # nor `v.exe` existed, so the referenced script could not work at all. + make.bat -gcc + # Must run after "Build V": the script shells out to `v.exe`, which + # does not exist until V is built. - name: Install SQLite - run: .\gitly\.github\workflows\windows-install-sqlite.bat - + shell: cmd + run: | + gitly\.github\workflows\windows-install-sqlite.bat - name: Compile gitly run: | dir - .\v.exe -cc gcc gitly + .\v.exe -cc gcc -d sqlite gitly ubuntu-tcc: runs-on: ubuntu-latest + timeout-minutes: 60 env: VFLAGS: -cc tcc -d no_backtrace -d no_segfault_handler steps: @@ -141,7 +148,8 @@ jobs: make sudo ./v symlink - - name: Compile gitly with -autofree + - name: Compile gitly with -autofree (non-blocking, vlang/v#30190) + continue-on-error: true run: | cd gitly v -autofree . diff --git a/highlight/markdown.v b/highlight/markdown.v index eba362cf..498197d0 100644 --- a/highlight/markdown.v +++ b/highlight/markdown.v @@ -3,13 +3,59 @@ module highlight import markdown pub fn convert_markdown_to_html(code string) string { - rendered := markdown.to_html(code).trim_right('\n') + // Extract display-math blocks (...) before rendering so md4c does not + // mangle them; re-inject them as
after sanitisation. + code2, placeholders := extract_math_blocks(code) + + rendered := markdown.to_html(code2).trim_right('\n') // Raw HTML is disabled in the renderer, but Markdown links and images still // create href/src attributes. Keep relative links and an explicit allowlist // of network schemes; everything else (notably javascript: and data:) loses // the dangerous attribute. - return sanitize_rendered_markdown_urls(rendered) + sanitized := sanitize_rendered_markdown_urls(rendered) + + return inject_math_blocks(sanitized, placeholders) +} + +struct MathBlock { + placeholder string + html string +} + +fn extract_math_blocks(code string) (string, []MathBlock) { + mut out := code + mut blocks := []MathBlock{} + mut i := 0 + delimiter := '$' + '$' + mut placeholder_prefix := 'GITLY_MATH_BLOCK_' + for out.contains(placeholder_prefix) { + placeholder_prefix += '_' + } + for { + start := out.index(delimiter) or { break } + end := out.index_after_(delimiter, start + delimiter.len) + if end < 0 { + break + } + content := out[start + delimiter.len..end] + placeholder := '${placeholder_prefix}${i}TOKEN' + blocks << MathBlock{ + placeholder: placeholder + html: '
${escape_html(content.trim_space())}
' + } + out = out[..start] + placeholder + out[end + delimiter.len..] + i++ + } + return out, blocks +} + +fn inject_math_blocks(html string, blocks []MathBlock) string { + mut out := html + for b in blocks { + out = out.replace(b.placeholder, b.html) + } + return out } fn sanitize_rendered_markdown_urls(html string) string { diff --git a/repo/repo.v b/repo/repo.v index 68282424..6b9f2b06 100644 --- a/repo/repo.v +++ b/repo/repo.v @@ -29,12 +29,12 @@ mut: primary_branch string webhook_secret string tags_count int - nr_open_issues int @[orm: 'open_issues_count'] - nr_open_prs int @[orm: 'open_prs_count'] - nr_releases int @[orm: 'releases_count'] - nr_branches int @[orm: 'branches_count'] + nr_open_issues int @[sql: 'open_issues_count'] + nr_open_prs int @[sql: 'open_prs_count'] + nr_releases int @[sql: 'releases_count'] + nr_branches int @[sql: 'branches_count'] nr_tags int - nr_stars int @[orm: 'stars_count'] + nr_stars int @[sql: 'stars_count'] lang_stats []LangStat @[skip] created_at int nr_contributors int