Commit e979ce98 authored by Zéfling's avatar Zéfling 🎨
Browse files

refacto

parent 6f2e3679
......@@ -2,18 +2,20 @@
## V0.2.0 (2022-05-30)
- Add option `wrapAttrNumber`
- Add options `prettier` on `attrPosition`
- Add options `maxLength` for text and `attrPosition` (`inline *`)
- add option `wrapAttrNumber`
- add options `prettier` on `attrPosition`
- add options `maxLength` for text and `attrPosition` (`inline *`)
- fix `inline` render
- update demo
## V0.1.0 (2022-02-10)
- With Ivy partial compilation mode
- with Ivy partial compilation mode
## V0.0.6 (2020-10-21)
- Add option `optionalEndTagsFix`
- Add options `inline` and `autoclose` on json node
- add option `optionalEndTagsFix`
- add options `inline` and `autoclose` on json node
- fix minor bugs
## V0.0.5 (2020-10-18)
......@@ -33,7 +35,7 @@
## V0.0.2 (2020-10-14)
- Fix attributs render
- fix attributs render
## V0.0.1 (2020-10-14)
......
{
"name": "json2html-lib",
"version": "0.1.0",
"version": "0.2.0",
"license": "MIT",
"repository": {
"type": "git",
......
......@@ -338,9 +338,9 @@ export class Json2html {
if (!inline && this.options.maxLength) {
const list = string.split('\n');
for (const line of list) {
let lineBuild = '';
if ((space + line).length > this.options.maxLength) {
const frags = line.split(' ');
let lineBuild = '';
for (const frag of frags) {
if ((space + lineBuild + (lineBuild ? ' ' : '') + frag).length < this.options.maxLength) {
lineBuild += (lineBuild ? ' ' : '') + frag;
......@@ -349,10 +349,8 @@ export class Json2html {
lineBuild = frag;
}
}
formatedText += (formatedText ? '\n' + space : '') + lineBuild;
} else {
formatedText += (formatedText ? '\n' + space : '') + line;
}
formatedText += (formatedText ? '\n' + space : '') + (lineBuild || line);
}
}
return formatedText || string;
......
......@@ -52,7 +52,7 @@
(change)="spaceBase = $event.target.value; generated()"
/>
</label>
<label *ngIf="indent && formatting === 'multiline'">
<label *ngIf="formatting === 'multiline'">
<span>attrPosition</span>
<select [value]="attrPosition" (change)="attrPosition = $event.target.value; generated()">
<option value="inline">inline: no alignment</option>
......@@ -61,10 +61,12 @@
<option value="inline alignFirstAttr">
inline alignFirstAttr: wrap alignment with the first attribute
</option>
<option value="space">space: alignment with higher level</option>
<option value="alignTag">alignTag: alignment with the tag</option>
<option value="alignFirstAttr">alignFirstAttr (default): alignment with the first attribute</option>
<option value="prettier">prettier: like Prettier formatter</option>
<option *ngIf="indent" value="space">space: alignment with higher level</option>
<option *ngIf="indent" value="alignTag">alignTag: alignment with the tag</option>
<option *ngIf="indent" value="alignFirstAttr">
alignFirstAttr (default): alignment with the first attribute
</option>
<option *ngIf="indent" value="prettier">prettier: like Prettier formatter</option>
</select>
</label>
<label *ngIf="indent && formatting === 'multiline'">
......@@ -76,7 +78,7 @@
(change)="wrapAttrNumber = $event.target.value; generated()"
/>
</label>
<label *ngIf="indent && formatting === 'multiline'">
<label *ngIf="formatting === 'multiline'">
<span>maxLength (0 = no wrap)</span>
<input
[value]="maxLength"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment