@@ -786,9 +786,25 @@ pro htmlizer::ProcessString, text, $
786
786
787
787
; save our updates
788
788
if (i eq 0 ) then begin
789
+ ; we made it this far, check if we are in parenthesis or not
790
+ ; if we are, we are not the start of the string, i.e. (this.that()).method,
791
+ posParen = stregex (text , '\(([^)]+)\)' , LENGTH = lParen)
792
+
793
+ ; set our start flag accordingly
794
+ case (1 ) of
795
+ ; no paren
796
+ (posParen eq - 1 ): string_start = 0
797
+
798
+ ; between start and end
799
+ ((posParen lt start) AND (start lt (posParen + lParen))): string_start = 1
800
+
801
+ ; default
802
+ else : string_start = 0
803
+ endcase
804
+
805
+ ; extract the string
789
806
strings = [strmid (text , 0 , start), new, strmid (text , start+ length), strings[i+ 1 :- 1 ]]
790
807
process = [1 , 0 , 1 , process[i+ 1 :- 1 ]]
791
- string_start = 0
792
808
endif else begin
793
809
strings = [strings[0 : (i- 1 )> 0 ], strmid (text , 0 , start), new, strmid (text , start+ length), strings[i+ 1 :- 1 ]]
794
810
process = [process[0 : (i- 1 )> 0 ], 1 , 0 , 1 , process[i+ 1 :- 1 ]]
@@ -833,9 +849,24 @@ pro htmlizer::ProcessString, text, $
833
849
834
850
; save our updates
835
851
if (i eq 0 ) then begin
852
+ ; we made it this far, check if we are in parenthesis or not
853
+ ; if we are, we are not the start of the string, i.e. (this.that()).method,
854
+ posParen = stregex (text , '\(([^)]+)\)' , LENGTH = lParen)
855
+
856
+ ; set our start flag accordingly
857
+ case (1 ) of
858
+ ; no paren
859
+ (posParen eq - 1 ): string_start = 0
860
+
861
+ ; between start and end
862
+ ((posParen lt start) AND (start lt (posParen + lParen))): string_start = 1
863
+
864
+ ; default
865
+ else : string_start = 0
866
+ endcase
867
+
836
868
strings = [strmid (text , 0 , start), new, strmid (text , start+ length), strings[i+ 1 :- 1 ]]
837
869
process = [1 , 0 , 1 , process[i+ 1 :- 1 ]]
838
- string_start = 0
839
870
endif else begin
840
871
strings = [strings[0 : (i- 1 )> 0 ], strmid (text , 0 , start), new, strmid (text , start+ length), strings[i+ 1 :- 1 ]]
841
872
process = [process[0 : (i- 1 )> 0 ], 1 , 0 , 1 , process[i+ 1 :- 1 ]]
@@ -867,6 +898,7 @@ pro htmlizer::ProcessString, text, $
867
898
; get the next character
868
899
nextChar = strmid (text ,start+ length,1 )
869
900
901
+ ; make sure we are not a property
870
902
if (total (nextChar eq ['.' ]) gt 0 ) then begin
871
903
; i.e. this.that, THIS = 5, THAT = 6
872
904
add = start+ length
@@ -901,7 +933,7 @@ pro htmlizer::ProcessString, text, $
901
933
902
934
; check to make sure that, if there are strings after the name that there is
903
935
; a comma present. otherwise we probably have a property
904
- if (strtrim (strmid (text , ( start + length + 1 ) < strlen ( text ) ),2 ) ne '' ) AND (commaStart eq - 1 ) then continue
936
+ if (strtrim (strmid (text , start + length + 1 ),2 ) ne '' ) AND (commaStart eq - 1 ) then continue
905
937
906
938
; get original starting point
907
939
startOrig = start
@@ -1256,7 +1288,6 @@ pro htmlizer::ProcessString, text, $
1256
1288
1257
1289
; recursively search the string
1258
1290
while (start ne - 1 ) do begin
1259
-
1260
1291
; check if special escape character for HTML with gt or lt
1261
1292
; if found, search rest of string, otherwise break
1262
1293
charBefore = strmid (text , start- 1 , 1 )
@@ -1299,7 +1330,6 @@ pro htmlizer::ProcessString, text, $
1299
1330
endif
1300
1331
endif
1301
1332
1302
-
1303
1333
; check for us being wihtin a function call
1304
1334
posFunc = stregex (text , '\([^]]+\)' , LENGTH = funcLength)
1305
1335
if (posFunc ne - 1 ) then begin
@@ -1311,9 +1341,8 @@ pro htmlizer::ProcessString, text, $
1311
1341
; check if we are within the start of a function call that does not end on this line
1312
1342
; this could be robustified, but will cover most cases
1313
1343
posFunc = strpos (text , '(' )
1314
- posContinue = strpos (text , '$' )
1315
1344
if (posFunc ne - 1 ) then begin
1316
- if (start gt posFunc) AND (posContinue ne - 1 ) then begin
1345
+ if (start gt posFunc) then begin
1317
1346
continue
1318
1347
endif
1319
1348
endif
@@ -1797,4 +1826,41 @@ pro HTMLizer__define
1797
1826
; base link for content
1798
1827
BASELINK: '' $
1799
1828
}
1829
+ end
1830
+
1831
+ ; main level program that shown an example of how you can use the routine
1832
+
1833
+ ; specify our input file
1834
+ inputFile = file_which ('python__define.pro' )
1835
+
1836
+ ; read in plot.pro
1837
+ strings = htmlizer_read_file(inputFile)
1838
+ strings = '(it->expects())->toFindInArray, scalar'
1839
+
1840
+ ; initialize the object
1841
+ html = htmlizer()
1842
+
1843
+ ; process some strings
1844
+ coloredStrings = html.Htmlize(strings, / DOCS_LINKS, / TOOLTIPS)
1845
+
1846
+ ; clean up
1847
+ html.cleanup
1848
+
1849
+ ; make our strings an official HTML file
1850
+ coloredStrings = $
1851
+ ['<html><head><link rel="stylesheet" type="text/css" href="./idl-styles.css"></head><body>' ,$
1852
+ coloredStrings,$
1853
+ '</body></html>' ]
1854
+
1855
+ ; set up our output file
1856
+ outFile = filepath (file_basename (inputFile, '.pro' ) + '.html' , / TMP)
1857
+
1858
+ ; write tot disk
1859
+ htmlizer_write_file, outFile, coloredStrings
1860
+
1861
+ ; copy CSS to output directory
1862
+ htmlizer_copy_css, file_dirname (outFile)
1863
+
1864
+ print , 'Output file : ' + outFile
1865
+
1800
1866
end
0 commit comments