198 |
198 |
199 fun is_hidden (Latex.Basic tk, _) = |
199 fun is_hidden (Latex.Basic tk, _) = |
200 T.is_kind T.Command tk andalso T.val_of tk mem !hidden_commands |
200 T.is_kind T.Command tk andalso T.val_of tk mem !hidden_commands |
201 | is_hidden _ = false; |
201 | is_hidden _ = false; |
202 |
202 |
|
203 fun filter_newlines toks = (case mapfilter |
|
204 (fn (tk, i) => if is_newline tk then Some tk else None) toks of |
|
205 [] => [] | [tk] => [tk] | _ :: toks' => toks'); |
|
206 |
203 fun present_tokens lex (flag, toks) state state' = |
207 fun present_tokens lex (flag, toks) state state' = |
204 Buffer.add (case flag of None => "" | Some b => Latex.flag_markup b) o |
208 Buffer.add (case flag of None => "" | Some b => Latex.flag_markup b) o |
205 ((if !hide_commands andalso exists (is_hidden o fst) toks then [] |
209 ((if !hide_commands andalso exists (is_hidden o fst) toks then [] |
|
210 else if !hide_commands andalso is_proof state then |
|
211 if is_proof state' then [] else filter_newlines toks |
206 else mapfilter (fn (tk, i) => |
212 else mapfilter (fn (tk, i) => |
207 if i > ! interest_level then None |
213 if i > ! interest_level then None else Some tk) toks) |
208 else if !hide_commands andalso is_proof state then |
|
209 if not (is_proof state') andalso is_newline tk then Some tk |
|
210 else None |
|
211 else Some tk) toks) |
|
212 |> map (apsnd (eval_antiquote lex state')) |
214 |> map (apsnd (eval_antiquote lex state')) |
213 |> Latex.output_tokens |
215 |> Latex.output_tokens |
214 |> Buffer.add); |
216 |> Buffer.add); |
215 |
217 |
216 |
218 |