• Add Indenting Markup

    By Dave Parillo 2 decades ago

    I like the simple markup mediawiki uses to control indenting paragraphs. I added a function to the WikiPage.class to convert ':' to div tags. Multiple :'s result in larger div margins.


       ' Indent 2em spaces for each colon found at the beginning of a line<br/>
       ' param txt           - the whole wiki page text<br/>
       ' param amount  - the number of :'s to search for<br/>
    Private Function doIndent (txt As String, amount As Integer) As String<br/>
        doIndent = ReplaceRangeEnds(txt, Chr(10) &amp; Ustring(amount, &quot;:&quot;), Chr(10), _<br/>
        &quot;&lt;div style='margin-left:  &quot; &amp; (2 * amount) &amp; &quot;em'&gt;&quot; , &quot; &lt;/div&gt;&quot;  ,  &quot;*&quot; , True)        <br/>
    End Function<br/>
    



    doIndent is called from parseIndent which just calls doIndent in a loop, processing most colons first.



    I can't say I totally understand the ReplaceRangeEnds function. As written, this only properly indents adjacent paragraphs (with the same indent level) if there is an intervening blank line. i.e.

    : Level 1

    : Level A

    Fails to indent level A. Ah well.

    • a hack re: indenting markup

      By Dave Parillo 2 decades ago

      This works, but is a hack:

        ' Indent 2em spaces for each colon found at the beginning of a line<br/>
         ' param txt           - the whole wiki page text<br/>
         ' param amount  - the number of :'s to search for<br/>
      Private Function doIndent (txt As String, amount As Integer) As String<br/>
          doIndent = ReplaceRangeEnds(txt, Chr(10) &amp; Ustring(amount, &quot;:&quot;), Chr(10), _<br/>
          Chr(10) &amp; &quot;&lt;div style='margin-left:  &quot; &amp; (2 * amount) &amp; &quot;em'&gt;&quot; , &quot; &lt;/div&gt;&quot; &amp; Chr(10),  &quot;*&quot; , True)  <br/>
          <br/>
          doIndent = ReplaceRangeEnds(doIndent, Chr(10) &amp; Ustring(amount, &quot;:&quot;), Chr(10), _<br/>
          &quot;&lt;div style='margin-left:  &quot; &amp; (2 * amount) &amp; &quot;em'&gt;&quot; , &quot; &lt;/div&gt;&quot;,  Chr(10) , False)   <br/>
      End Function<br/>
      



      I don't like this code, but it beats forcing users to insert extra blank lines in the wiki text.