#UI_ENHANCEMENT by cg
authorClaus Gittinger <cg@exept.de>
Wed, 04 Dec 2019 14:04:28 +0100
changeset 4520 f7e5c7641306
parent 4519 e0aab139cd66
child 4521 e143e651704f
#UI_ENHANCEMENT by cg class: HTMLDocGenerator comment/format in: #extractExamplesFromClass: changed: #generateExamples:
HTMLDocGenerator.st
--- a/HTMLDocGenerator.st	Tue Dec 03 21:52:29 2019 +0100
+++ b/HTMLDocGenerator.st	Wed Dec 04 14:04:28 2019 +0100
@@ -718,12 +718,24 @@
     "everything between exBegin and exEnd is shown as code example;
      the remaining text is shown as regular text (commenting the code, I hope)"
 
-    |inExample|
+    |inExample needPre|
 
     inExample := false.
     outStream nextPutLine:'<h2><a name="EXAMPLES" href="#I_EXAMPLES">Examples:</A></h2>'.
     outStream nextPutLine:'<BR>'.
 
+    needPre := false.
+    (examples contains:[:line | line includesString:'[exBegin]']) ifFalse:[
+        needPre := true.
+        "/ but not if it looks like html
+        ((examples contains:[:line | line includesString:'<pre>'])
+        or:[(examples contains:[:line | line includesString:'<html>'])]) ifTrue:[
+            needPre := false
+        ]
+    ].
+
+    needPre ifTrue:[ outStream nextPutLine:'<pre>'].
+
     examples do:[:line |
         line withoutSeparators = '[exBegin]' ifTrue:[
             inExample ifTrue:[
@@ -745,6 +757,7 @@
     inExample ifTrue:[
         self generateExampleEnd.
     ].
+    needPre ifTrue:[ outStream nextPutLine:'</pre>'].
     self generateHorizontalLine.
 !
 
@@ -1589,6 +1602,7 @@
     ].
 
     examples isEmpty ifTrue:[ ^ nil].
+
     makePre ifTrue:[
         examples addFirst:'<pre>'.
         examples addLast:'</pre>'.