Skip to content

Commit

Permalink
add ansi-format classes
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-stasse committed Mar 28, 2024
1 parent 6d7b547 commit 06907fe
Showing 1 changed file with 34 additions and 15 deletions.
49 changes: 34 additions & 15 deletions packages/module/src/ansi_up/ansi_up.ts
Original file line number Diff line number Diff line change
Expand Up @@ -686,25 +686,26 @@ export default class AnsiUp {
const fg = fragment.fg;
const bg = fragment.bg;

// Note on bold: https://stackoverflow.com/questions/6737005/what-are-some-advantages-to-using-span-style-font-weightbold-rather-than-b?rq=1
if (fragment.bold) {
styles.push(this._boldStyle);
}
if (!this._use_classes) {
// USE INLINE STYLES

if (fragment.faint) {
styles.push(this._faintStyle);
}
// Note on bold: https://stackoverflow.com/questions/6737005/what-are-some-advantages-to-using-span-style-font-weightbold-rather-than-b?rq=1
if (fragment.bold) {
styles.push(this._boldStyle);
}

if (fragment.italic) {
styles.push(this._italicStyle);
}
if (fragment.faint) {
styles.push(this._faintStyle);
}

if (fragment.underline) {
styles.push(this._underlineStyle);
}
if (fragment.italic) {
styles.push(this._italicStyle);
}

if (fragment.underline) {
styles.push(this._underlineStyle);
}

if (!this._use_classes) {
// USE INLINE STYLES
if (fg) {
styles.push(`color:rgb(${fg.rgb.join(',')})`);
}
Expand All @@ -713,6 +714,24 @@ export default class AnsiUp {
}
} else {
// USE CLASSES

// Note on bold: https://stackoverflow.com/questions/6737005/what-are-some-advantages-to-using-span-style-font-weightbold-rather-than-b?rq=1
if (fragment.bold) {
classes.push("ansi-bold");
}

if (fragment.faint) {
classes.push("ansi-faint");
}

if (fragment.italic) {
classes.push("ansi-italic");
}

if (fragment.underline) {
classes.push("ansi-underline");
}

if (fg) {
if (fg.class_name !== 'truecolor') {
classes.push(`${fg.class_name}-fg`);
Expand Down

0 comments on commit 06907fe

Please sign in to comment.