format text in javascript : how to Write a parser/method in javascript which would parse below

  

      digraph "com.a:test:jar:1.0" { 
         "com.a:test:jar:1.0" -> 
         "org.apache.httpcomponents:httpclient:jar:4.5.5:compile"; 
         "com.a:test:jar:1.0" -> "com.google.code.gson:gson:jar:2.8.2:compile"; 
         "com.a:test:jar:1.0" -> "info.picocli:picocli:jar:2.3.0:compile"; 
         "com.a:test:jar:1.0" -> "log4j:log4j:jar:1.2.17:compile"; 
         "com.a:test:jar:1.0" -> "org.xerial:sqlite-jdbc:jar:3.21.0:compile";
         "org.apache.httpcomponents:httpclient:jar:4.5.5:compile" -> 
         "org.apache.httpcomponents:httpcore:jar:4.4.9:compile" ; 
         "org.apache.httpcomponents:httpclient:jar:4.5.5:compile" -> "commons-logging:commons-logging:jar:1.2:compile" ; 
         "org.apache.httpcomponents:httpclient:jar:4.5.5:compile" -> "commons-codec:commons-codec:jar:1.10:compile" ; 
          }

into 

     digraph "com.a:test:jar:1.0" { 
             "com.a:test:jar:1.0" -> 
             "org.apache.httpcomponents:httpclient:jar:4.5.5:compile"; 
             "com.a:test:jar:1.0" -> "com.google.code.gson:gson:jar:2.8.2:compile"; 
             "com.a:test:jar:1.0" -> "info.picocli:picocli:jar:2.3.0:compile"; 
             "com.a:test:jar:1.0" -> "log4j:log4j:jar:1.2.17:compile"; 
             "com.a:test:jar:1.0" -> "org.xerial:sqlite-jdbc:jar:3.21.0:compile";
              }

i.e anything appearing next to diagraph "com.a:test:jar:1.0" if it appears before (LHS) `->` have it else omit it.

Note: there can be multiple blocks of digraph.
