Skip to content

Commit

Permalink
modify render process
Browse files Browse the repository at this point in the history
  • Loading branch information
SnowFireWolf committed Jul 13, 2024
1 parent a878ff0 commit e79f892
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
4 changes: 1 addition & 3 deletions src/parser/JSONToHTML.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,15 @@ import textToHTML from "./textToHTML";



// json convert to html
/**
* Convert JSON to HTML.
*
* @param sourceJson
* @param sourceJson
*/
export default function parseJSONToHTML(
sourceJson: motdJsonType,
) {
let htmlElement = "";
// let colorHex = "";
let colorStyle = "";
let fontStyle = "";

Expand Down
9 changes: 2 additions & 7 deletions src/parser/autoCleanToText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,14 @@ import { cleanCodes } from "../utils";



// make sure JSON data is JSON object and then convert.
export function JSONRender(json: object | motdJsonType) {
return JSONToCleanedText(JSON.parse(JSON.stringify(json)));
}

/**
* auto check data type then convert to html.
*/
export function autoCleanToText(motd: string | object | motdJsonType): string {
export function autoCleanToText(motd: string | object): string {
// type check
if (typeof motd === "object") {
// console.log('process mode: Object mode');
return JSONRender(motd);
return JSONToCleanedText(motd as motdJsonType);
} else if (typeof motd === "string") {
// console.log('process mode: String mode');
return cleanCodes(motd);
Expand Down
6 changes: 3 additions & 3 deletions src/parser/autoToHTML.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import {


// make sure JSON data is JSON object and then convert.
export function JSONRender(json: object | motdJsonType) {
return JSONToHTML(JSON.parse(JSON.stringify(json)));
export function JSONRender(json: object) {
return JSONToHTML(json as motdJsonType);
}

/**
* auto check data type then convert to html.
*/
export function autoToHTML(motd: string | object | motdJsonType): string {
export function autoToHTML(motd: string | object): string {
// type check
if (typeof motd === "object") {
// console.log('process mode: Object mode');
Expand Down

0 comments on commit e79f892

Please sign in to comment.