| | 23 | |
| | 24 | ;+ |
| | 25 | ; Process directives. |
| | 26 | ;- |
| | 27 | pro docparrstmarkupparser::_processDirective, line, pos, len, tree=tree |
| | 28 | compile_opt strictarr |
| | 29 | |
| | 30 | fullDirective = strmid(line, pos + 3L, len) |
| | 31 | tokens = strsplit(fullDirective, '::[[:space:]]+', /regex, /extract) |
| | 32 | |
| | 33 | case strlowcase(tokens[0]) of |
| | 34 | 'image': begin |
| | 35 | tag = obj_new('MGtmTag', type='image') |
| | 36 | tag->addAttribute, 'source', tokens[1] |
| | 37 | end |
| | 38 | else: self.system->warning, 'unknown rst directive ' + tokens[0] |
| | 39 | endcase |
| | 40 | |
| | 41 | beforeDirective = strmid(line, 0, pos) |
| | 42 | afterDirective = strmid(line, pos + len) |
| | 43 | tree->addChild, obj_new('MGtmText', text=beforeDirective) |
| | 44 | tree->addChild, tag |
| | 45 | tree->addChild, obj_new('MGtmText', text=afterDirective) |
| | 46 | tree->addChild, obj_new('MGtmTag', type='newline') |
| | 47 | end |
| 58 | | if (code && (currentIndent eq -1 || currentIndent gt indent)) then begin |
| 59 | | listing->addChild, obj_new('MGtmText', text=strmid(cleanline, indent)) |
| 60 | | listing->addChild, obj_new('MGtmTag', type='newline') |
| 61 | | endif else begin |
| 62 | | para->addChild, obj_new('MGtmText', text=cleanline) |
| 63 | | para->addChild, obj_new('MGtmTag', type='newline') |
| | 84 | directivePos = stregex(cleanline, '\.\. [[:alpha:]]+:: [[:alnum:]_/.\-]+', $ |
| | 85 | length=directiveLen) |
| | 86 | |
| | 87 | if ((~code || (currentIndent gt -1 && currentIndent le indent)) && directivePos ne -1L) then begin |
| | 88 | self->_processDirective, cleanline, directivePos, directiveLen, tree=para |
| | 90 | endif else begin |
| | 91 | if (code && (currentIndent eq -1 || currentIndent gt indent)) then begin |
| | 92 | listing->addChild, obj_new('MGtmText', text=strmid(cleanline, indent)) |
| | 93 | listing->addChild, obj_new('MGtmTag', type='newline') |
| | 94 | endif else begin |
| | 95 | para->addChild, obj_new('MGtmText', text=cleanline) |
| | 96 | para->addChild, obj_new('MGtmTag', type='newline') |
| | 97 | code = 0B |
| | 98 | endelse |