src/Pure/Thy/thy_edit.ML
changeset 27863 a084895d8b91
parent 27846 2828a276dc93
child 28434 56f0951f4d26
equal deleted inserted replaced
27862:8f727f7c8c1d 27863:a084895d8b91
    21   val span_source: (OuterLex.token, 'a) Source.source ->
    21   val span_source: (OuterLex.token, 'a) Source.source ->
    22     (span, (OuterLex.token, 'a) Source.source) Source.source
    22     (span, (OuterLex.token, 'a) Source.source) Source.source
    23   val parse_spans: Scan.lexicon * Scan.lexicon -> Position.T -> string -> span list
    23   val parse_spans: Scan.lexicon * Scan.lexicon -> Position.T -> string -> span list
    24   val present_span: span -> output
    24   val present_span: span -> output
    25   val report_span: span -> unit
    25   val report_span: span -> unit
    26   val present_html: Path.T -> Path.T -> unit
       
    27 end;
    26 end;
    28 
    27 
    29 structure ThyEdit: THY_EDIT =
    28 structure ThyEdit: THY_EDIT =
    30 struct
    29 struct
    31 
    30 
   147 fun report_span span =
   146 fun report_span span =
   148   Position.report (kind_markup (span_kind span)) (Position.encode_range (span_range span));
   147   Position.report (kind_markup (span_kind span)) (Position.encode_range (span_range span));
   149 
   148 
   150 end;
   149 end;
   151 
   150 
   152 
       
   153 (* HTML presentation -- example *)
       
   154 
       
   155 fun present_html inpath outpath =
       
   156   parse_spans (OuterKeyword.get_lexicons ()) (Path.position inpath) (File.read inpath)
       
   157   |> HTML.html_mode (implode o map present_span)
       
   158   |> enclose
       
   159     (HTML.begin_document (Path.implode (Path.base inpath)) ^ "<div class=\"source\"><pre>")
       
   160     ("</pre></div>" ^ HTML.end_document)
       
   161   |> File.write outpath;
       
   162 
       
   163 end;
   151 end;