Skip to content

Commit 0eaa00c

Browse files
iftenneyLIT team
authored and
LIT team
committed
Support markdown in component descriptions.
PiperOrigin-RevId: 479065711
1 parent 5f20e0c commit 0eaa00c

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

lit_nlp/client/elements/interpreter_controls.css

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
.description {
22
font-size: 8pt;
33
color: rgb(60, 64, 67);
4-
padding-top: 10px;
4+
}
5+
6+
/* Reduce excess whitespace after markdown-formatted descriptions */
7+
.description > p:last-child {
8+
margin-block-end: 0.25em;
59
}
610

711
.header {

lit_nlp/client/elements/interpreter_controls.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {observable} from 'mobx';
2626
import {ReactiveElement} from '../lib/elements';
2727
import {BooleanLitType, CategoryLabel, SingleFieldMatcher, LitType, LitTypeWithVocab, MultiFieldMatcher, Scalar, SparseMultilabel, Tokens} from '../lib/lit_types';
2828
import {styles as sharedStyles} from '../lib/shared_styles.css';
29+
import {getTemplateStringFromMarkdown} from '../lib/utils';
2930
import {Spec} from '../lib/types';
3031

3132
import {styles} from './interpreter_controls.css';
@@ -73,10 +74,12 @@ export class InterpreterControls extends ReactiveElement {
7374
const expandable =
7475
Object.keys(this.spec).length > 0 || this.description.length > 0;
7576

77+
const descriptionHTML = getTemplateStringFromMarkdown(this.description);
78+
7679
// clang-format off
7780
const content = html`
7881
<div class="content">
79-
<div class="description">${this.description}</div>
82+
<div class="description">${descriptionHTML}</div>
8083
${this.renderControls()}
8184
<div class="buttons-holder">
8285
<button class="filled-button" @click=${apply}

lit_nlp/components/ablation_flip.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class AblationFlip(lit_components.Generator):
7272
prediction flip.
7373
7474
The number of model predictions made by this generator is upper-bounded by
75-
<number of tokens> + 2**MAX_ABLATABLE_TOKENS. Since MAX_ABLATABLE_TOKENS is a
75+
number of tokens + 2^MAX_ABLATABLE_TOKENS. Since MAX_ABLATABLE_TOKENS is a
7676
constant, effectively this generator makes O(n) model predictions, where n is
7777
the total number of tokens across all input fields.
7878
"""

0 commit comments

Comments
 (0)