[Question]
  [
Lots of people on this site use [esoteric languages](https://esolangs.org/wiki/Main_Page), and since these languages are unusual and hard to understand, they will frequently write an explanation in a certain format. For example, if the code was
```
abcdefghijklmnop
```
And this languages uses `#` for comments, they would write an explanation like this:
```
a                #Explanation of what 'a' does
 bc              #Bc
   d             #d
    e            #Explanation of e
     fgh         #foobar
        ij       #hello world
          k      #etc.
           l     #so on
            mn   #and
              op #so forth
```
I frequently do this too, but every time I do this, I feel like creating the layout of text is really obnoxious and time-consuming. So I want you to create a "Esolang-Comment-Template-Generator" for me. For example, if we ignore the comments, the previous code has this template:
```
a                #
 bc              #
   d             #
    e            #
     fgh         #
        ij       #
          k      #
           l     #
            mn   #
              op #
```
# The Challenge:
You must write a program or function that takes two strings as input, and outputs this "Esolang-Comment-Template". The first input will be the code, but with bars (`|`) inserted where the newlines go. The second input is what we will use for comments. So our last example would have this for input:
```
"a|bc|d|e|fgh|ij|k|l|mn|op", "#"
```
Unfortunately this excludes bars from being part of the code input, but that's OK. You can assume that the comment input will be a single character. For simplicity's sake, the comment char will not be a bar. The code input will only contain printable ASCII, and it will not contain any newlines. 
Hopefully you can infer what to do from the testcases, but I'll try to clarify some things. 
You must split the code input up into "code-sections" on every bar. Then, each section of code is output on its own line and left-padded with the length of all the previous code (not including the bars). Then, each line is right-padded with enough spaces so that the last two characters on every line are "One additional space" + "The comment character".
One trailing newline is allowed. 
Here is another example. For the input
```
"Hello|World", "/"
```
The first *section* of code is "Hello" and the second is "World". So it should give the output:
```
Hello      /
     World /
```
Here are some more samples:
```
Input:
"a|b|c|d|e|f|g", ","
Output:
a       ,
 b      ,
  c     ,
   d    ,
    e   ,
     f  ,
      g ,
Input:
"abcdefg", ":"
Output:
abcdefg :
Input:
"4|8|15|16|23|42", "%"
Output:
4          %
 8         %
  15       %
    16     %
      23   %
        42 %
Input:
"E|ac|h s|ecti|on is| one c|haracte|r longer| than the| last!", "!"
Output:
E                                                   !
 ac                                                 !
   h s                                              !
      ecti                                          !
          on is                                     !
                one c                               !
                     haracte                        !
                            r longer                !
                                     than the       !
                                              last! !
Input:
"This|Code|has||empty||sections", "@"
Output:
This                     @
    Code                 @
        has              @
                         @
           empty         @
                         @
                sections @
```
# Rules:
You may take these inputs and outputs in any reasonable format. For example, reading/writing a file, STDIN/STOUT, function arguments/return value, etc. As usual, this is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so try to make your code as short as possible and you win if you can get the shortest solution in your language! I will also select the shortest solution as the overall winner. [Standard loopholes](http://meta.codegolf.stackexchange.com/questions/1061/loopholes-that-are-forbidden-by-default) are banned.
  
[Answer]
## [Retina](http://github.com/mbuettner/retina), ~~35~~ 34 bytes
Byte count assumes ISO 8859-1 encoding.
```
\|
¬∑$'¬∂$`¬±
T0-2`¬∑¬±|p`___ `.+¬±.|¬∑.+
```
The two input strings are separated by a space (which is unambiguous since we know that the comment delimiter is always a single character).
[Try it online!](http://retina.tryitonline.net/#code=XHwKwrckJ8K2JGDCsQpUMC0yYMK3wrF8cGBfX18gYC4rwrEufMK3Lis&input=RXxhY3xoIHN8ZWN0aXxvbiBpc3wgb25lIGN8aGFyYWN0ZXxyIGxvbmdlcnwgdGhhbiB0aGV8IGxhc3QhICE)
[Answer]
# Java 11, ~~189~~ ~~159~~ 136 bytes
```
s->c->{int p=0;for(var a:s.split("\\|"))System.out.println(" ".repeat(p)+a+" ".repeat(s.replace("|","").length()-(p+=a.length())+1)+c);}
```
-30 bytes converting Java 7 to Java 10 and optimizing the loops.  
-23 bytes converting Java 10 to Java 11, so `String#repeat` builtin can be used.
[Try it online.](https://tio.run/##bVLBbhshEL37KyZbVQHtmtZJWlVxbFWyWuXSUyr1kPQwZtldHBYQYEtWxt/uYnvVxlUuCHhv3vDmscINjlf1814ajBF@oLYvI4CYMGkJq4yKddJGNGsrk3ZWfB82dw8paNtWb3EWzsZ1r8LdosOAMqkwn0MDs30cz@V4/qJtAj/7OG1cYBsMgLdRRG90YsXTExWcP2xjUr1w6yR87pKMZQUUIiivMDHPSyxfneNhY1AqVlBRFQUXRtk2dYyPmS9n@PfIywkvJZ/u9tNRNunXS5NNDl43TtfQZ//s5OzxNyA/zAIgqZifhrSUVJOipu1Ir@iZDPWWnC@qy3eXfPqKeq@McfTLBVNn8MM5mHVoEKI2w9V/8FLWqjkAt@fADX2hySeafKara7q5yoT354RvhJI6iKRyDOQs6EjgrIJ8e8qBAhhnWxUIUoc2L4ogB58ustrFudrPLpcvXK1ycSRSvU9boqiOEcfM/3ri70b//stxhsfy0wwhVjK3BjkMEhqB3psti1yglMonJoem8Ebmg/5u/wc)
**Explanation:**
```
s->c->{                     // Method with String & char parameters and no return-type
  int p=0;                  //  Position-integer, starting at 0
  for(var a:s.split("\\|")) //  Loop over the parts split by "|":
    System.out.println(     //   Print with trailing newline:
      " ".repeat(p)         //    `p` amount of spaces
      +a                    //    plus the current part
      " ".repeat(s.replace("|","").length()-(p+=a.length())+1)
                            //    plus the correct trailing amount of spaces
                            //    (and add the length of the current part to `p` at the
                            //    same time)
      +c);}                 //    plus the current comment character
```
[Answer]
# Pyth - ~~28~~ ~~27~~ ~~24~~ 23 bytes
~~Might be able to golf a little off.~~ A lot off, apparently!
```
jt+R+;zC.t.u+*lNdYcQ\|k
```
[Try it online here](http://pyth.herokuapp.com/?code=jt%2BR%2B%3BzC.t.u%2B%2alNdYcQ%5C%7Ck&input=%22a%7Cbc%7Cd%7Ce%7Cfgh%7Cij%7Ck%7Cl%7Cmn%7Cop%22%0A%23&debug=0).
[Answer]
## Pyke, ~~31~~ ~~28~~ 24 bytes
```
\|cDslF2l-hd*Q+Zi:il?+ZK
```
[Try it here!](http://pyke.catbus.co.uk/?code=%5C%7CcDslF2l-hd%2aQ%2BZi%3Ail%3F%2BZK&input=%23%0Aa%7Cbc%7Cd%7Ce%7Cfgh%7Cij%7Ck%7Cl%7Cmn%7Cop)
[Answer]
## JavaScript (ES6), 92 bytes
```
f=
(s,c)=>s.split`|`.map((_,i,a)=>a.map((e,j)=>i-j?e.replace(/./g,` `):e).join``+` `+c).join`
`
;
```
```
<div oninput=o.textContent=f(s.value,c.value)><input id=s placeholder=Code><input id=c size=1 maxlength=1 value=#><pre id=o>
```
[Answer]
# GNU sed (85 + 1 for -r) 86
```
:s;h;:;s,\|( *)[^ \|](.),|\1 \2,;t;s,\|,,g
p;g;:l;s,^( *)[^ \|],\1 ,;tl;s,\|,,;/\S/bs
```
The inputs are strings separated by a space. 
**Tests:**  
input.txt:
```
a|b|c|d|e|f|g ,
abcdefg :
4|8|15|16|23|42 %
E|ac|h s|ecti|on is| one c|haracte|r longer| than the| last! !
This|Code|has||empty||sections @
```
Output:
```
$ cat input.txt | sed -rf template
a       ,
 b      ,
  c     ,
   d    ,
    e   ,
     f  ,
      g ,
abcdefg :
4          %
 8         %
  15       %
    16     %
      23   %
        42 %
E                                                   !
 ac                                                 !
   h s                                              !
      ecti                                          !
          on is                                     !
                one c                               !
                     haracte                        !
                            r longer                !
                                     than the       !
                                              last! !
This                     @
    Code                 @
        has              @
                         @
           empty         @
                         @
                sections @
```
[Answer]
# Python 2, ~~107~~ ~~105~~ ~~102~~ 99 bytes
Tested with all test cases above
**EDIT** Golfed off 2 bytes by changing d=a.split("|");i=0 to d,i=a.split("|"),0
Not sure how I missed that one. Thanks @Oliver Ni
Another 3 bytes gone. Thanks again.
Suggestion from @Jonathan actually saves 3 bytes and takes it down to the magic 99. Thanks.
```
def c(a,b):
 d,i=a.split("|"),0
 for e in d:j=i+len(e);print" "*i+e+" "*(len("".join(d))-j+1)+b;i=j
```
[Answer]
# Haskell, ~~139~~ 135 bytes
```
s#p=j$foldl g("",0)s where g(a,n)c|c=='|'=(j(a,n)++"\n"++q n,n)|1>0=(a++[c],n+1);q m=' '<$[1..m];j(a,n)=a++q(sum[1|c<-s,c/='|']-n+1)++p
```
Saved 4 bytes by inlining a definition.
**Ungolfed:**
```
template :: String -> String -> String
template code comment = format $ foldl g ("", 0) code
    where g (acc, n) c
            | c == '|' = (format (acc, n) ++ "\n" ++ spaces n, n)
            | otherwise = (acc ++ [c], n+1)
          l = length $ filter (/= '|') code
          spaces n = replicate n ' '
          format (acc, n) = acc ++ spaces (l-n+1) ++ comment
```
[Answer]
# Groovy, ~~120~~ ~~113~~ 111 Bytes
```
def m(s,c){s.split(/\|/).inject(0,{e,t->println((' '*e+t).padRight(s.replace('|','').size()+1)+c);e+t.size()})}
```
**ungolfed\***
```
def m(s,c){
  s.split(/\|/).inject(0, { e, t ->
    println((' '*e+t).padRight(s.replace('|','').size())+' '+c)
    e+t.size()
  })
}
```
# (First Draft with 120 Bytes)
```
def m(s,c){def l=0;s.split(/\|/).collect{l+=it.size();it.padLeft(l).padRight(s.replace('|','').size())+' '+c}.join('\n')}
```
**ungolfed\***
```
def m(s,c){
  def l=0 // minimized version needs a semicolon here
  s.split(/\|/).collect{
    l+=it.size() // minimized version needs a semicolon here
    it.padLeft(l).padRight(s.replace('|','').size())+' '+c
  }.join('\n')
}
```
**Tests**
```
%> m('a|bc|d|e|fgh|ij|k|l|mn|op', '#')
a                #
 bc              #
   d             #
    e            #
     fgh         #
        ij       #
          k      #
           l     #
            mn   #
              op #
%> m('Hello|World', '/')
Hello      /
     World /
%> m('a|b|c|d|e|f|g', ',')
a       ,
 b      ,
  c     ,
   d    ,
    e   ,
     f  ,
      g ,
%> m('abcdefg', ':')
abcdefg :
%> m('4|8|15|16|23|42', '%')
4          %
 8         %
  15       %
    16     %
      23   %
        42 %
%> m('E|ac|h s|ecti|on is| one c|haracte|r longer| than the| last!', '!')
E                                                   !
 ac                                                 !
   h s                                              !
      ecti                                          !
          on is                                     !
                one c                               !
                     haracte                        !
                            r longer                !
                                     than the       !
                                              last! !
%> m('This|Code|has||empty||sections', '@')
This                     @
    Code                 @
        has              @
                         @
           empty         @
                         @
                sections @
```
[Answer]
# Python 2, ~~125 124~~ 132 bytes
-1 byte thanks to @TuukkaX (missed golfing the space from `i, v`)
```
def g(s,c):x=s.split('|');print((' '+c+'\n').join(' '*len(''.join(x[:i]))+v+' '*len(''.join(x[i+1:]))for i,v in enumerate(x))+' '+c)
```
All test cases on [**ideone**](http://ideone.com/MWZ0Lx)
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~29~~ ~~38~~ ~~31~~ 29 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
'|‚Äû«ù í:'«ù¬°' í–ºŒµD¬Æ>√∫sg¬Æ+¬©s}.BŒµ√∞¬≤J,
```
Can definitely be golfed, but at least its working now..  
+9 bytes because `¬°` (split) removes empty items automatically, so I had to add `'|‚Äû«ù í:'«ù¬°' í–º`..  
[Try it online.](https://tio.run/##AUYAuf8wNWFiMWX//yd84oCex53Kkjonx53CoSfKktC8zrVEwq4@w7pzZ8KuK8Kpc30uQs61w7DCskos//9hYmN8ZHxlfHxmZwoh)
**Explanation:**
```
'|¬∂:           # Take the first input, and replace every "|" with "¬∂"
               #  i.e. "abc|d|e||fg" ‚Üí "abc¬∂d¬∂e¬∂¬∂fg" (¬∂ are new-lines in 05AB1E)
    .B         # Box all the items (appending trailing whitespace to make it a rectangle)
               #  i.e. "abc¬∂d¬∂e¬∂¬∂fg" ‚Üí ['abc','d  ','e  ','   ','fg ']
      Œµ√∞√ú}     # Remove all trailing spaces from each item
               #  i.e. ['abc','d  ','e  ','   ','fg '] ‚Üí ['abc','d,'e','','fg']
               #  NOTE: `'|¬°` would have resulted in ['abc','d','e','fd'], hence the use of
               #        Box which implicitly splits on new-lines to keep empty items
Œµ              # For-each:
 D             #  Duplicate the current item
  ¬Æ>√∫          #  Prepend global_variable + 1 amount of spaces
               #  (+1 because the global_variable is -1 by default)
               #   i.e. "e" and 3+1 ‚Üí "    e"
 sg            #  Swap so the duplicated item is at the top, and take its length
   ¬Æ+          #  Sum it with the global_variable
               #   i.e. "e" (‚Üí 1) and 4 ‚Üí 5
     ¬©         #  And store it as new global_variable
      s        #  Then swap so the space appended item is at the end again
       }       # And end the for-each loop
.B             # Box all the items (appending the appropriate amount of spaces)
               #  i.e. ['abc','   d','    e','     ','     fg']
               #   ‚Üí ['abc    ','   d   ','    e  ','       ','     fg']
Œµ              # For-each again:
 √∞             #  A space character
  I            #  The second input-character
   J           #  Join both together with the current item
    ,          #  And print the current row with trailing new-line
```
[Answer]
# [Japt](https://github.com/ETHproductions/japt) [`-R`](https://codegolf.meta.stackexchange.com/a/14339/), 17 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
There's a byte to be saved here, *at least*, I just can't quite see it.
```
q| √ã√πT¬±D√ä√É√∫ √ã+ViS
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&flags=LVI&code=cXwgy/lUsUTKw/ogyytWaVM&input=ImF8YmN8ZHxlfGZnaHxpanxrfGx8bW58b3AiCiIjIg)
```
q| √ã√πT¬±D√ä√É√∫ √ã+ViS     :Implicit input of strings U=programme & V=character
q|                    :Split U on |
   √ã                  :Map each D
    √π                 :  Left pad with spaces to length
     T¬±               :    Increment T (initially 0) by
       D√ä             :    Length of D
         √É            :End map
          √∫           :Right pad each with spaces to length of longest
            √ã         :Map
             +        :  Append
              Vi      :    V prepended with
                S     :      Space
                      :Implicit output joined with newlines
```
[Answer]
## PowerShell v2+, ~~103~~ 99 bytes
```
param($a,$b)$a-split'\|'|%{" "*$l+$_+" "*(($a-replace'\|').length+1-$_.length-$l)+$b;$l+=$_.Length}
```
Takes input as two strings, `-split`s the first on literal pipe (since split uses regex syntax), and feeds the elements into a loop `|%{...}`.
Each iteration, we construct a string as being a number of spaces defined by `$l` concatenated with the current element. For the first loop, `$l` initializes to `$null`, which gets evaluate here as `0`.
That string is further concatenated with another number of spaces (defined by how long `$a` would be if we `-replace`d every pipe with nothing, plus `1` for the additional padding between code and comments, minus the `.length` of the current element, minus `$l` which is how many spaces we padded left on this iteration), concatenated with our comment character `$b`. That's left on the pipeline.
We then update `$l` for the next iteration.
The resultant strings are all left on the pipeline, and output via implicit `Write-Output` happens at program execution, with a newline between them by default.
### Examples
```
PS C:\Tools\Scripts\golfing> .\esolang-comment-template-generator.ps1 "This|Code|has||empty||sections" "@"
This                     @
    Code                 @
        has              @
                         @
           empty         @
                         @
                sections @
PS C:\Tools\Scripts\golfing> .\esolang-comment-template-generator.ps1 "a|bc|def|ghi|h" "|"
a          |
 bc        |
   def     |
      ghi  |
         h |
```
[Answer]
# Vim, ~~39~~ 38 keystrokes
-1 byte thanks to DJMcMayhem
Expects as input a buffer (e.g. a file) whose first character is the comment delimiter, followed by the code, e.g. `#foo|bar|baz`.
```
"cxqaf|m`Yp<Ctrl+o>v$r jv0r x@aq@a$p<Ctrl+v>gg$C <Ctrl+r>c<Esc>
```
## Explanation
("`_`" denotes a literal space.)
```
"cx          " Delete the first character (the comment delimiter) and store in register 'c'
qa           " Start recording macro 'a'
f|m`         " Advance to the first '|' on the line and set mark
Yp<Ctrl+o>   " Duplicate this line and return to mark
v$r_         " Replace everything after the cursor on this line (inclusive) with spaces
jv0r_x       " Go down a line and replace everything before the cursor on this line (inclusive) with
             "   spaces, then delete one space
@a           " Call macro recursively
q@a          " Stop recording and immediately call the macro
$p           " Paste the deleted space at the end of the last line
<Ctrl+v>gg$       " Highlight the column where the comment delimiters will go and all trailing spaces
C_<Ctrl+r>c<Esc>  " Replace the highlighted text on each line with a space and the contents of
                  "   register 'c' (the comment delimiter)
```
[Answer]
# [Floroid](https://github.com/TuukkaX/Floroid) - 94 bytes
```
Ah(a,b):c=a.fn("|");z(" "+b+"\n".y(' '*Z("".y(c[:j]))+l+" "*Z("".y(c[j+1:]))Kj,lIai(c))+' '+b)
```
Uses an approach similar to @[JonathanAllan](https://codegolf.stackexchange.com/users/53748/jonathan-allan)s' Python solution.
## Testcases
```
Call: h("a|bc|d|e|fgh|ij|k|l|mn|op", "#")
Output: 
a                #
 bc              #
   d             #
    e            #
     fgh         #
        ij       #
          k      #
           l     #
            mn   #
              op #
```
[Answer]
# C# 176 167 154 bytes
```
string f(string s,char x){var c=s.Split('|');var d="";int i=0;foreach(var b in c)d+=b.PadLeft(i+=b.Length).PadRight(s.Length+2-c.Length)+x+"\n";return d;}
```
UnGolfed
```
string f(string s, char x)
{
    var c = s.Split('|');
    var d = "";
    int i = 0;
    foreach (var b in c)
        d += b.PadLeft(i += b.Length).PadRight(s.Length + 2 - c.Length) + x + "\n";
    return d;
}
```
A LINQ solution would have been 146 but needed `using System.Linq;` bringing it back up to 164:
```
string f(string s,char x){var c=s.Split('|');int i=0;return c.Aggregate("",(g,b)=>g+b.PadLeft(i+=b.Length).PadRight(s.Length+2-c.Length)+x+"\n");}
```
Old solutions:
167 bytes:
```
string f(string s,char x){var c=s.Split('|');var d="";int i=0;foreach(var b in c){d+=b.PadLeft(i+b.Length).PadRight(s.Length+2-c.Length)+x+"\n";i+=b.Length;}return d;}
```
176 bytes using string interpolation
```
string f(string s,char x){var c=s.Split('|');var d="";int i=0;foreach(var b in c){d+=string.Format($"{{1,{i}}}{{0,-{s.Length+2-c.Length-i}}}{x}\n",b,"");i+=b.Length;}return d;}
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 10 bytes
```
·π£‚Äù|‚Å∂·πÅ;…ó\pG
```
[Try it online!](https://tio.run/##AT8AwP9qZWxsef//4bmj4oCdfOKBtuG5gTvJl1xwR////1RoaXN8Q29kZXxoYXN8fGVtcHR5fHxzZWN0aW9uc/8nQCc "Jelly ‚Äì Try It Online")
[Answer]
# [AWK](https://www.gnu.org/software/gawk/manual/gawk.html), 107 104 103 bytes
```
w=2-(n=split($1,p,"|"))+gsub(t=".",FS,$1){for(;s++<n;gsub(t,FS,b))y=y substr((b=b p[s])$1,1,w)$2RS}$0=y
```
[Try it online!](https://tio.run/##JczRCsIgFIDhVxnihYdZ5G6XEAQ9QOsuupi1mlQqO4ZIp2e3RZc/H/x9upeSdLMQTmN42Ci4kkEyYgD1DV9GRM2WTO46yRW8r34SLdb12rV//IEByDpXc2OchDDaVOGIJ5hPSibgzb778JXOpRxGi7T1l4HGHomGZ4iZCIdztN5htfkC "AWK ‚Äì Try It Online")
*Thanks to Pedro Maimere for helping shave off more 3 chars*
One interesting thing about this challenge... I found a quirk about the TIO AWK setup. I can't figure out way to specify input where a positional argument can contain a space. Meaning setup a TIO test that behaves like this commandline,
```
echo "this is the first parameter" second | gawk '{ print $1 }'
```
In TIO, the first parameter will be `"this` not the whole string. That means while it works in a terminal window, I can't show that it handle the second test for this challenge in TIO.
Here's how the code works... The test associated with the codeblock is always truthy, so the code always runs. It's only a test (rather then code) to avoid needing a `;` character. It does a couple of things by using AWK's willingness to combine multiple expressions into one "line" of code.
```
w=2-(n=split($1,p,"|"))+gsub(t=".",FS,$1)
```
First is splits the first parameter into in array of strings using the pipe character as the delimeter with `n=split($1,p,"|")`. It also saves the number of substrings generated in `n`. Then it changes all the characters in the first parameter to spaces with `gsub(t=".",FS,$1)` setting convenience constants `t` and `n` in the process.
Finally the value of `w` is set to the number of non-pipe characters in the first parameter by subtracting the number of sub-strings from the total number of characters in the original.
The associated code block is one statement, a `for` loop, that processes each substring.
```
for(;s++<n;gsub(t,FS,b))y=y substr((b=b p[s])$1,1,w)$2RS
```
The iteration check is simple `s++<n`. The end of loop statement converts all the characters in the previous output line to blanks `gsub(t,FS,b)`, which turns it into the prefix for the next line. The body of the loop constructs and appends the next line of output to an accumulator `y`. That string is a concatenation of the previous string, plus the current string (code fragment) with a bunch of blanks appended (meaning `$1`) `(b=b p[s])$1`. That mess is truncated to the length we want `w` and the comment delimiter and LF are appended with `y=y substr(...,w)$2RS`.
Once all the code substrings have been processes, assigning `$0` to the accumulator takes care if printing out the results.
```
$0=y
```
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal) `j`, 74 [bitsv2](https://github.com/Vyxal/Vyncode/blob/main/README.md), 9.25 bytes
```
\|/:¬¶‚Ü≥:t‚Ü≤·∏ä
```
[Try it Online!](https://vyxal.pythonanywhere.com/?v=2#WyJqPSIsIiIsIlxcfC86wqbihrM6dOKGsuG4iiIsIiIsIlwidGhlfGZpdG5lc3N8Z3JhbXx8cGFjZXJ8dGVzdFwiXG5cIi8tLVwiIl0=)
Bitstring:
```
01101010100010101110000101000000110001011111111110001111111100110011110001
```
## Explained
```
\|/:¬¶‚Ü≥:t‚Ü≤·∏ä¬≠‚Å°‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å°‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å£‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å¢‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å§‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å°‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å£‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å¢‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å§‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å£‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å§‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å£‚Å°‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å¢‚Å°‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å£‚Å¢‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å¢‚Å¢‚Äã‚Äé‚Äè‚Äã‚Å¢‚Å†‚Å¢‚Äå¬≠
\|/         # ‚Äé‚Å°Split on "|"s
   :¬¶       # ‚Äé‚Å¢Push the cumulative sums without popping. This acts as the space length before each section
     ‚Ü≥      # ‚Äé‚Å£Pad each item right with spaces to length in ^
      :t‚Ü≤   # ‚Äé‚Å§And pad each item left with spaces to length of tail of ^
         ·∏ä  # ‚Äé‚Å¢‚Å°Append " {comment char}" to each
‚Äé‚Å¢‚Å¢Implicitly join on newlines
üíé
```
Created with the help of [Luminespire](https://vyxal.github.io/Luminespire) and not this challenge.
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 79 bytes
```
c=>s=>s.split`|`.map((_,i,a)=>a.map(y=>i--?y.replace(/./g,' '):y).join``+' '+c)
```
[Attempt This Online!](https://ato.pxeger.com/run?1=LYxBDsIgFAWvYnBRSAt1aUygR_AIghQqlQKRumjyb-KmMXoob2OjTSZ5mcWbxyvE1sxPy9_30dL956i5yAssJ-9GCZINKmF8qlylCBfqpxMXjtJmYjeTvNIG16zuqmJTkMNEWB9dkLJctNRkze50DDl6w3zssMVoiwhGCs4aWjBguwu4Hq7gYQgQEyLrb57_-wU)
+4 to add an extra space before `#`
[Answer]
# PHP, ~~120~~ ~~117~~ ~~116~~ ~~110~~ 109 bytes
```
foreach($a=split('\|',$argv[1])as$i=>$t){$c=preg_replace('#.#',' ',$a);$c[$i]=$t;echo join($c)," $argv[2]
";}
```
or
```
foreach($a=split('\|',$argv[1])as$t){$c=preg_replace('#.#',' ',$a);$c[$i++|0]=$t;echo join($c)," $argv[2]
";}
```
[Answer]
# [MATL](http://github.com/lmendo/MATL), ~~33~~ 31 bytes
```
'\|'0'|'hYXo8M&YbY:&YdtaZ)0ihYc
```
[Try it online!](http://matl.tryitonline.net/#code=J1x8JzAnfCdoWVhvOE0mWWJZOiZZZHRhWikwaWhZYw&input=J1RoaXN8Q29kZXxoYXN8fGVtcHR5fHxzZWN0aW9ucycKJyMn)
### Explanation
The builtin function `Yd` (`blkdiag`), which builds a block-diagonal matrix from its inputs, does most of the work. The fill values in the matrix are 0, and char 0 is treated as a space for displaying purposes. The code would simply split on `|`, build a matrix from the resulting blocks, convert to char, and append two columns with space and comment symbol.
However, the possibility of empty sections in the input string ~~complicates~~ makes the problem more interesting: the resulting block would be empty and thus wouldn't show in the resulting matrix.
To solve this, we introduce a char 0 before each `|`, so no block will be empty; and then in the resulting char matrix we remove columns that are formed by char 0 only. A non-empty code section will have some printable ASCII char, and thus the columns it spans will survive. An empty section will contribute a row, but won't introduce an extra column.
```
'\|'    % Push this string: source for regexp matching. It's just | escaped
0'|'h   % Push a string formed by char 0 followed by | (no escaping needed)
YX      % Input string implicitly. Replace first of the above string by the second
o       % Convert from chars to code points. Gives a numeric vector
8M      % Push '|' again
&Yb     % Split numeric vector at occurences of | (the latter is automatically
        % converted  to its code point). This gives a cell array of numeric vectors
Y:      % Unbox cell array: pushes the numeric vectors it contains
&Yd     % Form a block-diagonal matrix from those vectors
ta      % Duplicate. Compute vector that equals true for columns that have some
        % nonzero value
Z)      % Used that as a logical index (mask) for the columns of the matrix.
        % This removes columns that contain only zeros
0ih     % Input comment symbol and prepend char 0 (which will be displayed as space)
Yc      % Append that to each row of the matrix. The matrix is automatically 
        % converted from code points to chars
        % Display implicitly
```
[Answer]
# Ruby, ~~96~~ 80 bytes
```
->s,c{s.gsub(/(^|\|)([^|]*)/){" "*$`.count(t="^|")+$2+" "*(1+$'.count(t))+c+$/}}
```
See it on eval.in: <https://eval.in/639012>
I really ought to just learn Retina.
[Answer]
# Pyth, 30 bytes
```
VJcE\|s[*ZdN*h--lsJZlNdQ)=+ZlN
```
or
```
jm+dQ.t.t+MC,.u*l+NYdJc+Ed\|kJ
```
Both are full programs that take input on STDIN of the comment string, and then the program string, newline-separated.
[Try the first version online](https://pyth.herokuapp.com/?code=VJcE%5C%7Cs%5B%2aZdN%2ah--lsJZlNdQ%29%3D%2BZlN&test_suite=1&test_suite_input=%27%23%27%0A%22a%7Cbc%7Cd%7Ce%7Cfgh%7Cij%7Ck%7Cl%7Cmn%7Cop%22%0A%22%2F%22%0A%22Hello%7CWorld%22%0A%22%2C%22%0A%22a%7Cb%7Cc%7Cd%7Ce%7Cf%7Cg%22%0A%22%3A%22%0A%22abcdefg%22%0A%27%25%27%0A%224%7C8%7C15%7C16%7C23%7C42%22%0A%22%21%22%0A%22E%7Cac%7Ch+s%7Cecti%7Con+is%7C+one+c%7Characte%7Cr+longer%7C+than+the%7C+last%21%22%0A%22%40%22%0A%22This%7CCode%7Chas%7C%7Cempty%7C%7Csections%22&debug=0&input_size=2)
[Try the second version online](https://pyth.herokuapp.com/?code=jm%2BdQ.t.t%2BMC%2C.u%2al%2BNYdJc%2BEd%5C%7CkJ&test_suite=1&test_suite_input=%27%23%27%0A%22a%7Cbc%7Cd%7Ce%7Cfgh%7Cij%7Ck%7Cl%7Cmn%7Cop%22%0A%22%2F%22%0A%22Hello%7CWorld%22%0A%22%2C%22%0A%22a%7Cb%7Cc%7Cd%7Ce%7Cf%7Cg%22%0A%22%3A%22%0A%22abcdefg%22%0A%27%25%27%0A%224%7C8%7C15%7C16%7C23%7C42%22%0A%22%21%22%0A%22E%7Cac%7Ch+s%7Cecti%7Con+is%7C+one+c%7Characte%7Cr+longer%7C+than+the%7C+last%21%22%0A%22%40%22%0A%22This%7CCode%7Chas%7C%7Cempty%7C%7Csections%22&debug=0&input_size=2)
**How they work**
```
VJcE\|s[*ZdN*h--lsJZlNdQ)=+ZlN  Program. Inputs: E, Q
  cE\|                          Split E on "|"
 J                              Assign to J
                                Implicit Z=0
V                               For N in that:
       [                )        Create a list with elements:
        *Zd                       Z spaces
           N                      N
               -lsJZ              len(concatenate(J))-Z
              -     lN             -len(N)
             h                     +1
            *         d            spaces
                       Q          Q
      s                          Concatenate the list
                                 Implicitly print
                        =+ZlN    Z=Z+len(N)
jm+dQ.t.t+MC,.u*l+NYdJc+Ed\|kJ  Program. Inputs: E, Q
                       +Ed      Add a trailing space to E
                      c   \|    Split that on "|"
                     J          Assign to J
             .u                 Cumulatively reduce J with:
                            k    starting value empty string and
                                 function N, Y ->
                l+NY              len(N+Y)
               *    d             spaces
            ,                J  Two-element list of that and J
           C                    Transpose
         +M                     Map concatenation over that
       .t                       Transpose, padding with spaces
     .t                         Transpose again
 m+dQ                           Map concatenation with Q over that
j                               Join on newlines
                                Implicitly print
```
[Answer]
# Perl, 63 bytes
Includes +5 for `-Xpi`
Run with input on STDIN and comment character after -i:
```
perl -Xpi% esolang.pl <<< "Ab|Cd||ef"
```
`esolang.pl`:
```
s/
/|/;s%(.*?)\|%$"x$`=~y/|//c.$1.$"x$'=~y/|//c." $^I
"%eg
```
Totally boring straightforward solution
[Answer]
# [Turtl√®d](https://github.com/Destructible-Watermelon/turtl-d/), 35 bytes (noncompeting)
Takes one input, the last character is the comment character. Does not work with comment character as space, but I assume that isn't necessary.
```
!' [*.+(|' dl)r_]' r[*+.(|u)_][ .d]
```
Explanation:
```
!                                  take input into string variable
 '                                 write space over current cell
   [*           ]                  while cell is not *
     .+                            write pointed char of string, stringpointer+1 (starts 0)
       (|    )                     if current cell is |
         ' dl                      write space (over |), move down, left
              r_                   move right, write * if pointed char is
                                   last char, else space
                 ' r               write space, move right
                    [*       ]     while cell is not *
                      +.           increment pointer and write pointed char
                        (|u)       if cell is |, move up
                            _      write * if the pointed char is the last char
                              [   ] while cell is not space
                                .d  write the pointed char from string, move down 
```
[Answer]
# GolfScript, 85 bytes
```
{(;);}:r;", "%(r\(r n+:c;;.,\'|'%.,@\-)):l;0:m;{.,0>}{" "m*\(.,m+:m l\-" "\*+c@}while
```
[Try it online](http://golfscript.tryitonline.net/#code=eyg7KTt9OnI7IiwgIiUoclwociBuKzpjOzsuLFwnfCclLixAXC0pKTpsOzA6bTt7LiwwPn17IiAibSpcKC4sbSs6bSBsXC0iICJcKitjQH13aGlsZQ&input=IkhlbGxvLHxXb3JsZCF8VGhpc3xpc3xHb2xmU2NyaXB0IiwgIiMi&debug=on)
# 2017 Update - [GolfScript](https://tio.run/##FccxDsIwDADAnVdYZrCgbgJrIiT@QRhooMU00ArY6ubroUyn64bUfuJbxm8pxEA2Zxd93lvDwUykdJiZj6HeuORPS89258RPhqVyAgmkJqBtrMIfXGGYbSl40SbqVW/adneVh/aa9PnSYUQGXOMP) - 71 bytes
```
', '/~~:c;~1/.,\.{'|'=},,@\-):l;['|']/0:i;{.,i+:i l i-' '*c+\' '*"
"\}/
```
### Explanation
```
', '/~~:c;~1/        # Parses input
.,\.{'|'=},,@\-):l;  # Computes string length without '|'
['|']/               # Splits the array
0:i;                 # Counter
{.,                  # Length of the substring
i+:i                 # Counter update
l i-' '*c+\          # Adds spaces after the substring 
' '*"\n"\            # Adds spaces before the next substring
}/                   # ...For each substring
```
[Answer]
# [Funky](https://github.com/TehFlaminTaco/Funky), 89 bytes
```
s=>c=>{y=0forn inl=s::split"|"print((v=" "::rep)(y)+l[n]+v((#l::reduce@++1)-y+=#l[n])+c)}
```
[Try it online!](https://tio.run/##dVDdasIwFL62T3GMCA3twDo3RiUiyN7AO@lFTE@1rKZdE4XS02fvUlc2mCwXB/L9JefLrvqj6TPRG7FRYtM2YpGVtYZcF8LEsamK3DJiVZ1r6/s3wYDFcY0V9xseFAedBDffnxUDll4VboMg4k9NIGYDxwPFu36Pxu6kQQMCWm/SMklHUpQSUkYnFgILWRfeiaNKMbtD8Qit6I2iF4peaflMq@VAzUfqnaSiMxhCZXMq3Z8NQakRHCprqSxSDUWpT1gT2LPUbiBBIY2dDjnTMWd/dsZdmaKzGSK8VLYhMkNqqc2g3LLO6zzPFQO5awZ@N2o9GM93Q2z@6fpxwou0/o/skCeHRcLD/9ko4XztTbIHz4Ns/edF/nDv@i8 "Funky ‚Äì Try It Online")
[Answer]
# [Python 3](https://docs.python.org/3/), 108 bytes
```
s,c=input().split("|"),input()
i,S=0,len("".join(s))
for l in s:L=len(l);print(" "*i+l+" "*(S-L-i+1)+c);i+=L
```
[Try it online!](https://tio.run/##LYtBCsIwEADvfUXIKWvSonizBApee6sfkBrpStyEbjwU9u/RgqeBGSZvZUl0rpXd7JHypxjoOEcsRosG91cNuskfXQxktO5eCckwQPNMq4oKSfFl9HuM0OcV6TcrfUAb7U4ztWOL9gR2hh6tH2u9LchyTY8gy51FwjuXTYTDXDARN8MX) Simple solution -- keep track of how many spaces we have (i) and accumulate.
[Answer]
# Python 3.8 (pre-release), 99 bytes
Different approach:
```
def f(c,d,i=0):
 for y in(x:=c.split('|')):z=[' '*len(e)for e in x];z[i]=y;print(''.join(z),d);i+=1
```
[Try it online!](https://tio.run/##ZZHNasMwEITvfoqNS5GVuCF/LcHBUCh9g97SUBR5HSu1JWPpEId9d1eqQy657GH2m9EyantXGb3ett0wFFhCmci0SFW@4FkEpemgB6WTS5bLuW1r5RJGjPPsmu8ZsGmNOkEeMPQYXA67614d8n7Xdkp7ls3PxtuvPC34Ts3y5eDQOiksWshhHyWxoKOkgpDKU0XqTL9UU6PJtHEK8VPM05GhG0SnoKc3/Sj9yf9KNiob2tLylZZvtFrTZhU2z@Pmk4SkCiyhdIqMBmUJjEbwquiEdEgd1EafsCNwldB@IEEtrJuEmMkY81V534cp0LssETat64lsCDXaBvA95tEhikIn0nOpn02D2v1I/04o6d6AL/hW0wubbhcz9q0Zj8IPPPj4HWV8@AM "Python 3.8 (pre-release) ‚Äì Try It Online")
Ungolfed with explanation:
```
def f(c,d,i=0):
 x=c.split('|')              # break string by '|'
 for y in x:                 # for each element of list
  z=[' '*len(e) for e in x]  # create a list of blank strings
  z[i]=y                     # insert element we care about into otherwise blank list
  print(''.join(z),d)        # print line
  i+=1                       # increment
```
]