forked from tangled.org/core
this repo has no description

appview/pages: unconditionally apply syntax highlights

Signed-off-by: oppiliappan <me@oppi.li>

oppi.li 8b73729e 418ce504

verified
Changed files
+21 -24
appview
pages
+21 -24
appview/pages/pages.go
··· 674 674 } 675 675 } 676 676 677 - if params.Lines < 5000 { 678 - c := params.Contents 679 - formatter := chromahtml.New( 680 - chromahtml.InlineCode(false), 681 - chromahtml.WithLineNumbers(true), 682 - chromahtml.WithLinkableLineNumbers(true, "L"), 683 - chromahtml.Standalone(false), 684 - chromahtml.WithClasses(true), 685 - ) 677 + c := params.Contents 678 + formatter := chromahtml.New( 679 + chromahtml.InlineCode(false), 680 + chromahtml.WithLineNumbers(true), 681 + chromahtml.WithLinkableLineNumbers(true, "L"), 682 + chromahtml.Standalone(false), 683 + chromahtml.WithClasses(true), 684 + ) 686 685 687 - lexer := lexers.Get(filepath.Base(params.Path)) 688 - if lexer == nil { 689 - lexer = lexers.Fallback 690 - } 686 + lexer := lexers.Get(filepath.Base(params.Path)) 687 + if lexer == nil { 688 + lexer = lexers.Fallback 689 + } 691 690 692 - iterator, err := lexer.Tokenise(nil, c) 693 - if err != nil { 694 - return fmt.Errorf("chroma tokenize: %w", err) 695 - } 696 - 697 - var code bytes.Buffer 698 - err = formatter.Format(&code, style, iterator) 699 - if err != nil { 700 - return fmt.Errorf("chroma format: %w", err) 701 - } 691 + iterator, err := lexer.Tokenise(nil, c) 692 + if err != nil { 693 + return fmt.Errorf("chroma tokenize: %w", err) 694 + } 702 695 703 - params.Contents = code.String() 696 + var code bytes.Buffer 697 + err = formatter.Format(&code, style, iterator) 698 + if err != nil { 699 + return fmt.Errorf("chroma format: %w", err) 704 700 } 705 701 702 + params.Contents = code.String() 706 703 params.Active = "overview" 707 704 return p.executeRepo("repo/blob", w, params) 708 705 }