about summary refs log tree commit diff
path: root/tools/cheddar/src/main.rs (follow)
AgeCommit message (Collapse)AuthorFilesLines
2020-07-25 r/1464 feat(tools/cheddar): Add endpoint for Markdown renderingVincent Ambo1-26/+56
Similar to the source code highlighting endpoint, but for Markdown. This is to be used by the bug tracker, as well as Sourcegraph in the future. Change-Id: I4bea5c46ba969ba9965b61409e1c19c2edf1246c Reviewed-on: https://cl.tvl.fyi/c/depot/+/1424 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi>
2020-06-20 r/1045 chore(cheddar): Clean up all clippy lintsVincent Ambo1-11/+10
Change-Id: I5544c10e964b57891fce6ea01f09eeec406e9bef Reviewed-on: https://cl.tvl.fyi/c/depot/+/510 Reviewed-by: lukegb <lukegb@tvl.fyi>
2020-06-20 r/1044 feat(cheddar): Add Sourcegraph-compatible highlighting serverVincent Ambo1-41/+94
Sourcegraph uses a component called syntect_server to syntax-highlight source files. Since we already have custom syntaxes, overrides and configuration we might as well use them with Sourcegraph! This implements the syntect_server "protocol" (it's just a single endpoint) so that we can swap out the syntect_server component with cheddar. Note: There's a few clippy lints here, but they're being solved in a followup commit because I wanted to take care of all of them at once (not just the ones introduced in this change). Change-Id: Ib518a2fa1b9fee299fe599482403599583cac479 Reviewed-on: https://cl.tvl.fyi/c/depot/+/509 Reviewed-by: lukegb <lukegb@tvl.fyi>
2020-06-19 r/1034 style(cheddar): Reformat with rustfmtVincent Ambo1-37/+44
Change-Id: I9a0764f23c1269447a8b18f3128074fc58f70456 Reviewed-on: https://cl.tvl.fyi/c/depot/+/492 Reviewed-by: glittershark <grfn@gws.fyi>
2020-06-19 r/1033 refactor(cheddar): Pass references readers & writers into renderersVincent Ambo1-15/+18
This paves the way for using other things than stdin/stdout as sources/sinks, which is required for example for implementing a syntect_server replacement based on cheddar. Change-Id: I5779db8dbf7b7ced109c26b940f721d237d60785 Reviewed-on: https://cl.tvl.fyi/c/depot/+/491 Reviewed-by: glittershark <grfn@gws.fyi> Reviewed-by: lukegb <lukegb@tvl.fyi>
2020-06-17 r/1005 refactor(cheddar): Switch to clap-rs for command line argumentsVincent Ambo1-30/+27
The complexity of the arg parsing is increasing somewhat because we're adding more features to cheddar, so to set us up for that this switches the arg parsing to the somewhat more flexible clap. Change-Id: I187bc0c1b6c6bd596fa0f6bb494b04e335262ba9 Reviewed-on: https://cl.tvl.fyi/c/depot/+/445 Reviewed-by: lukegb <lukegb@tvl.fyi> Reviewed-by: tazjin <mail@tazj.in>
2020-06-15 r/967 feat(cheddar): Override syntax highlighting for 'rules.pl' to PrologVincent Ambo1-8/+28
Adds a mechanism for per-filename overrides of the chosen language syntax and configures it for Gerrit's submit rule file. This also switches the syntax set used to the one from //third_party/bat_syntaxes, which contains custom additions such as Prolog support. Change-Id: I2023dbad5b326305ef2ef0ecf34ef66a3f7575ab Reviewed-on: https://cl.tvl.fyi/c/depot/+/349 Reviewed-by: riking <rikingcoding@gmail.com> Reviewed-by: lukegb <lukegb@tvl.fyi>
2020-02-09 r/511 Merge branch 'feat/cheddar-extensions'Vincent Ambo1-36/+114
2020-01-19 r/426 feat(cheddar): Add toggle flag for about-filter behaviourVincent Ambo1-13/+38
Cheddar now needs to be passed the --about-filter flag to toggle the behaviour for rendering Markdown into HTML. By default Markdown will be highlighted like normal source code (i.e. cgit source-filtering is the default behaviour).
2020-01-11 feat(cheddar): Implement callout paragraphsVincent Ambo1-0/+68
Implements support for tagging paragraphs that begin with a callout word (TODO, WARNING, QUESTION, TIP) with an additional `cheddar-*` class that makes it possible to render these callouts specially. This is currently not the nicest implementation, but it works.
2020-01-11 refactor(cheddar): Extract code block highlighting into functionVincent Ambo1-37/+47
Since I am going down the path of adding additional Markdown extensions it makes sense to avoid letting `format_markdown` turn into a giant beast of a function. Therefore this commit extracts the logic for rendering code blocks via syntect and changes the innards of `format_markdown` to instead provide arbitrary AST value replacements.
2019-12-22 r/291 fix(cheddar): Fix errors if filename does not have an extensionVincent Ambo1-9/+7
2019-12-21 r/288 feat(cheddar): Style pre-elements for better readabilityVincent Ambo1-4/+22
Uses GitHub-like styling for <pre> elements, i.e. slight padding and background colour highlighting.
2019-12-21 r/287 feat(cheddar): Render code blocks in Markdown via syntectVincent Ambo1-26/+82
Implements fully static (i.e. no JavaScript!) highlighting of code blocks when rendering Markdown. This works by walking through the Comrak AST and replacing any code blocks with pre-rendered HTML blocks. Syntaxes are chosen based on the "block info", which is the string users put after the block's opening fence. This can either be a (case-insensitive) name of a syntax, or alternatively a file extension associated with the desired syntax. The theme is set to one that imitates GitHub.
2019-12-21 r/282 feat(cheddar): Render Markdown via ComrakVincent Ambo1-9/+24
Renders any ".md" file by pushing it through the Comrak rendering pipeline. This does not yet implement syntax highlighting of fenced blocks, but we're getting there.
2019-12-21 r/281 refactor(cheddar): Set up scaffolding for Markdown renderingVincent Ambo1-11/+37
Generalises the two bits of the program that will be required either way (extension parsing and syntax loading). A dependency on Comrak is introduced as I think GitHub-flavoured Markdown (with all its fancy extensions) is desirable!
2019-12-21 r/277 feat(cheddar): Use syntax highlighting assets from batVincent Ambo1-1/+2
This uses Nix to inject the path to the syntax highlighting assets that ship with the bat source code into the cheddar build at compile time, where the Rust compiler then inserts it into the binary via macros. bat has a lot of custom syntax highlighting definitions that they collected from all over the place (including for languages like Nix!) and this makes them accessible to cheddar. Also if you're reading this, can you just take a moment to appreciate how incredible it is that Nix just lets us do something like this?!
2019-12-21 r/276 feat(tools/cheddar): Check in new syntax highlighting toolVincent Ambo1-0/+84
The first step with this tool will be to use it as a source-filter for cgit. The second step is to use it as the Markdown renderer by depending on one of the Markdown libraries, with integration for rendering code snippets directly.