Code Style Sheets: CSS for Code
Abstract
Program text is rendered using impoverished typographic styles. Beyond choice of fonts and syntax-highlighting colors, code editors and related tools utilize very few text decorations. These limited styles are, furthermore, applied in monolithic fashion, regardless of the programs and tasks at hand.
We present the notion of code style sheets for styling program text. Motivated by analogy to cascading style sheets (CSS) for styling HTML documents, code style sheets provide mechanisms for defining rules to select elements from an abstract syntax tree (AST) in order to style their corresponding visual representation. Technically, our selector language generalizes essential constructs from CSS to a programming-language setting with algebraic data types (such as ASTs). Practically, code style sheets allow ASTs to be styled granularly, based on semantic information-such as the structure of abstract syntax, static type information, and corresponding run-time values-as well as design choices on the part of authors and readers of a program. Because programs are heavily nested in structure, a key aspect of our design is a layout algorithm that renders nested, multiline text blocks more compactly than in existing box-based layout systems such as HTML.
In this paper, we design and implement a code style sheets system for a subset of Haskell, using it to illustrate several code presentation and visualization tasks. These examples demonstrate that code style sheets provide a uniform framework for rendering programs in multivarious ways, which could be employed in future designs for text-based as well as structure editors.
Ask Lune
Know this paper in minutes, not an afternoon.
Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.
2 top-tier papers have cited it since. Know what they found before your reviewers do.
Lune can draw on
the full paper · the top-tier papers that cite it · related work
Free to start. No credit card required.
Lineage
- Filling typed holes with live GUIs cites Projection Boxes: On-the-fly Reconfigurable Visualization for Live Programming
- Filling typed holes with live GUIs cites Adding interactive visual syntax to textual code
- Ragged Blocks: Rendering Structured Text with Style cites Filling typed holes with live GUIs
- Ragged Blocks: Rendering Structured Text with Style cites Structured Editing for All: Deriving Usable Structured Editors from Grammars
- Ragged Blocks: Rendering Structured Text with Style cites Adding interactive visual syntax to textual code
- Ragged Blocks: Rendering Structured Text with Style cites Penrose: from mathematical notation to beautiful diagrams
Cited by top-tier papers2
Builds on8
- Penrose: from mathematical notation to beautiful diagramsKatherine Ye, Wode Ni, Max Krieger, Dor Ma'ayan et al.SIGGRAPH 2020 · 53 citations
- Projection Boxes: On-the-fly Reconfigurable Visualization for Live ProgrammingSorin LernerCHI 2020 · 52 citations
- Filling typed holes with live GUIsCyrus Omar, David Moon, Andrew Blinn, Ian Voysey et al.PLDI 2021 · 35 citations
- Adding interactive visual syntax to textual codeLeif Andersen, Michael Ballantyne, Matthias FelleisenOOPSLA 2020 · 28 citations
- Structured Editing for All: Deriving Usable Structured Editors from GrammarsTom Beckmann, Patrick Rein, Stefan Ramson, Joana Bergsiek et al.CHI 2023 · 21 citations
Related papers
- A Pretty Expressive PrinterSorawee Porncharoenwase, Justin Pombrio, Emina TorlakOOPSLA 2023
- Taking ASCII Drawings Seriously: How Programmers Diagram CodeDevamardeep Hayatpur, Brian Hempel, Kathy Chen, William Duan et al.CHI 2024 · 7 citations
- Stylette: Styling the Web with Natural LanguageTae Soo Kim, DaEun Choi, Yoonseo Choi, Juho KimCHI 2022 · 71 citations
- Digging for fold: synthesis-aided API discovery for HaskellMichael B. James, Zheng Guo, Ziteng Wang, Shivani Doshi et al.OOPSLA 2020 · 19 citations
- AST-Trans: Code Summarization with Efficient Tree-Structured AttentionZe Tang, Xiaoyu Shen, Chuanyi Li, Jidong Ge et al.ICSE 2022 · 57 citations
