Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
</head>
<body>
  
</body>
</html>
 
.woosb-qty-input {
     background: #dbcef5;
     color:#000;
}
.woosb-qty-input-plus.newclass{
     background: green;
     color:#fff;
}
.woosb-price .woosb-price-ori.newclass ins{
  color:red;
}
.woosb-qty-input-plus, .woosb-qty-input-minus {
    border: 2px solid #333;    padding: 10px;
}
 
function formatter(str, x=3, y=6){
  
  let s = str.split`\n`
  
  s.forEach((e,i)=>{
    if( /\d+\)/.test(e) ) s[i] = ' '.repeat(x)+e.trimLeft()
    else if ( !e.includes('*') ) s[i]=' '.repeat(y)+e.trimLeft()
  })
  
  return s.join`\n`
}
console.log(
    
  
  formatter(`* Список
      1) Элемент первый
      2) Элемент второй.
    3) Элемент третий.
Текст, расположенный под вторым элементом, чтобы ровненько. Вот так.
 4) Элемент четвертый
5) Элемент пятый
 6) Элемент шестой
  Текст, расположенный под вторым элементом, чтобы ровненько. Вот так.
         Текст, расположенный под вторым элементом, чтобы ровненько. Вот так.`)
  
  
  
)
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers