Index: openacs-4/packages/acs-tcl/tcl/test/html-conversion-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/test/html-conversion-procs.tcl,v diff -u -r1.12 -r1.13 --- openacs-4/packages/acs-tcl/tcl/test/html-conversion-procs.tcl 30 Sep 2017 18:12:52 -0000 1.12 +++ openacs-4/packages/acs-tcl/tcl/test/html-conversion-procs.tcl 15 Mar 2018 12:33:05 -0000 1.13 @@ -298,6 +298,87 @@ } +aa_register_case -cats {api smoke} -procs {ad_html_text_convert} ad_text_html_convert_to_plain { + Test rendering of a more or less standard HTML text +} { + + set html {Some Title +

An H1 Title

+

This is bold and this is strong. + This is italics and this is em. + A text with a link. +

+

An H2 Title

+

Now the same with a blockquote: +

+ This is bold and this is strong. + This is italics and this is em. + A text with a link. +
+ Now a text with a ul: + + Now a text with a ol: +
    +
  1. First enumerated item +
  2. Second enumerated item +
+ + and a program +
+        set x 1
+        set r [expr {$x + 1}]
+        
+ } + set result [ad_html_text_convert -from text/html -to text/plain $html] + + aa_log "Resulting text:\n$result" + aa_true "Text contains title" [string match {Some Title*} $result] + aa_true "

and

are detected and marked with stars" { + [string first "\n*An H1" $result] > 0 + && [string first "\n**An H2" $result] > 0 + } + aa_true " and are converted" { + [string first {*bold*} $result] > 0 + && [string first {*strong*} $result] > 0 + } + aa_true " and are converted" { + [string first {_italics_} $result] > 0 + && [string first {_em_} $result] > 0 + } + aa_true "
    is converted" { + [string first "\n- First list" $result] > 0 + && [string first "\n- Second list" $result] > 0 + } + aa_true "
      is converted (same as
        )" { + [string first "\n- First enumerated" $result] > 0 + && [string first "\n- Second enumerated" $result] > 0 + } + + aa_true "
         results in linebreaks and deeper indentation" {
        +        [string first "\n        set x" $result] > 0
        +        && [string first "\n        set r" $result] > 0
        +    }
        +    
        +
        +    aa_true "Text contains two links" {
        +        [string first {[1].} $result] > 0
        +        && [string first {[2].} $result] > 0
        +    }
        +    aa_true "Text contains two references" {
        +        [string first {[1] /foo} $result] > 0
        +        && [string first {[2] /bar} $result] > 0
        +    }
        +    aa_true "Blockquote is indented" {
        +        [string first {    This is *bold} $result] > 0
        +    }
        +    
        +
        +
        +}
        +
         # Local variables:
         #    mode: tcl
         #    tcl-indent-level: 4