Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

25 subir cobertura de código para 45 #27

Merged
merged 12 commits into from
Nov 8, 2023
4 changes: 4 additions & 0 deletions .ambiente
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
chaveSecreta=MinhaChave
session=Falso
variavelTrue=verdadeiro
variavelFalse=falso
58 changes: 29 additions & 29 deletions infraestrutura/preprocessadores/foles.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
import { XMLParser, XMLBuilder } from 'fast-xml-parser';
import { FolEs } from '@designliquido/foles';
import { XMLBuilder, XMLParser } from 'fast-xml-parser';

export class PreprocessadorFolEs {
leitorLmht: XMLParser;
construtorLmht: XMLBuilder;
foles: FolEs;
leitorLmht: XMLParser;
construtorLmht: XMLBuilder;
foles: FolEs;

constructor() {
this.leitorLmht = new XMLParser({
ignoreAttributes : false
});
this.construtorLmht = new XMLBuilder({
ignoreAttributes : false
});
this.foles = new FolEs(false);
}

processar(conteudoLmht: string): string {
const objetoVisao = this.leitorLmht.parse(conteudoLmht);
constructor() {
this.leitorLmht = new XMLParser({
ignoreAttributes: false
});
this.construtorLmht = new XMLBuilder({
ignoreAttributes: false
});
this.foles = new FolEs(false);
}

const cabeca = objetoVisao.lmht?.cabeca || objetoVisao.lmht?.cabeça;
if (cabeca) {
// Procurar por estrutura de estilo.
const estilo = cabeca.estilo;
if (estilo) {
const estiloConvertido = this.foles.converterTextoParaCss(estilo);
cabeca.style = estiloConvertido;
delete cabeca.estilo;
}
}
processar(conteudoLmht: string): string {
const objetoVisao = this.leitorLmht.parse(conteudoLmht);

const xmlContent = this.construtorLmht.build(objetoVisao);
return xmlContent;
const cabeca = objetoVisao.lmht?.cabeca || objetoVisao.lmht?.cabeça;
if (cabeca) {
// Procurar por estrutura de estilo.
const estilo = cabeca.estilo;
if (estilo) {
const estiloConvertido = this.foles.converterTextoParaCss(estilo);
cabeca.style = estiloConvertido;
delete cabeca.estilo;
}
}
}

const xmlContent = this.construtorLmht.build(objetoVisao);
return xmlContent;
}
}
Loading
Loading